Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

since

1.0

Index

Functions

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

    since

    1.2

    since

    4.0 you can use full loot table dir in tableName parameter, same as in the rest of the module's methods

    Parameters

    • tableName: any_string

      path to the loot table, can be shortened like in createLootTableModifier, and full like loot_tables/path/name.json

    • cb: OnDropCallback

      function to be called after the items list is chosen by vanilla

    • Optional priority: number

      callback priority, the more it is, the earlier than other callbacks your callback will be called, default is 0

    Returns void

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

    since

    1.2

    Returns LootEntry

    LootEntry object to describe the item

  • Adds a new modifier to the loot table with given name.

    since

    1.0

    since

    4.0 you can use full loot table dir in tableName parameter, same as in the rest of the module's methods

    Parameters

    • tableName: any_string

      path to the loot table, relative to <behavior_pack>/loot_tables/ and without .json

    Returns LootModifier

    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.

    since

    3.0

    Parameters

    Returns void

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

    since

    3.0

    Parameters

    Returns void

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

    since

    4.0

    Parameters

    • conditionName: any_string

      name of the condition that will have to be put in "condition" param of condition's JSON object.

    • callback: CustomLootConditionCallback

      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

    Returns void

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

    since

    4.0

    Parameters

    • conditionName: any_string

      name of the condition that will have to be put in "condition" param of condition's JSON object.

    • callback: CustomLootConditionCallbackJS

      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

    Returns void

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

    since

    3.0

    Parameters

    • functionName: any_string

      name of the function that will have to be put in "function" param of function's JSON object.

    • callback: CustomLootFunctionCallback

      function to be called on the item that owns this function, it provides you with all needed parameters.

    Returns void

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

    since

    3.0

    Parameters

    • functionName: any_string

      name of the function that will have to be put in "function" param of function's JSON object.

    • callback: CustomLootFunctionCallbackJS

      function to be called on the item that owns this function, it provides you with all needed parameters.

    Returns void

  • Runs the loot pool condition for your internal purposes

    since

    4.0

    Parameters

    Returns boolean

    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

    since

    4.0

    Parameters

    • json: { condition: any_string }

      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.

    • context: LootTableContext

      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.

    Returns boolean

    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