Skip to content
WikilyWIKILY
All games23 Wikis · pick your game
Commands and cheatsAll commands

Switch game

23 Wikis · pick your game
/compute

Command

/compute

Calculates a number from a number provider and reports it, so it can be read in chat or stored with /execute store.

Syntax

/compute (block <computePos>|entity <computeTarget>) float <provider> [<scale>]
/compute (block <computePos>|entity <computeTarget>) integer <provider>
/compute default float <provider> [<scale>]
/compute default integer <provider>

Arguments

ArgumentKind of valueWhat to type
<computePos>Block positionFor block: the position of the block the calculation looks at.
<provider>Decimal number providerThe number provider to calculate: an id, or a definition written inline. After integer it must be a whole-number provider, after float a decimal-number provider.
<scale>Decimal numberFor float only: a number the value is multiplied by before rounding down. Defaults to 1.
<computeTarget>Target selectorFor entity: the single entity the calculation looks at. One entity only.

Details

Permission level2: operators, worlds with cheats on, command blocks and functions
Works inSingleplayer with cheats enabled and multiplayer servers. Needs permission level 2 (gamemasters): server operators, players with cheats, command blocks, and functions can all run it.
ResultReports the value the number provider returned. The number /execute store saves is that value. For float, the value is multiplied by the scale and rounded down to a whole number, and the message shows both the original and the rounded value when they differ.
defaultCalculates with only the basic information: the position the command runs at and, if there is one, the entity running it.
blockAlso gives the calculation the block at the given position, with its block state and its stored data if it has any. The position must be loaded.
entityAlso gives the calculation the given entity as its target entity.
integerUses a whole-number provider and returns its value unchanged.
floatUses a decimal-number provider. The optional scale multiplies the value before it is rounded down, so a scale of 100 keeps two decimals.
ProviderThe provider is either the id of a number provider from the game or a data pack, such as minecraft:brewing/uses_default, or one written directly in the command, such as a plain number or {type:"minecraft:uniform",min:1,max:6}.
Invalid valuesFails with "returned invalid value" if the calculation cannot produce a usable number, for example a division by zero or a result that is not a finite number.

Examples

/compute default integer minecraft:brewing/uses_default

Shows the value of the built-in brewing uses number provider, which is 20.

/compute default integer {type:"minecraft:uniform",min:1,max:6}

Rolls a random whole number from 1 to 6.

/compute block ~ ~-1 ~ integer minecraft:cooking/time_coal

Calculates the built-in Coal cooking time provider for the block below you.

/compute default float minecraft:cooking/fast_speed_multiplier 100

Shows the fast cooking speed multiplier and returns it multiplied by 100.

Join the creator communityThe people who build the Minecraft Java Edition wiki are on our Discord. Ask questions or suggest pages.Join Discord (opens Discord in a new tab)