LootJS: KubeJS Addon

LootJS: KubeJS Addon

8M Downloads

Transformation of entire loot list for `modifyLoot`

Prunoideae opened this issue ยท 1 comments

commented

Describe the feature/addition!

Instead of transforming each item in list, transform the entire list at one time:

For following lines of code:

public boolean applyLootHandler(LootContext context, List<ItemStack> loot) {
for (int i = 0; i < loot.size(); i++) {
if (predicate.test(loot.get(i))) {
ItemStack currentItemStack = loot.get(i);
loot.set(i, callback.modify(currentItemStack).copy());
}
}

Instead of using set, modifies the entire list returned by a callback:

loot.clear()
loot.addAll(callback.whatsoever())

Also, is it possible to expose LootContext here? It would be good for doing context-specific drops, like dropping head of player or souls of killed entities, etc.

Why would like to see this feature/addition?

The only way to change drops with a predicate is to use modifyLoot, however, this one-to-one mapping of loot is pretty rigid.

commented

Should use .apply(Consumer<LootContextJS>) instead.