LootPool¶
- loottweaker.vanilla.loot.LootPool¶
Each instance of this type represents a specific pool of a loot table.
Condition and function formatting¶
Conditions and functions should be supplied to methods as JSON format maps/ or Conditions/Functions. Do not supply the conditions/functions as part of a parent tag. When using a map to supply conditions or functions, it is recommended that you surround the keys with double quotes(“), as otherwise any keys which are ZenScript keywords(e.g function) will cause issues.
Recommended
[
{
"count":
{
"min": 0.0,
"max": 2.0
},
"function": "minecraft:set_count"
}
]
Not Recommended
[
{
count:
{
min: 0.0,
max: 2.0
},
function: "minecraft:set_count"
}
]
Converting JSON format maps to LootCondition/LootFunction¶
As of 0.3.0 JSON format maps are automatically converted to Conditions/Functions as needed, so any LootFunction/LootCondition parameter will accept a JSON format map.
Methods¶
See here for an explanation of the method documentation format used on this page.
- addConditions(LootCondition[] conditions) ¶
Adds conditions to the pool.
- Parameters:
conditions - an array of instances of LootCondition to add. JSON format maps are automatically converted.
import loottweaker.vanilla.loot.Conditions; // somePool is a LootPool created elsewhere somePool.addConditions([ {"condition": "killed_by_player"}, Conditions.randomChance(0.5) ]);
- removeEntry(String entryName) ¶
Removes the entry with a matching
entryName
tag from the pool- Parameters:
entryName - the unique name of the target entry
- Errors:
if no entry with the specified name exists in the pool
// somePool is a LootPool created elsewhere somePool.removeEntry("someEntryName");
- addItemEntry(IItemStack iStack, int weight, int quality, LootFunction[] functions, LootCondition[] conditions, String name) ¶
Adds a new
item
type entry to the pool.- Parameters:
iStack - the item stack the entry should produce. LootTweaker will autogenerate set_nbt, set_damage/set_data and set_count functions based on this stack, unless
functions
contains a function of the same type.weight - the main component that determines the generation chance. Higher weights make entries generate more often.
quality - determines how much the Luck attribute affects the generation chance. Higher qualities make the luck attribute affect the generation chance more.
functions - functions that affect the stack(s) generated by the entry. JSON format maps are automatically converted.
conditions - conditions for the generation of the entry. JSON format maps are automatically converted.
name - (Optional) a name for the entry. Must be unique within the pool.
- Errors:
if the pool already contains an entry with the same name.
import loottweaker.vanilla.loot.Conditions; // somePool is a LootPool created elsewhere somePool.addItemEntry( <minecraft:potato>, 1, // weight 1, i.e. low generation chance. Actual chance depends on total pool weight. 0, // Default quality [], // No functions [ Conditions.killedByPlayer() ], "someEntry" // Optional entry name );
- addItemEntry(IItemStack stack, int weightIn, int qualityIn, String name) ¶
Adds a new
item
type entry to the pool, with no conditions or functions.- Parameters:
iStack - the item stack the entry should produce. LootTweaker will autogenerate set_nbt, set_damage/set_data and set_count functions based on this stack, unless
functions
contains a function of the same type.weight - the main component that determines the generation chance. Higher weights make entries generate more often.
name - (Optional) a name for the entry. Must be unique within the pool.
- Errors:
if the pool already contains an entry with the same name.
- addItemEntry(IItemStack stack, int weightIn, String name) ¶
Adds a new
item
type entry to the pool, with no conditions or functions, and a quality of 0.- Parameters:
iStack - the item stack the entry should produce. LootTweaker will autogenerate set_nbt, set_damage/set_data and set_count functions based on this stack, unless
functions
contains a function of the same type.weight - the main component that determines the generation chance. Higher weights make entries generate more often.
name - (Optional) a name for the entry. Must be unique within the pool.
- Errors:
if the pool already contains an entry with the same name.
- addLootTableEntry(String tableName, int weightIn, int qualityIn, LootCondition[] conditions, String name) ¶
Adds a new
loot_table
type entry to the pool.- Parameters:
tableName - the identifier for the table the entry should generate loot from.
weight - the main component that determines the generation chance. Higher weights make entries generate more often.
quality- determines how much the Luck attribute affects the generation chance. Higher qualities make the luck attribute affect the generation chance more.
conditions - conditions for the generation of the entry. JSON format maps are automatically converted.
name - (Optional) a name for the entry. Must be unique within the pool.
- Errors:
if the pool already contains an entry with the same name.
import loottweaker.vanilla.loot.Conditions; // somePool is a LootPool created elsewhere somePool.addLootTableEntry( "someMod:someTable", 1, // weight 1, i.e. low generation chance. Actual chance depends on total pool weight. 0, // Default quality [ Conditions.killedByPlayer() ], "someEntry" // Optional entry name );
- addLootTableEntry(String tableName, int weightIn, int qualityIn, String name) ¶
Adds a new
loot_table
type entry to the pool with no conditions.- Parameters:
tableName - the identifier for the table the entry should generate loot from.
weight - the main component that determines the generation chance. Higher weights make entries generate more often.
quality - determines how much the Luck attribute affects the generation chance. Higher qualities make the luck attribute affect the generation chance more.
conditions - conditions for the generation of the entry.
name - (Optional) a name for the entry. Must be unique within the pool.
- Errors:
if the pool already contains an entry with the same name.
- addLootTableEntry(String tableName, int weightIn, String name) ¶
Adds a new
loot_table
type entry to the pool with no conditions, and a quality of 0.- Parameters:
tableName - the identifier for the table the entry should generate loot from.
weight - the main component that determines the generation chance. Higher weights make entries generate more often.
quality - determines how much the Luck attribute affects the generation chance. Higher qualities make the luck attribute affect the generation chance more.
conditions - conditions for the generation of the entry.
name - (Optional) a name for the entry. Must be unique within the pool.
- Errors:
if the pool already contains an entry with the same name.
- addEmptyEntry(int weight, int quality, LootCondition[] conditions, String name) ¶
Adds a new
empty
type entry to the pool.- Parameters:
weight - the main component that determines the generation chance. Higher weights make entries generate more often.
quality - determines how much the Luck attribute affects the generation chance. Higher qualities make the luck attribute affect the generation chance more.
conditions - conditions for the generation of the entry. JSON format maps are automatically converted.
name - (Optional) a name for the entry. Must be unique within the pool.
- Errors:
if the pool already contains an entry with the same name.
import loottweaker.vanilla.loot.Conditions; // somePool is a LootPool created elsewhere somePool.addLootTableEntry( 1, // weight 1, i.e. low generation chance. Actual chance depends on total pool weight. 0, // Default quality [ Conditions.killedByPlayer() ], "someEntry" // Optional entry name );
- addEmptyEntry(int weight, int quality, String name) ¶
Adds a new
empty
type entry to the pool with no conditions.- Parameters:
weight - the main component that determines the generation chance. Higher weights make entries generate more often.
quality - determines how much the Luck attribute affects the generation chance. Higher qualities make the luck attribute affect the generation chance more.
name - (Optional) a name for the entry. Must be unique within the pool.
- Errors:
if the pool already contains an entry with the same name.
- addEmptyEntry(int weight, String name) ¶
Adds a new
empty
type entry to the pool with no conditions, and a quality of 0.- Parameters:
weight - the main component that determines the generation chance. Higher weights make entries generate more often.
quality - determines how much the Luck attribute affects the generation chance. Higher qualities make the luck attribute affect the generation chance more.
name - (Optional) a name for the entry. Must be unique within the pool.
- Errors:
if the pool already contains an entry with the same name.
- setRolls(float min, float max) ¶
Sets the minimum and maximum rolls of the pool to the specified values.
- Parameters:
min - the new minimum rolls value
max - the new maximum rolls value
// somePool is a LootPool created elsewhere somePool.setRolls(0, 1);
- setBonusRolls(float min, float max) ¶
Sets the minimum and maximum bonus rolls of the pool to the specified values.
- Parameters:
min - the new minimum bonus rolls value.
max - the new maximum bonus rolls value.
// somePool is a LootPool created elsewhere somePool.setBonusRolls(0, 1);
- clearConditions() ¶
Removes all loot conditions attached to this loot pool. Loot conditions and loot functions attached to child entries are unaffected.
// somePool is a LootPool created elsewhere somePool.clearConditions();
- clearEntries() ¶
Removes all entries from this loot pool.
// somePool is a LootPool created elsewhere somePool.clearEntries();