Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Number provider: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Sync: updated from Minecraft
SyncBot (talk | contribs)
Sync: updated from Minecraft
Line 6: Line 6:
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 table]]s, [[Minecraft:predicate]]s, [[Minecraft:item modifiers]], [[Minecraft:Villager_trade_definition|villager trade]], [[Minecraft:trade sets]], [[Minecraft:Commands/compute|the compute command]], and in data components ({{DCL|compostable}}, {{DCL|cooking_fuel}}, and {{DCL|brewing_fuel}}).
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 table]]s, [[Minecraft:predicate]]s, [[Minecraft:item modifiers]], [[Minecraft:Villager_trade_definition|villager trade]], [[Minecraft:trade sets]], [[Minecraft:Commands/compute|the compute command]], and in data components ({{DCL|compostable}}, {{DCL|cooking_fuel}}, and {{DCL|brewing_fuel}}).


== JSON definition ==  
== JSON definition ==
 
A number provider can be of two types: a {{cd|minecraft:context_float_provider}} or a {{cd|minecraft:context_int_provider}}. Number providers can be defined in [[Minecraft:data pack]]s, as part of the directory structure below, depending on if they are a {{cd|minecraft:context_float_provider}} or a {{cd|minecraft:context_int_provider}}.
 
<div class="treeview">
<div class="treeview">
*{{File|archive|''data pack name''.zip}} or {{File|directory|''data pack name''}}
*{{File|archive|''data pack name''.zip}} or {{File|directory|''data pack name''}}
Line 22: Line 19:
</div>
</div>


== Use ==
== Use ==  


Number providers are used in [[Minecraft:loot table]]s, [[Minecraft:predicate]]s, [[Minecraft:item modifiers]], [[Minecraft:Villager_trade_definition|villager trade]], and [[Minecraft:trade sets]].  
Number providers are used in [[Minecraft:loot table]]s, [[Minecraft:predicate]]s, [[Minecraft:item modifiers]], [[Minecraft:Villager_trade_definition|villager trade]], and [[Minecraft:trade sets]].  
Line 361: Line 358:


== Format ==
== Format ==
{{Update|section=Integer Number Providers|reason=[[Minecraft:Java Edition 26.3 Pre-Release 1]]}}{{Incomplete section|Floating Point Number Providers}}
A a number provider can be an {{nbt|int}} or {{nbt|float}}. They can either be defined as a constant value or as an object.  
A a number provider can be an {{nbt|int}} or {{nbt|float}}. They can either be defined as a constant value or as an object.  


Line 397: Line 395:
Each type has two ways to get a number: an [[Minecraft:integer]] or a [[Minecraft:float]].  
Each type has two ways to get a number: an [[Minecraft:integer]] or a [[Minecraft:float]].  


By default, the integer is the float converted to the nearest integer ({{cd|floor(x+0.5)}}). Numbers less than or equal to -2,147,483,648.0 are returned as -2,147,483,648, numbers greater than or equal to 2,147,483,648.0 are returned as 2,147,483,647. However, in many types, there is a specific method for gat a integers.
<!--By default, the integer is the float converted to the nearest integer ({{cd|floor(x+0.5)}}). Numbers less than or equal to -2,147,483,648.0 are returned as -2,147,483,648, numbers greater than or equal to 2,147,483,648.0 are returned as 2,147,483,647. However, in many types, there is a specific method for gat a integers.-->


==== Integer Providers ====
==== Integer Providers ====
Line 614: Line 612:


== Navigation ==
== Navigation ==
{{Navbox Java Edition technical|datapack}}
[[Minecraft:de:Zahlenanbieter]]
[[Minecraft:de:Zahlenanbieter]]
[[Minecraft:fr:Fournisseur de nombre]]
[[Minecraft:fr:Fournisseur de nombre]]

Revision as of 11:12, 2 October 2026

Template:For Template:Exclusive Template:Update 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, the compute command, and in data components (Template:DCL, Template:DCL, and Template:DCL).

JSON definition

Use

Number providers are used in Minecraft:loot tables, Minecraft:predicates, Minecraft:item modifiers, villager trade, and Minecraft:trade sets.

Number provider Minecraft:registry can be used in the components Template:DCL, Template:DCL and Template:DCL. In this case, only number providers and constants are accepted, not inline definitions.

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.

Or:

Or:

Or:

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.


Integer Providers

These can be used in Template:Cd

Abs

Returns the absolute value of the input.

Avg

The mean of all inputs. Note this rounds towards 0.

Binomial

A random number following a binomial distribution. The returned float has the same value as the int.

Conditional

Returns the value from Template:NbtTemplate:NbtTemplate:Nbt if its Template:NbtTemplate:Nbt is met or Template:NbtTemplate:NbtTemplate:Nbt if not.

Constant

A constant value.

Sub

Subtracts Template:NbtTemplate:NbtTemplate:Nbt from Template:NbtTemplate:NbtTemplate:Nbt and then returns that value

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.

Score

To query and use a Minecraft:scoreboard value.

Storage

A value in Minecraft:command storage.

Enchantment level

A value dependent on the level of the Minecraft:loot context enchantment.

Add

The sum of multiple value providers

Mul

The product of the multiplication of multiple value providers

Min

The minimum of multiple value providers

Max

The maximum of multiple value providers

Average

The average of multiple value providers

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.

Number dispatcher

Returns the first case which fulfills its condition or the default if none do.

Weighted list

Returns a value from a distribution of weighted number providers.

  • Template:Nbt
    • Template:Nbt: Template:Cd
    • Template:Nbt: Returns a value from a distribution of weighted number providers.
      • Template:Nbt: A single weighted number provider:
        • Template:PastTemplate: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].

History

Template:HistoryTable

Navigation

Minecraft:de:Zahlenanbieter Minecraft:fr:Fournisseur de nombre Minecraft:ja:ナンバープロバイダー Minecraft:lzh:供值器 Minecraft:zh:数值提供器