Minecraft:Number provider
More actions
Template:For Template:Exclusive Template:Update Template:Wip A number provider or context number provider is a data structure used to provide a number, which can be a constant, a random number within a certain distribution, or read from Minecraft:scores or Minecraft:storage etc., and mathematical operations or conditional dispatches can be applied. Number providers are used in Minecraft:loot tables, Minecraft:predicates, Minecraft:item modifiers, villager trade, Minecraft:trade sets, the Template:Cmd command, the Template:Cd operation in the Template:Cmd command, and by reference in data components (Template:DCL, Template:DCL, and Template:DCL).
JSON definition
Use
Number providers can be written in-line in Minecraft:loot tables, Minecraft:predicates, Minecraft:item modifiers, villager trade, and Minecraft:trade sets.
They can additionally be registered by a data pack from the Template:Cd or Template:Cd Minecraft:registry, and referenced using a Minecraft:namespaced identifier. References to registered number providers can be used in data components, such as Template:DCL, Template:DCL and Template:DCL. Only a constant or Minecraft:namespaced identifier may be used here, not inline definitions, due to the data structure only being understood server-side.
Number providers can additionally be used in-line or by reference in Template:Cmd and Template:Cmd to perform operations on data in scoreboards and storage. This is the only way to perform floating-point mathematics with commands.
Vanilla context_float_provider registries
These are registry context_float_providers used in the vanilla Minecraft:data pack
Template:File: Number providers used in the default component Template:Data component link:Template:JSON fileTemplate:File: Number providers used in the default component Template:Data component link Template:JSON fileTemplate:JSON fileTemplate:JSON file/cooking
Vanilla context_int_provider registries
These are registry context_int_providers used in the vanilla Minecraft:data pack.
Template:File: Number providers used in the default component Template:Data component link:Template:JSON file
Template:File: Number providers used in the default component Template:DCL: Template:JSON file Template:JSON file Template:JSON file Template:JSON fileTemplate:JSON fileTemplate:File: Number providers used in the default component Template:DCL:Template:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON fileTemplate:JSON file Template:JSON file Template:JSON fileSee Template:Slink for a list of items that use such number providers in the component Template:Cd by default.
Format
Template:UpdateTemplate:Incomplete section A a number provider can be an Template:Nbt or Template:Nbt. They can either be defined as a constant value or as an object.
- Template:Nbt: Constant number provider.
Or:
- Template:Nbt: The root tag. Shorthand for a uniform distributionTemplate:Until.
- Template:NbtTemplate:Nbt: Number provider. The minimum value.
- Template:NbtTemplate:Nbt: Number provider. The maximum value.
Or:
- Template:Nbt: Namespaced ID pointing to an element of number provider Minecraft:registry. See Template:Slink.
Or:
- Template:Nbt: The root tag.
- Template:Nbt: The number provider type as a Minecraft:resource location. .
- Extra fields of the number provider, described below.
Number providers types
Template:Past Each type of number provider specifies the rules by which the number will be provided. To do this, they use associated extra contents, which function differently for each type.
The type values can omit or include the namespace Template:Cd, for example using the type Template:Cd or Template:Cd has the same effect.
Number provider types can not be customized via data packs.
Each type has two ways to get a number: an Minecraft:integer or a Minecraft:float, which can be used in Template:Cd and Template:Cd respectively.
Table of types
| Type | Description | Integer | Float | Nbt |
|---|---|---|---|---|
| abs | Returns the absolute value of the input. | Template:Table choice | Template:Table choice |
|
| avg | The mean of all inputs. | Template:Table choice | Template:Table choice |
|
| binomial | A random number following a binomial distribution. The returned float has the same value as the int. | Template:Table choice | Template:Table choice |
|
| ceil | Returns the ceiling (i.e. rounded towards positive infinity) value of the input. | Template:Table choice | Template:Table choice |
|
| conditional | Returns the value from Template:NbtTemplate:Nbt if its Template:NbtTemplate:Nbt is met or Template:NbtTemplate:Nbt if not. | Template:Table choice | Template:Table choice |
|
| constant | A constant value. | Template:Table choice | Template:Table choice |
|
| cos | Returns the cosine of the input. | Template:Table choice | Template:Table choice |
|
| sub | Subtracts Template:NbtTemplate:Nbt from Template:NbtTemplate:Nbt and then returns that value | Template:Table choice | Template:Table choice |
|
| enchantment level | A value dependent on the level of the Minecraft:loot context enchantment. | Template:Table choice | Template:Table choice |
|
| floor | Returns the floor (i.e. rounded towards negative infinity) value of the input. | Template:Table choice | Template:Table choice |
|
| from_float | Converts a float provider to an integer value.
Non integer values will be rounded towards zero. |
Template:Table choice | Template:Table choice |
|
| from_int | Converts an integer provider to a float value. | Template:Table choice | Template:Table choice |
|
| length | Calculates the Minecraft:Euclidean distance between two points.
The amount of dimensions is the amount of Template:Nbt (For instance, 3 inputs is 3D distance). |
Template:Table choice | Template:Table choice |
|
| max | The maximum of multiple value providers | Template:Table choice | Template:Table choice |
|
| min | The minimum of multiple value providers | Template:Table choice | Template:Table choice |
|
| mod | Does Template:NbtTemplate:Nbt modulus Template:NbtTemplate:Nbt and then returns that value. | Template:Table choice | Template:Table choice |
|
| floor_mod | Does Template:NbtTemplate:Nbt modulus Template:NbtTemplate:Nbt and then returns that value. | Template:Table choice | Template:Table choice |
|
| environment_attribute | Fetches and provides the value of an Minecraft:environment attribute (that can be represented as a number).
This provider requires a context with an origin position set as long as the environment attribute can vary positionally. |
Template:Table choice | Template:Table choice |
|
| negate | Returns the negation of the input. | Template:Table choice | Template:Table choice |
|
| Number dispatcher | Returns the first case which fulfills its condition or the default if none do. | Template:Table choice | Template:Table choice |
|
| pow | Does Template:NbtTemplate:Nbt to the power of Template:NbtTemplate:Nbt and then returns that value. | Template:Table choice | Template:Table choice |
|
| mul | The product of the multiplication of multiple value providers | Template:Table choice | Template:Table choice |
|
| div | Divides Template:NbtTemplate:Nbt by Template:NbtTemplate:Nbt and then returns that value. | Template:Table choice | Template:Table choice |
|
| floor_div | Divides Template:NbtTemplate:Nbt by Template:NbtTemplate:Nbt and then returns that value. | Template:Table choice | Template:Table choice |
|
| round | Returns the rounded (towards the nearest integer, with ties rounding towards positive infinity) value of the input. | Template:Table choice | Template:Table choice |
|
| sin | Returns the sine of the input. | Template:Table choice | Template:Table choice |
|
| sqrt | Returns the square root of the input. | Template:Table choice | Template:Table choice |
|
| score | To query and use a Minecraft:scoreboard value. | Template:Table choice | Template:Table choice |
|
| storage | A value in Minecraft:command storage. | Template:Table choice | Template:Table choice |
|
| add | The sum of multiple value providers | Template:Table choice | Template:Table choice |
|
| truncate | Returns the truncated (rounded towards zero) value of the input. | Template:Table choice | Template:Table choice |
|
| uniform | A random number following a uniform distribution between two values. The values are inclusive, meaning the provided number can be either Template:Cd or Template:Cd, except if the provided number is a float, in which case it must be strictly less than Template:Cd. If Template:Cd ≤ Template:Cd, the provided number is Template:Cd. | Template:Table choice | Template:Table choice |
|
| weighted_list | Returns a value from a distribution of weighted number providers. | Template:Table choice | Template:Table choice |
|
History
Minecraft:de:Zahlenanbieter Minecraft:fr:Fournisseur de nombre Minecraft:ja:ナンバープロバイダー Minecraft:lzh:供值器 Minecraft:zh:数值提供器