Options
All
  • Public
  • Public/Protected
  • All
Menu

Object returned by LootModule.createLootTableModifier method, used to modify a specific loot table in different ways, like adding your custom JSON, adding exactly items or registering a callback called after the modifications listed above, to modify the resulting JSON object one more time, having access to all of its content.

The most weighty feature of LootModifier is a class system, that repeats Minecraft loot tables JSON format (a loot table consists of pools, each pool has its conditions, tiers and entries, etc.)

Here is an example of using this system - repeating vanilla zombie loot table with it:

KEX.LootModule.createLootTableModifier("entities/zombie")
.createNewPool()
.addEntry()
.describeItem("minecraft", "rotten_flesh")
.setWeight(1)
.setCount(0, 2)
.beginFunctions()
.addLootingEnchantFunction(0, 1)
.endFunctions()
.endEntry()
.endPool()
.createNewPool()
.addEntry()
.describeItem("minecraft", "iron_ingot")
.setWeight(1)
.setCount(1)
.endEntry()
.addEntry()
.describeItem("minecraft", "carrot")
.setWeight(1)
.setCount(1)
.endEntry()
.beginConditions()
.addKilledByPlayerCondition()
.addRandomChanceWithLootingCondition(0.025, 0.01)
.endConditions()
.endPool();
since

1.0

Hierarchy

  • LootModifier

Index

Methods

  • Adds new item by given string namespace and identifier to the loot table.

    since

    1.0

    Parameters

    • namespace: any_string
    • identifier: any_string
    • count: number | MinMax

      item count, can be fixed integer or object with minimum and maximum possible values

    • data: number
    • chance: number

      chance for this item to be dropped, value between 0.0 (0%) and 1.0 (100%)

    • Optional rolls: number | MinMax

      number of rolls, defaults to 1 This method is actually a shortcut, which looks like this:

      LootPool pool = this.createNewPool(rolls)
      .addEntry()
      .describeItem(namespace, identifier)
      .setCount(count)
      .setData(data)
      .endEntry();
      if(chance < 1.0f)
      {
      pool.beginConditions()
      .addRandomChanceCondition(chance)
      .endConditions();
      }
      return this;

    Returns LootModifier

    reference to itself to be used in sequential calls

  • Adds new item by given numeric ID to the loot table.

    since

    1.0

    Parameters

    • id: number
    • count: number | MinMax

      item count, can be fixed integer or object with minimum and maximum possible values

    • data: number
    • chance: number

      chance for this item to be dropped, value between 0.0 (0%) and 1.0 (100%)

    • Optional rolls: number | MinMax

      number of rolls, defaults to 1

      • Roll is an action of generating a list of randomly chosen items from the loot pool, after all the rolls the lists are merged and dropped from the mob or put into the chest.

      This method is actually a shortcut, which looks like this:

      LootPool pool = this.createNewPool(rolls)
      .addEntry()
      .describeItem(id)
      .setCount(count)
      .setData(data)
      .endEntry();
      if(chance < 1.0f)
      {
      pool.beginConditions()
      .addRandomChanceCondition(chance)
      .endConditions();
      }
      return this;

    Returns LootModifier

    reference to itself to be used in sequential calls

  • Adds a callback called right after common modifications which you can use to modify the resulting loot table JSON object one more time, having access to all of its content.

    since

    1.2

    Parameters

    • cb: JSModifyCallback

      function that provides you with loot table JSON object represented as a JS object, which you can modify how you wish

    • Optional priority: number

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

    Returns LootModifier

    reference to itself to be used in sequential calls

  • Adds a callback called right after common modifications which you can use to modify the resulting loot table JSON object one more time, having access to all of its content.

    since

    1.2

    Parameters

    • cb: JSONModifyCallback

      function that provides you with loot table JSON object represented as an org.json.JSONObject instance, which you can modify how you wish

    • Optional priority: number

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

    Returns LootModifier

    reference to itself to be used in sequential calls

  • Adds a callback called after common modifications and modify callbacks which you can use to read the resulting loot table JSON object after all modifications, in order to, for example, save some data from it for your personal needs

    since

    1.2

    Parameters

    • cb: JSONModifyCallback

      function that provides you with loot table JSON object represented as an org.json.JSONObject instance. Modifying it doesn't make any effect, because every callback is called using a copy of the loot table JSON object.

    Returns LootModifier

    reference to itself to be used in sequential calls

  • Adds a callback called after common modifications and modify callbacks which you can use to read the resulting loot table JSON object after all modifications, in order to, for example, save some data from it for your personal needs

    since

    1.2

    Parameters

    • cb: JSModifyCallback

      function that provides you with loot table JSON object represented as a JS object. Modifying it doesn't make any effect, because every callback is called using a copy of the loot table JSON object.

    Returns LootModifier

    reference to itself to be used in sequential calls

  • createNewPool(): LootPool
  • createNewPool(rolls: number): LootPool
  • createNewPool(minRolls: number, maxRolls: number): LootPool
  • Adds new loot pool to the loot table with 1 roll

    • Roll is an action of generating a list of randomly chosen items from the loot pool, after all the rolls the lists are merged and dropped from the mob or put into the chest.
    since

    1.0

    Returns LootPool

    LootPool object to describe the created pool

  • Adds new loot pool to the loot table with given number of rolls

    • Roll is an action of generating a list of randomly chosen items from the loot pool, after all the rolls the lists are merged and dropped from the mob or put into the chest.
    since

    1.0

    Parameters

    • rolls: number

    Returns LootPool

    LootPool object to describe the created pool

  • Adds new loot pool to the loot table with the number of rolls that is chosen randomly every time between given minimum and maximum value.

    • Roll is an action of generating a list of randomly chosen items from the loot pool, after all the rolls the lists are merged and dropped from the mob or put into the chest.
    since

    1.0

    Parameters

    • minRolls: number
    • maxRolls: number

    Returns LootPool

    LootPool object to describe the created pool

  • isLocked(): boolean
  • After calling this method, all the further modifications applied to the following LootModifier (basically all of its methods) will be ignored. Worth noticing that the LootModifier on which the lock method was called, cannot be unlocked.

    since

    4.0

    Returns LootModifier

    reference to itself to be used in sequential calls

  • You can store loot table modification data as a JSON file of Minecraft loot table format, somewhere in your mod's directory. Here you specify the absolute path to this JSON file and all its contents will be added to the following LootModifier.

    since

    1.0

    Parameters

    Returns LootModifier

    reference to itself to be used in sequential calls

  • Here you can specify loot table modification data represented as a JS object of Minecraft loot table format, and all its contents will be added to the following LootModifier.

    since

    1.0

    Parameters

    Returns LootModifier

    reference to itself to be used in sequential calls

Generated using TypeDoc