CraftTweaker

CraftTweaker

151M Downloads

Combining LootTableIdLootCondition and other "normal" conditions in LootConditions.allOf fails.

jaredlll08 opened this issue ยท 2 comments

commented

Issue description

import crafttweaker.api.loot.condition.LootConditions;
import crafttweaker.api.loot.modifier.CommonLootModifiers;
import crafttweaker.api.loot.condition.LootTableIdLootCondition;
import crafttweaker.api.loot.condition.RandomChanceLootCondition;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.ingredient.IIngredient;
import crafttweaker.api.ingredient.type.IIngredientAny;
import crafttweaker.api.ingredient.type.IIngredientEmpty;

val cyclic_loot as float[IItemStack] = {
    <item:minecraft:stick> : 1.0
};

for item, chance in cyclic_loot {
    craftingTable.remove(item);
    loot.modifiers.register("loot_" + item.registryName.path,
        LootConditions.allOf([
            LootTableIdLootCondition.create(<resource:minecraft:chests/abandoned_mineshaft>),
            RandomChanceLootCondition.create(chance)
    ]),
    CommonLootModifiers.addWithRandomAmount(item, 4, 16));
}
loot_2.zs:17:29 Could not cast LootTableIdLootConditionBuilder to function() as LootCondition

Having just the LootTableIdLootCondition works fine.

Steps to reproduce

No response

Script used

n/a

The crafttweaker.log file

n/a

Minecraft version

1.18

Modloader

Fabric

Modloader version

Whatever CRT dev uses

CraftTweaker version

HEAD

Other relevant information

No response

The latest.log file

n/a

commented

Maybe fixed by Stan's refactor?

commented

This will be closed by ZenCodeLang/ZenCode#124