-
Notifications
You must be signed in to change notification settings - Fork 17
Number Providers
Vanilla Minecraft has an API that provides Number Providers, which are used in Loot Tables, Advancements and other data-driven systems to get numbers. This library provides a few new Number Providers, as well as expanding the system with Item Stack Number Providers and Entity Number Providers, which are Number Providers parameterized with an Item Stack or Entity respectively. They are a numerical equivalent of Predicates (also called Loot Conditions).
Example:
{
"type": "petrolpark:context_entity_property",
"target": "this",
"value": {
"type": "petrolpark:experience_level"
}
}Targets an entity available in the Loot Context and returns some value from them. target can take these values:
-
this- Loot Context Param:minecraft:this_entity. The entity which died (if this is a mob loot table), or the player in most loot tables. -
killer- Loot Context Param:minecraft:killer_entity. The entity which killed the entity that died (if this is a mob loot table) -
direct_killer- Loot Context Param:minecraft:direct_killer_entity. The direct entity that killed this entity (for example,direct_killermight be an Arrow Entity wherekillerwas the Player that shot it) -
killer_player- Loot Context Param:minecraft:last_damage_player. The last player to do damage to this entity. Make sure you consult the Minecraft code to know which Loot Parameter corresponds to which entity in each circumstance.
value must be an Entity Number Provider.
Example:
{
"type": "petrolpark:tool_property",
"value": {
"type": "petrolpark:count"
}
}Gets the tool Item Stack available in the Loot Context and returns some value from them. value must be an Item Stack Number Provider. Note that the minecraft:tool Loot Context Param is not available in some Loot Contexts (such as when an entity is killed, for which you might want to use a Context Entity Property Provider with an Equipment Property Provider to get the mainhand weapon).
This subset of Number Providers perform operations on lists of other Number Providers. They all have a field values which expects an array of other Number Providers (inline constant Number Providers are acceptable). Negative numbers work as expected.
Example:
{
"type": "petrolpark:sum",
"values": [
1.0,
2.0
]
}Returns the sum of the return result of all Number Providers in the list (this example: 3.0).
Example:
{
"type": "petrolpark:product",
"values": [
1.0,
2.0
]
}Returns the product of the return result of all Number Providers in the list (this example: 2.0).
Example:
{
"type": "petrolpark:max",
"values": [
1.0,
2.0
]
}Returns the maximum (or minimum, with "type": "petrolpark:min") of the return result of all Number Providers in the list (this example: 2.0).
Item Stack Number Providers generate numbers based on properties of the Item Stack. Whenever they are used, a valid Item Stack will be available in context, but be aware that this may be empty.
Example:
{
"type": "petrolpark:count"
}No fields. Returns the count of the Item Stack.
Example:
{
"type": "petrolpark:enchantment_level",
"enchantment": "minecraft:sharpness"
}Returns the level of the given Enchantment on the Item Stack. If the Item Stack does not have that Enchantment it will give 0. The field enchantment must be the valid ID of an Enchantment.
Entity Number Providers generate numbers based off of properties of an Entity. Whenever they are used, a valid Entity will be available in context.
Example:
{
"type": "petrolpark:experience_level"
}No fields. Returns the Experience Level of the Entity if they are a Player, or 0 otherwise.
Example:
{
"type": "petrolpark:equipment_property",
"slot": "mainhand",
"value": {
"type": "petrolpark:count"
}
}Gets the Item in a slot of an Entity (if they have one) and gets some value from it. slot can be any of mainhand, offhand, feet, legs, chest or head. value must be an Item Stack Number Provider.
Flags than can be applied to Item Stacks and other objects and will propagate through crafting
Timers that can be attached to Item Stacks to modify them after a given time, no matter what Inventory they are in
A way for mods to detect groupings of Players and store information on these groupings
Manipulation of Loot Table randomness and other RNG to give desired Items
Additional inventory and hotbar slots for the Player
Blocks and Items that have variants craftable from any mod's wood
Data-driven modifications to existing Loot Tables with greater versatility than NeoForge Global Loot Modifiers
Data-driven changes to the world (give Items, XP, unlock Villager Trades)
Levelable "Shops" shared between Teams giving Rewards for randomly-generated Item requests
Additional implementations of vanilla's Number Providers used in Loot Tables and Advancements
Extension of NeoForge Ingredients to include descriptions and Loot Table forcing
Work with automatically-detected "compression" Recipes (e.g. Nuggets <-> Ingots <-> Blocks)
Recycling (page under construction)
Balanced and versatile "uncrafting" API
Gating Recipes for vanilla and modded Items behind Item unlocks
1.3.1, 1.3.2, 1.3.3, 1.3.4
1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 1.4.14, 1.4.15, 1.4.16, 1.4.17, 1.4.18, 1.4.19, 1.4.20, 1.4.21, 1.4.22, 1.4.23, 1.4.24, 1.4.25, 1.4.26