/compute Command in Minecraft Java Edition

Calculate Numbers from Providers with the Compute Command

Java EditionDebug & DeveloperPermission: Level 2Added in 26.3

The /compute command lets you evaluate number providers directly in the game. It takes an inline SNBT provider and calculates either an integer or a decimal number based on the context you choose.

Map makers and data pack creators use this command to test math logic, read entity scores, and generate random numbers. You can run the calculation using a default setup, a specific block position, or a targeted entity.

Syntax (Java 26.3, 6 forms)

  1. /compute block <computePos> float <provider> [<scale>]
  2. /compute block <computePos> integer <provider>
  3. /compute default float <provider> [<scale>]
  4. /compute default integer <provider>
  5. /compute entity <computeTarget> float <provider> [<scale>]
  6. /compute entity <computeTarget> integer <provider>

The forms you will use most

/compute default integer <provider>
Calculates a whole number using the default context.
/compute default float <provider> [<scale>]
Calculates a decimal number using the default context and optionally multiplies it by a scale before rounding.
/compute block <computePos> integer <provider>
Calculates a whole number using a specific block position as the context.
/compute block <computePos> float <provider> [<scale>]
Calculates a decimal number at a specific block position and optionally applies a scale factor.
/compute entity <computeTarget> integer <provider>
Calculates a whole number using a single player or mob as the context.
/compute entity <computeTarget> float <provider> [<scale>]
Calculates a decimal number using a single entity as the context, with an optional scale multiplier.

Arguments

ArgumentTypeWhat it means
<computePos>block positionThe three block coordinates (x y z) for the calculation, which can use ~ for relative positions or ^ for local coordinates.
<provider>context float providerThe context int provider or context float provider written inline as SNBT to define how the number is calculated.
<scale>decimal numberAn optional decimal number that multiplies the result of a float provider before rounding it to a whole number.
<provider>context int providerThe context int provider or context float provider written inline as SNBT to define how the number is calculated.
<computeTarget>target selector
one target
A player name, UUID, or target selector like @p or @s that selects a single entity.

Examples

Version history

Measured from the game files of every Java release from 1.13 to 26.3.

  1. 26.3 Command added.

Tips

Common mistakes

Java vs Bedrock

The /compute command is only available in Minecraft Java Edition starting in version 26.3. Bedrock Edition does not have a command with this name.

FAQ

When was the /compute command added to Minecraft?

The /compute command was added to Minecraft Java Edition in version 26.3.

Why does /compute reject a regular number?

The command expects a context provider written in SNBT format rather than a bare number, so you must format it like {type:"minecraft:constant",value:10}.

What does the scale number do in a float compute command?

The optional scale argument multiplies the decimal number from the float provider and then rounds the final answer to a whole number.

Related commands

/debug/help/jfr/perf/stopwatch/test/tick/version