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 26: Line 26:
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]].  


Number provider [[Minecraft:registry]] can be used in the components {{DCL|compostable}}, {{DCL|brewing}} and {{DCL|cooking_fuel}}. In this case, only number providers and constants are accepted, not inline definitions.
Number provider [[Minecraft:registry]] can be used in the components {{DCL|compostable}}, {{DCL|brewing_fuel}} and {{DCL|cooking_fuel}}. In this case, only number providers and constants are accepted, not inline definitions.


=== Vanilla registries ===
=== Vanilla context_float_provider registries ===


There are registry number providers used in vanilla [[Minecraft:data pack]].
These are registry context_float_providers used in the vanilla [[Minecraft:data pack]]
 
{{File|directory|brewing}}: Number providers used in the default component {{Data component link|brewing_fuel.speed_multiplier}}:{{JSON file|speed_default|1.0|desc=}}{{File|directory|cooking}}: Number providers used in the default component {{Data component link|cooking_fuel.speed_multiplier}}
{{JSON file|fast_speed_multiplier|2.0}}{{JSON file|normal_speed_multiplier|1.0}}{{JSON file/cooking|speed_default|"minecraft:cooking/normal_speed_multiplier"|"minecraft:cooking/fast_speed_multiplier"|desc=}}
 
=== Vanilla context_int_provider registries ===
 
These are registry context_int_providers used in the vanilla [[Minecraft:data pack]].
 
{{File|directory|brewing}}: Number providers used in the default component {{Data component link|brewing_fuel.uses}}:{{JSON file|uses_default|20|desc=}}


