Minecraft:Number provider: Difference between revisions
More actions
Sync: new page from Minecraft |
Sync: updated from Minecraft |
||
| Line 230: | Line 230: | ||
* '''environment_attribute''' — Fetches and provides the value of an environment attribute (that can be represented as a number). | * '''environment_attribute''' — Fetches and provides the value of an 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. | This provider requires a context with an origin position set as long as the environment attribute can vary positionally. | ||
** {{nbt|string|attribute}}: An [[Minecraft:environment attribute]] ID to fetch. | |||
</div> | </div> | ||
| Line 257: | Line 256: | ||
**** {{nbt|int|weight}}: A positive integer. Determines how often this weighted number provider is chosen out of all data in the distribution. Weighted number provider with higher weights are used more often. The chance of an weighted number provider being chosen is [this weighted number provider's weight ÷ total weight of all weighted number provider in the distribution]. | **** {{nbt|int|weight}}: A positive integer. Determines how often this weighted number provider is chosen out of all data in the distribution. Weighted number provider with higher weights are used more often. The chance of an weighted number provider being chosen is [this weighted number provider's weight ÷ total weight of all weighted number provider in the distribution]. | ||
</div> | </div> | ||
== History == | |||
{{section needed}} | |||
== Navigation == | == Navigation == | ||
{{Navbox Java Edition technical|datapack}} | {{Navbox Java Edition technical|datapack}} | ||
Revision as of 11:12, 14 July 2026
Template:For Template:Exclusive Template:Wip A number provider is a data structure used to provide a number, which can be simply a constant, a random number within a certain distribution, a number under a certain condition, etc. Number providers are used in Minecraft:loot tables, Minecraft:predicates, Minecraft:item modifiers, villager trade, Minecraft:trade sets, and the data component Template:DCLTemplate:Upcoming.
JSON definition
Number providers can be defined in Minecraft:data packs, as part of the directory structure below.
Use
In most uses of number provider, it is used as an Minecraft:NBT object, within a larger structure, and cannot be used as a registry . This includes all uses in Minecraft:loot tables, Minecraft:predicates, Minecraft:item modifiers, villager trade, and Minecraft:trade sets.
In Java 26.3, number provider Minecraft:registry can be used in the component Template:DCL to define how many layers are added when using Minecraft:composter. In this case, only number providers are accepted, not line definitions.
Vanila registries
There are 5 registry number providers used in vanilla data pack.
Template:File: Number providers used in the component Template:DCL default: Template:Collapse Template:Collapse Template:Collapse Template:Collapse Template:Collapse
See Template:Slink for a list of items that use such number providers in the component Template:Cd by default.
Format
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:NbtTemplate:Nbt: Constant number provider.
Or:
- Template:Nbt: The root tag. Shorthand for a uniform distribution.
- Template:NbtTemplate:NbtTemplate:Nbt: Number provider. The minimum value.
- Template:NbtTemplate:NbtTemplate:Nbt: Number provider. The maximum value.
Or:
- Template:Nbt: The root tag.
- Template:Nbt: The number provider type as a Minecraft:resource location. It can be Template:Cd,Template:CdTemplate:Upcoming, Template:CdTemplate:Upcoming, and Template:CdTemplate:Upcoming.
- Extra fields of the number provider, described below.
Number providers types
The possible values for Template:Nbt and associated extra contents:
- constant — A constant value.
- Template:NbtTemplate:Nbt: The exact value.
- uniform — A random number following a uniform distribution between two values (inclusive).
- Template:NbtTemplate:NbtTemplate:Nbt: Number provider. The minimum value.
- Template:NbtTemplate:NbtTemplate:Nbt: Number provider. The maximum value.
- binomial — A random number following a binomial distribution.
- Template:NbtTemplate:Nbt: Number provider. The amount of trials.
- Template:NbtTemplate:Nbt: Number provider. The probability of success on an individual trial.
- score — To query and use a scoreboard value.
- Template:Nbt: To choose which player name or entity UUID to query.
- Template:Nbt: Set to Template:Cd to manually specify a player name or UUID. Set to Template:Cd to use an entity from loot context.
- Template:Nbt: Included only if Template:Nbt is set to Template:Cd. Specifies the name of the player, or the entity's UUID (in hypenated hexadecimal format) whose score to query.
- Template:Nbt: Included only if Template:Nbt is set to Template:Cd. Specifies an entity from loot context to query the score of. Can be Template:Loot entity target
- Template:Nbt: The scoreboard objective to query on the selected player name or UUID.
- Template:Nbt: (Optional) Scale to multiply the score before returning it.
- Template:Nbt: To choose which player name or entity UUID to query.
- storage — A value in command storage.
- Template:Nbt: The Minecraft:resource location of the storage.
- Template:Nbt: The Minecraft:nbt path to the field in storage.
- enchantment_level — A value dependent on the level of the loot context enchantment
- Template:Nbt: Minecraft:level-based value calculating the value based on the enchantment.
- sum — The sum of multiple value providers
- Template:Nbt: List of number providers to sum.
- environment_attribute — Fetches and provides the value of an 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:Nbt: An Minecraft:environment attribute ID to fetch.
- number_dispatcherTemplate:Upcoming — Returns the first case which fulfills its condition or the default if none do.
- Template:Nbt: A list of cases in the order that the dispatcher will try to execute them.
- Template:Nbt: A single case:
- Template:Nbt: A Minecraft:predicate to be tested in this case.
- Template:NbtTemplate:NbtTemplate:Nbt: A number provider, which is executed if the Template:Nbt is fulfilled.
- Template:Nbt: A single case:
- Template:NbtTemplate:NbtTemplate:Nbt: (Optional. Default Template:Cd) A number provider, which runs if none of the conditions in Template:Nbt is fulfilled.
- Template:Nbt: A list of cases in the order that the dispatcher will try to execute them.
- conditionalTemplate:Upcoming — Returns the value from Template:NbtTemplate:NbtTemplate:Nbt if its Template:Nbt or Template:NbtTemplate:NbtTemplate:Nbt if not:
- Template:Nbt: A Minecraft:predicate to test which value will be returned.
- Template:NbtTemplate:NbtTemplate:Nbt: A number provider, which runs if the Template:Nbt is fulfilled.
- Template:NbtTemplate:NbtTemplate:Nbt: (Optional. Default Template:Cd) A number provider, which runs if the Template:Nbt is not fulfilled.
- weighted_listTemplate:Upcoming — Returns a value from a distribution of weighted number providers.
- Template:Nbt: Returns a value from a distribution of weighted number providers.
- Template:Nbt: A single weighted number provider:
- Template:NbtTemplate:NbtTemplate:Nbt: A number provider, which is executed if the weighted number provider is chosen.
- Template:Nbt: A positive integer. Determines how often this weighted number provider is chosen out of all data in the distribution. Weighted number provider with higher weights are used more often. The chance of an weighted number provider being chosen is [this weighted number provider's weight ÷ total weight of all weighted number provider in the distribution].
- Template:Nbt: A single weighted number provider:
- Template:Nbt: Returns a value from a distribution of weighted number providers.