-
Notifications
You must be signed in to change notification settings - Fork 4
1.19.2 Event
LootJS provides the lootjs
KubeJS event to create your loot modifications or for other stuff. The event is server-sided and can be reloaded by invoking /reload
.
To learn more about KubeJS events, please refer to their wiki.
LootJS.modifiers((event) => {
// your code
});
Adds a new loot modifier for blocks.
The function returns a builder
object so you can add conditions
and actions
.
LootJS.modifiers((event) => {
event
.addBlockLootModifier("minecraft:gravel")
.randomChance(0.3)
.addLoot("minecraft:gunpowder");
});
Adds a new loot modifier for entities.
The function returns a builder
object so you can add conditions
and actions
.
LootJS.modifiers((event) => {
event
.addEntityLootModifier("minecraft:creeper")
.addLoot("minecraft:gunpowder");
});
Adds a new loot modifier for loot tables. You can use multiple loot table ids or use a regular expression for values
.
The function returns a builder
object so you can add conditions
and actions
.
LootJS.modifiers((event) => {
// by id
event
.addLootTableModifier("minecraft:entities/creeper")
.randomChance(0.3)
.addLoot("minecraft:gunpowder");
// by regular expression
event
.addLootTableModifier(/.*creeper.*/)
.randomChance(0.3)
.addLoot("minecraft:gunpowder");
});
Adds a new loot modifier for a loot type. You can also use multiple LootType
's for types
.
The function returns a builder
object so you can add conditions
and actions
.
LootJS.modifiers((event) => {
event
.addLootTypeModifier(LootType.ENTITY) // or multiple LootType.BLOCK, LootType.ENTITY ...
.randomChance(0.3)
.addLoot("minecraft:gravel");
});
LootJS.modifiers(event => {
event.disableWitherStarDrop()
event.disableCreeperHeadDrop()
event.disableSkeletonHeadDrop()
event.disableZombieHeadDrop()
})
Enables the log output.
LootJS.modifiers((event) => {
event.enableLogging();
});
Returns a list of all registered global loot modifiers from other mods.
LootJS.modifiers((event) => {
const modifiers = event.getGlobalModifiers();
modifiers.forEach((modifier) => {
console.log(modifier)
});
});
Remove one or multiple global loot modifiers from other mods. Can be used to prevent mods from adding their own loot through global loot. This will not work if the mod adds their items directly into the loot tables.
You can pass multiple loot tables or mod ids.
LootJS.modifiers((event) => {
event.removeGlobalModifier("examplemod:example_loot_change"); // by location
event.removeGlobalModifier("@examplemod"); // by mod id. Use `@` as prefix
});
Disables the loot modification for given values
.
values
can be resource locations for the loot table or a regular expression.
LootJS.modifiers((event) => {
// all leaves disabled via regex
event.disableLootModification(/.*:blocks\/.*_leaves/);
// disable bats
event.disableLootModification("minecraft:entities/bat");
});