{{File|directory|compostable}}: Number providers used in the default component {{DCL|compostable}}:
{{File|directory|compostable}}: Number providers used in the default component {{DCL|compostable}}:
{{JSON file|always_add_one|1.0}}
{{JSON file|always_add_one|1}}
{{JSON file|low|{
{{JSON file|low_medium|{
   "type": "minecraft:number_dispatcher",
   "type": "minecraft:number_dispatcher",
   "cases": [
   "cases": [
     {
     {
       "condition": {
       "condition": {
         "block": "minecraft:composter",
         "type": "minecraft:match_block",
         "condition": "minecraft:block_state_property",
         "blocks": "minecraft:composter",
         "properties": {
         "state": {
           "level": "0"
           "level": "0"
         }
         }
       },
       },
       "number_provider": 1.0
       "value": 1
     }
     }
   ],
   ],
Line 52: Line 61:
     "distribution": [
     "distribution": [
       {
       {
         "data": 1.0,
         "data": 1,
         "weight": 30
         "weight": 50
       },
       },
       {
       {
         "data": 0.0,
         "data": 0,
         "weight": 70
         "weight": 50
       }
       }
     ]
     ]
   }
   }
}
<nowiki>}</nowiki>}}
}}
{{JSON file|low|{
{{JSON file|low_medium|{
   "type": "minecraft:number_dispatcher",
   "type": "minecraft:number_dispatcher",
   "cases": [
   "cases": [
     {
     {
       "condition": {
       "condition": {
         "block": "minecraft:composter",
         "type": "minecraft:match_block",
         "condition": "minecraft:block_state_property",
         "blocks": "minecraft:composter",
         "properties": {
         "state": {
           "level": "0"
           "level": "0"
         }
         }
       },
       },
       "number_provider": 1.0
       "value": 1
     }
     }
   ],
   ],
Line 81: Line 89:
     "distribution": [
     "distribution": [
       {
       {
         "data": 1.0,
         "data": 1,
         "weight": 50
         "weight": 30
       },
       },
       {
       {
         "data": 0.0,
         "data": 0,
         "weight": 50
         "weight": 70
       }
       }
     ]
     ]
   }
   }
}
<nowiki>}</nowiki>}}
}}
{{JSON file|medium_high|{
{{JSON file|medium|{
   "type": "minecraft:number_dispatcher",
   "type": "minecraft:number_dispatcher",
   "cases": [
   "cases": [
     {
     {
       "condition": {
       "condition": {
         "block": "minecraft:composter",
         "type": "minecraft:match_block",
         "condition": "minecraft:block_state_property",
         "blocks": "minecraft:composter",
         "properties": {
         "state": {
           "level": "0"
           "level": "0"
         }
         }
       },
       },
       "number_provider": 1.0
       "value": 1
     }
     }
   ],
   ],
Line 110: Line 117:
     "distribution": [
     "distribution": [
       {
       {
         "data": 1.0,
         "data": 1,
         "weight": 65
         "weight": 85
       },
       },
       {
       {
         "data": 0.0,
         "data": 0,
         "weight": 35
         "weight": 15
       }
       }
     ]
     ]
   }
   }
}
<nowiki>}</nowiki>}}{{JSON file|medium|{
}}
{{JSON file|medium_high|{
   "type": "minecraft:number_dispatcher",
   "type": "minecraft:number_dispatcher",
   "cases": [
   "cases": [
     {
     {
       "condition": {
       "condition": {
         "block": "minecraft:composter",
         "type": "minecraft:match_block",
         "condition": "minecraft:block_state_property",
         "blocks": "minecraft:composter",
         "properties": {
         "state": {
           "level": "0"
           "level": "0"
         }
         }
       },
       },
       "number_provider": 1.0
       "value": 1
     }
     }
   ],
   ],
Line 139: Line 144:
     "distribution": [
     "distribution": [
       {
       {
         "data": 1.0,
         "data": 1,
         "weight": 85
         "weight": 65
       },
       },
       {
       {
         "data": 0.0,
         "data": 0,
         "weight": 15
         "weight": 35
       }
       }
     ]
     ]
   }
   }
}
<nowiki>}</nowiki>}}{{File|directory|cooking}}:  Number providers used in the default component {{DCL|cooking_fuel.burn_time}}:{{JSON file|fast_burn_time_reduction_factor|2}}{{JSON file|normal_burn_time_reduction_factor|1}}{{JSON file|time_bamboo|{
}}
  "type": "minecraft:div",
 
  "left": 50,
{{File|directory|cooking}}:  Number providers used in the default component {{DCL|cooking_fuel.burn_time}}, except {{cd|speed_default}}:
  "right": {
{{JSON file/cooking|speed_default|1.0|2.0|desc=: Used in the default components {{cd|cooking_fuel.speed_multiplier}}}}
    "type": "minecraft:conditional",
{{JSON file/cooking|time_bamboo|50.0|25.0}}
    "condition": "minecraft:block/fast_cooking",
{{JSON file/cooking|time_blaze|2400.0|1200.0}}
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
{{JSON file/cooking|boats|1200.0|600.0}}
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
{{JSON file/cooking|coal|1600.0|8000.0}}
  }
{{JSON file/cooking|time_coal_block|16000.0|8000}}
<nowiki>}</nowiki>}}{{JSON file|time_blaze_rod|{
{{JSON file/cooking|time_dried_kelp_block|4001.0|2000.5}}
  "type": "minecraft:div",
{{JSON file/cooking|time_dry_plants|100.0|50.0}}
  "left": 2400,
{{JSON file/cooking|time_hanging_signs|800.0|400.0}}
  "right": {
{{JSON file/cooking|time_lava_bucket|20000.0|10000.0}}
    "type": "minecraft:conditional",
{{JSON file/cooking|time_roots|300.0|150.0}}
    "condition": "minecraft:block/fast_cooking",
{{JSON file/cooking|time_wood_blocks|300.0|150.0}}
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
{{JSON file/cooking|time_wood_items_extra_small|100.0|50.0}}
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
{{JSON file/cooking|time_wood_items_large|200.0|100.0}}
  }
{{JSON file/cooking|time_wood_items_small|300.0|150.0}}
<nowiki>}</nowiki>}}{{JSON file|time_boats|{
{{JSON file/cooking|time_wood_slabs|150.0|75.0}}
  "type": "minecraft:div",
{{JSON file/cooking|time_wool|100.0|50.0}}
  "left": 1200,
{{JSON file/cooking|time_wool_carpets|67.0|33.5}}
  "right": {
{{JSON file/cooking|time_wool_slabs|50.0|25.0}}
    "type": "minecraft:conditional",
{{File|directory|brewing}}:
    "condition": "minecraft:block/fast_cooking",
{{JSON file|speed_default|1.0|desc=: Used in the default component {{DCL|brewing_fuel.speed_multiplier}}}}
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
{{JSON file|uses_default|20.0|desc=: Used in the default component {{DCL|brewing_fuel.uses}}}}
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
 
  }
See {{Slink|Composter|Composting}} for a list of items that use such number providers in the component {{cd|compostable}} by default.
<nowiki>}</nowiki>}}{{JSON file|time_coal_block|{
  "type": "minecraft:div",
  "left": 16000,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_coal|{
  "type": "minecraft:div",
  "left": 1600,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_dried_kelp_block|{
  "type": "minecraft:div",
  "left": 4001,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_dry_plants|{
  "type": "minecraft:div",
  "left": 100,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_hanging_signs|{
  "type": "minecraft:div",
  "left": 800,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_lava_bucket|{
  "type": "minecraft:div",
  "left": 20000,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_roots|{
  "type": "minecraft:div",
  "left": 300,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_wood_blocks|{
  "type": "minecraft:div",
  "left": 300,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_wood_items_extra_small|{
  "type": "minecraft:div",
  "left": 100,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_wood_items_large|{
  "type": "minecraft:div",
  "left": 200,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_wood_items_small|{
  "type": "minecraft:div",
  "left": 300,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_wood_slabs|{
  "type": "minecraft:div",
  "left": 150,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}{{JSON file|time_wool_carpets|{
  "type": "minecraft:div",
  "left": 67,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}
{{JSON file|time_wool_slabs|{
  "type": "minecraft:div",
  "left": 50,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}
{{JSON file|time_wool|{
  "type": "minecraft:div",
  "left": 100,
  "right": {
    "type": "minecraft:conditional",
    "condition": "minecraft:block/fast_cooking",
    "on_false": "minecraft:cooking/normal_burn_time_reduction_factor",
    "on_true": "minecraft:cooking/fast_burn_time_reduction_factor"
  }
<nowiki>}</nowiki>}}See {{Slink|Composter|Composting}} for a list of items that use such number providers in the component {{cd|compostable}} by default.
<!--
<!--
=== [[Minecraft:Loot table]] ===
=== [[Minecraft:Loot table]] ===
Line 246: Line 388:
=== Number providers types ===
=== Number providers types ===


{{past|n|copy={{nbt|string}}{{nbt|float}}}}
{{past|n|copy={{nbt|string}}{{nbt|int}}}}
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.  
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.  


Line 266: Line 408:
* {{nbt|compound}}
* {{nbt|compound}}
** {{nbt|string|type}}: {{cd|abs}}
** {{nbt|string|type}}: {{cd|abs}}
** {{nbt|compound|input}}: The number to take the absolute value of
** {{Nbt|string}}{{nbt|compound|input}}: The number to take the absolute value of


===== Avg =====
===== Avg =====
Line 283: Line 425:
** {{nbt|string|type}}: {{cd|binomial}}  
** {{nbt|string|type}}: {{cd|binomial}}  
** {{nbt|string}}{{nbt|int}}{{nbt|compound|n}}: Number provider. The amount of trials.
** {{nbt|string}}{{nbt|int}}{{nbt|compound|n}}: Number provider. The amount of trials.
** {{past|n}}{{nbt|compound|p}}: Number provider. The probability of success on an individual trial.
** {{Nbt|string}}{{Nbt|float}}{{nbt|compound|p}}: Number provider. The probability of success on an individual trial.
</div>
</div>


===== Conditional =====
===== Conditional =====
Returns the value from {{nbt|string}}{{nbt|int}}{{nbt|compound|on_true}} if its {{nbt|compound|conditions}} or {{nbt|string}}{{nbt|int}}{{nbt|compound|on_false}} if not.
Returns the value from {{nbt|string}}{{nbt|int}}{{nbt|compound|on_true}} if its {{Nbt|string}}{{nbt|compound|condition}} is met or {{nbt|string}}{{nbt|int}}{{nbt|compound|on_false}} if not.


<div class="treeview" id="conditional" style="margin-block-end: 1em;">
<div class="treeview" id="conditional" style="margin-block-end: 1em;">
* {{nbt|compound}}
* {{nbt|compound}}
** {{nbt|string|type}}: {{cd|conditional}}
** {{nbt|string|type}}: {{cd|conditional}}
** {{nbt|compound|conditions}}: A '''[[Minecraft:predicate]]''' to test which value will be returned.
** {{Nbt|string}}{{nbt|compound|condition}}: A '''[[Minecraft:predicate]]''' to test which value will be returned.
** {{nbt|string}}{{nbt|int}}{{nbt|compound|on_true}}: A number provider, which runs if the {{nbt|compound|conditions}} is fulfilled.
** {{nbt|string}}{{nbt|int}}{{nbt|compound|on_true}}: A number provider, which runs if the {{Nbt|string}}{{nbt|compound|condition}} is met.
** {{nbt|string}}{{nbt|int}}{{nbt|compound|on_false}}: (Optional. Default {{cd|0}}) A number provider,  which runs if the {{nbt|compound|conditions}} is not fulfilled.
** {{nbt|string}}{{nbt|int}}{{nbt|compound|on_false}}: (Optional. Default {{cd|0}}) A number provider,  which runs if the {{Nbt|string}}{{nbt|compound|condition}} is not met.
</div>
</div>


===== Constant =====
===== Constant =====
A constant value.  Note that the value provided must be a float. If the number provider requires an integer, it will be converted later.
A constant value.  


<div class="treeview" id="constant" style="margin-block-end: 1em;">
<div class="treeview" id="constant" style="margin-block-end: 1em;">
Line 311: Line 453:
<div class="treeview" id="sum" style="margin-block-end: 1em;">
<div class="treeview" id="sum" style="margin-block-end: 1em;">
* {{nbt|compound}}
* {{nbt|compound}}
** {{nbt|string|type}}: {{cd|add}}  
** {{nbt|string|type}}: {{cd|sub}}
** {{nbt|string}}{{nbt|int}}{{nbt|compound|left}}: The left of the equation
** {{nbt|string}}{{nbt|int}}{{nbt|compound|left}}: The left of the equation
** {{nbt|string}}{{nbt|int}}{{nbt|compound|right}}: The right of the equation
** {{nbt|string}}{{nbt|int}}{{nbt|compound|right}}: The right of the equation<br />
</div>
</div>
<!--Outdated-->
===== Uniform =====
===== Uniform =====
A random number following a uniform distribution between two values. The values are inclusive, meaning the provided number can be either {{cd|min}} or {{cd|max}}, except if the provided number is a float, in which case it must be strictly less than {{cd|max}}. If {{cd|max}} &le; {{cd|min}}, the provided number is {{cd|min}}.
A random number following a uniform distribution between two values. The values are inclusive, meaning the provided number can be either {{cd|min}} or {{cd|max}}, except if the provided number is a float, in which case it must be strictly less than {{cd|max}}. If {{cd|max}} &le; {{cd|min}}, the provided number is {{cd|min}}.
Line 329: Line 468:


===== Score =====
===== Score =====
To query and use a [[Minecraft:scoreboard]] value. Return {{cd|0.0}} if the scoreboard cannot be calculated.
To query and use a [[Minecraft:scoreboard]] value.
<div class="treeview" id="score" style="margin-block-end: 1em;">
<div class="treeview" id="score" style="margin-block-end: 1em;">
* {{nbt|compound}}
* {{nbt|compound}}
** {{nbt|string|type}}: {{cd|score}}
** {{nbt|string|type}}: {{cd|score}}
** {{nbt|compound|target}}: To choose which player name or entity UUID to query.
** {{Nbt|string}}{{nbt|compound|target}}: To choose which player name or entity UUID to query. (Must be an object unless specifying an entity from loot context using the same options as {{nbt|string|target}})
*** {{nbt|string|type}}: Set to {{cd|fixed}} to manually specify a player name or UUID. Set to {{cd|context}} to use an entity from loot context.
*** {{nbt|string|type}}: Set to {{cd|fixed}} to manually specify a player name or UUID. Set to {{cd|context}} to use an entity from loot context.
*** {{nbt|string|name}}: Included only if {{nbt|string|type}} is set to {{cd|fixed}}. Specifies the name of the player, or the entity's [[Minecraft:Universally unique identifier|UUID]] <small>(in hypenated hexadecimal format)</small> whose score to query.
*** {{nbt|string|name}}: Included only if {{nbt|string|type}} is set to {{cd|fixed}}. Specifies the name of the player, or the entity's [[Minecraft:Universally unique identifier|UUID]] <small>(in hypenated hexadecimal format)</small> whose score to query.
*** {{nbt|string|target}}: Included only if {{nbt|string|type}} is set to {{cd|context}}. Specifies an entity from [[#Loot context types|loot context]] to query the score of. Can be {{Loot entity target}}
*** {{nbt|string|target}}: Included only if {{nbt|string|type}} is set to {{cd|context}}. Specifies an entity from [[#Loot context types|loot context]] to query the score of. Can be {{Loot entity target}}
** {{nbt|string|score}}: The scoreboard objective to query on the selected player name or UUID.
** {{nbt|string|score}}: The scoreboard objective to query on the selected player name or UUID.
** {{nbt|float|scale}}: (Optional. Default {{cd|1.0}}) Scale to multiply the score before returning it.
** {{Past|n}}{{Nbt|compound|fallback}}: (Optional. Default {{Code|0}}) The value to return if {{nbt|string|target}} or {{nbt|string|score}} do not exist.
</div>
</div>


Line 349: Line 488:
** {{nbt|string|storage}}: The [[Minecraft:resource location]] of the storage.
** {{nbt|string|storage}}: The [[Minecraft:resource location]] of the storage.
** {{nbt|string|path}}: The [[Minecraft:nbt path]] to the field in storage.
** {{nbt|string|path}}: The [[Minecraft:nbt path]] to the field in storage.
** {{Past|n}}{{Nbt|compound|fallback}}: (Optional. Default {{Code|0}}) The value to return if {{nbt|string|storage}} or {{nbt|string|path}} do not exist.
</div>
</div>


Line 378: Line 518:
</div>
</div>


===== Minimum =====
===== Min =====
The minimum of multiple value providers
The minimum of multiple value providers


<div class="treeview" id="minimum" style="margin-block-end: 1em;">
<div class="treeview" id="minimum" style="margin-block-end: 1em;">
* {{nbt|compound}}
* {{nbt|compound}}
** {{nbt|string|type}}: {{cd|minimum}}  
** {{nbt|string|type}}: {{cd|min}}
** {{nbt|list|operands}}: List of number providers to compare.
** {{nbt|list|inputs}}: List of number providers to compare.
</div>
</div>


===== Maximum =====
===== Max =====
The maximum of multiple value providers
The maximum of multiple value providers


<div class="treeview" id="maximum" style="margin-block-end: 1em;">
<div class="treeview" id="maximum" style="margin-block-end: 1em;">
* {{nbt|compound}}
* {{nbt|compound}}
** {{nbt|string|type}}: {{cd|maximum}}  
** {{nbt|string|type}}: {{cd|max}}
** {{nbt|list|operands}}: List of number providers to compare.
** {{nbt|list|inputs}}: List of number providers to compare.
</div>
</div>


Line 424: Line 564:
** {{nbt|list|cases}}: A list of cases in the order that the dispatcher will try to execute them.
** {{nbt|list|cases}}: A list of cases in the order that the dispatcher will try to execute them.
*** {{nbt|compound}}: A single case:
*** {{nbt|compound}}: A single case:
**** {{nbt|compound|condition}}: A '''[[Minecraft:predicate]]''' to be tested in this case.
**** {{Nbt|string}}{{nbt|compound|condition}}: A '''[[Minecraft:predicate]]''' to be tested in this case.
**** {{past|n}}{{nbt|compound|number_provider}}: A number provider, which is executed if the {{nbt|compound|condition}} is fulfilled.
**** {{past|n}}{{nbt|compound|value}}: A number provider, which is executed if the {{Nbt|string}}{{nbt|compound|condition}} is met.
** {{past|n}}{{nbt|compound|default}}: (Optional. Default {{cd|0.0}}) A number provider, which runs if none of the conditions in {{nbt|list|cases}} is fulfilled.
** {{past|n}}{{nbt|compound|default}}: (Optional. Default {{cd|0}}) A number provider, which runs if none of the conditions in {{nbt|list|cases}} are met.
</div>
</div>



Revision as of 11:12, 26 September 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

A number provider can be of two types: a Template:Cd or a Template:Cd. Number providers can be defined in Minecraft:data packs, as part of the directory structure below, depending on if they are a Template:Cd or a Template:Cd.

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

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.

By default, the integer is the float converted to the nearest integer (Template:Cd). 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

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

Template:Navbox Java Edition technical

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