Skip to content

Number Providers

petrolpark edited this page Mar 29, 2026 · 18 revisions

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, Entity Number Providers and Team 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).

This is a list of Number Providers (including Item Stack, Entity and Team Number Providers) added by the library. More comprehensive documentation of each can be found in the JavaDocs.


Conditional

Example:

{
    "type": "petrolpark:conditional",
    "condition": {
        "type": "minecraft:match_tool",
        "predicate": {
            "items": [
                "minecraft:diamond_sword"
            ]
        }
    },
    "pass": {
        "type": "minecraft:constant",
        "value": 0
    },
    "fail": 2,
}

Evaluates condition, which is a Loot Item Condition, and returns pass or fail accordingly, where pass and fail are both other Number Providers.

Context Entity Property

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_killer might be an Arrow Entity where killer was the Player that shot it)
  • killer_player - Loot Context Param: minecraft:last_damage_player. The last player to do damage to this entity.
  • A namespaced ID of a LootContextParam<Entity>, including any of those listed above (such as petrolpark:customer_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.

Tool Property

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).

Polynomial

Example:

{
    "type": "polynomial",
    "value": {
        "type": "minecraft:constant",
        "value": 2.7
    }
    "coefficients": [
        0.0,
        1.0,
        {
           "type": "minecraft:uniform",
           "min": 0.2
           "max": 0.7
        }
    ]
}

Returns the evaluation of a polynomial where value, a Number Provider, is the "x" and the entries of coefficients, a list of Number Providers, are the ordered coefficients including the constant.

Sigmoid

Example:

{
    "type": "petrolpark:sigmoid",
    "shallowness": 0.1,
    "midpoint": 0,
    "value": {
       "minecraft:uniform",
       "min": 0.0,
       "max": 8.0
    }
}

Returns 1 / (1 + exp((midpoint - value) / shallowness)), where all three fields are Number Providers. In this example the first two are using inline definitions.


Group Function Number Providers

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, such as in all the examples given here). Negative numbers work as expected.

Sum

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).

Product

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).

Mean

Example:

{
    "type": "petrolpark:mean",
    "values": [
        1.0,
        2.0
    ]
}

Returns the arithmetic mean of the return result of all Number Providers in the list (this example: 1.5).

Max/Min

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

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.

Flat

Example:

{
    "type": "petrolpark:flat",
    "value": {
        "type": "minecraft:constant",
        "value": 5.0
    }
}

Returns the value of the given Number Provider, ignoring the Item Stack entirely.

Count

Example:

{
    "type": "petrolpark:count"
}

No fields. Returns the count of the Item Stack.

Enchantment

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

Entity Number Providers generate numbers based off of properties of an Entity. Whenever they are used, a valid Entity will be available.

Flat

Example:

{
    "type": "petrolpark:flat",
    "value": {
        "type": "minecraft:constant",
        "value": 5.0
    }
}

Returns the value of the given Number Provider, ignoring the Entity entirely.

Attribute

Example:

{
    "type": "petrolpark:attribute",
    "attribute": "minecraft:movement_speed"
}

Returns the Entity's value of the given Attribute, or 0 if the Entity does not have that Attribute.

Experience Level

Example:

{
    "type": "petrolpark:experience_level"
}

No fields. Returns the Experience Level of the Entity if they are a Player, or 0 otherwise.

Equipment Property

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.


Team Number Providers

Team Number Providers generate numbers based on properties of a Team. Whenever they are used, a valid Team will be available in context.

Flat

Example:

{
    "type": "petrolpark:flat",
    "value": {
        "type": "minecraft:constant",
        "value": 5.0
    }
}

Returns the value of the given Number Provider, ignoring the Team entirely.

Member Count

Example:

{
    "type": "petrolpark:member_count"
}

No fields. Returns the number of members in the Team.

Member Reduction

Example:

{
    "type": "petrolpark:member_reduction",
    "value": {
        "type": "petrolpark:experience_level"
    },
    "function": "petrolpark:mean"
}

Applies an Entity Number Provider to all members of the team, then reduces them to a single value. value is the Entity Number Provider and function is the ID of a Group Function Number Provider to be applied to the values.

API Reference

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

Loot and Data

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

Recipes

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

Changelogs

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, 1.4.27, 1.4.28, 1.4.29, 1.4.30

Clone this wiki locally