Adds a function that will be called right after the list of randomly chosen items from a loot table is created. The function has access to this list and to the loot call circumstances object.
path to the loot table, can be shortened like in createLootTableModifier, and full like loot_tables/path/name.json
function to be called after the items list is chosen by vanilla
callback priority, the more it is, the earlier than other callbacks your callback will be called, default is 0
Adds new item that can be dropped when bartering with piglins.
Actually it's a wrapper over createLootTableModifier,
but it's made differently to prevent bugs in bartering logics,
because piglin_barter
loot table has unusual structure:
only one pool and one list of items, and as createLootTableModifier
creates new pools, using it here may cause incorrect work.
Here is an example:
KEX.LootModule.addPiglinBarteringItem()
.describeItem(VanillaItemID.netherite_ingot)
.setCount(32, 64)
.setWeight(1000);
It's important to notice, that weight
is mandatory here, otherwise the item
will be ignored during the modification. In vanilla piglin bartering list,
values from 1 (netherite hoe) to 40 (gravel, leather, nether bricks and other cheap stuff) are used.
Based on this, you can understand which weight
values you should use.
LootEntry object to describe the item
empty LootConditions to use in loot entry function description
Adds a new modifier to the loot table with given name.
path to the loot table, relative to <behavior_pack>/loot_tables/
and without .json
LootModifier object containing loads of functions to modify the loot table how you wish
Fills vanilla container on given coords, with items randomly chosen from given loot table. Currently only chest, hopper, dispenser, dropper and barrel are supported, it'll be improved in future.
BlockSource object of the dimension where the block is located
path to the loot table, can be shortened like in createLootTableModifier, and full like loot_tables/path/name.json
entity that will be used as ThisEntity
in LootTableContext object created internally.
Forces the given loot table to be loaded as soon as the player enters the world.
As an element of optimization, the loot tables in Minecraft are not loaded all together at the same time. A single loot table is deserialized from its JSON file when a mob with this loot table is killed or a chest with it is opened for the first time in the current session.
This creates inconveniences for the developers that need the data from a loot table immediately (for example, for a RecipeViewer addon using LootModifier's post-modify callbacks).
This method is a solution. It forces loot table's deserialization in LevelDisplayed
callback.
path to the loot table, can be shortened like in createLootTableModifier, and full like loot_tables/path/name.json
Creates the list of randomly chosen items from given loot table using given circumstances object, and returns it. OnDropCallbacks are also triggered when you use this method.
path to the loot table, can be shortened like in createLootTableModifier, and full like loot_tables/path/name.json
LootTableContext object to add circumstances to the loot event.
You have to create a LootTableContext.Builder and then call its method create
, that returns the LootTableContext.
the resulting java.util.List of items
Adds new loot pool condition that you can add to "conditions"
array in your loot table's JSON,
and specify its behavior without any limits in your code.
name of the condition that will have to be put in "condition"
param of condition's JSON object.
function to be called on the loot pool that owns this condition and must return true or false, depending on whether the condition was met or not
Adds new loot pool condition that you can add to "conditions"
array in your loot table's JSON,
and specify its behavior without any limits in your code.
Same as registerCustomLootCondition, but the function's first parameter is a JS object of condition's JSON description instead of org.json.JSONObject.
name of the condition that will have to be put in "condition"
param of condition's JSON object.
function to be called on the loot pool that owns this condition and must return true or false, depending on whether the condition was met or not
Adds new loot entry function that you can add to "functions"
array in your loot table's JSON,
and specify its behavior without any limits in your code.
name of the function that will have to be put in "function"
param of function's JSON object.
function to be called on the item that owns this function, it provides you with all needed parameters.
Adds new loot entry function that you can add to "functions"
array in your loot table's JSON,
and specify its behavior without any limits in your code.
Same as registerCustomLootFunction, but the function's first parameter is a JS object of function's JSON description instead of org.json.JSONObject.
name of the function that will have to be put in "function"
param of function's JSON object.
function to be called on the item that owns this function, it provides you with all needed parameters.
Runs the loot pool condition for your internal purposes
JSON description of the condition represented as an org.json.JSONObject.
You must have the "condition"
field in it with the string identifier of the condition,
in order for the method to determine and validate it.
LootTableContext object with the circumstances of the loot event. You can use a LootTableContext object provided to you by one of LootModule callbacks, or create and customize it yourself using LootTableContext.Builder.
true or false depending on whether the condition was met or not. Returns false if the condition's JSON description is invalid.
Runs the loot pool condition for your internal purposes
JSON description of the condition represented as a JS object.
You must have the "condition"
field in it with the string identifier of the condition,
in order for the method to determine and validate it.
LootTableContext object with the circumstances of the loot event. You can use a LootTableContext object provided to you by one of LootModule callbacks, or create and customize it yourself using LootTableContext.Builder.
true or false depending on whether the condition was met or not. Returns false if the condition's JSON description is invalid.
Generated using TypeDoc
A module that adds a wide set of features with loot tables, for example: modifying vanilla loot tables (so that loot in dungeon chests and drops from killed mobs changes), filling containers like chests and barrels with a loot table, getting list of randomly chosen items from a loot table etc.
1.0