#LootTables not working

1 messages · Page 1 of 1 (latest)

fossil sparrow
#

LootTableEvents.MODIFY.register((key, tableBuilder, source, registry) ->{

        if(LootTables.BURIED_TREASURE_CHEST.equals(key.getValue())){
            LootPool.Builder poolBuilder = LootPool.builder().rolls(ConstantLootNumberProvider.create(1))
                    .conditionally(RandomChanceLootCondition.builder(1f))
                    .with(ItemEntry.builder(Items.SNIFFER_EGG))
                    .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1.0f,2.0f)).build());

            tableBuilder.pool(poolBuilder.build());
        }
    });

So been trying to get this to work in minecraft 1.21.4 and it just doesnt work

#

It doesnt show any errors, its just the items refuse to spawn into the assigned structures

soft dome
#

Does it work

if you put a more simple one without condition ?

var lootPool =
    LootPool.builder()
    .rolls(ConstantLootNumberProvider.create(1))
    .with(
        ItemEntry.builder(Items.DIAMOND_BLOCK)
        .weight(1)
    );

tableBuilder.pool(lootPool);

/loot give @s loot minecraft:chests/burried_treasure

#

And if there is any datapack that overrides the whole table it will not work
like the villager trade rebalance one

fossil sparrow
soft dome
#

and it work great

fossil sparrow
#

Nvm i figured out how to fix it

i put if(LootTables.BURIED_TREASURE_CHEST.equals(key.getValue()))

when now it should be if(key.equals(LootTables.BURIED_TREASURE_CHEST))

#

Thank you

soft dome
#

place a debug breakpoint to see the code inisde if is ever called

#

Registry thing is always strange😅

fossil sparrow
#

It is very.

#

For entities its

if(HORSE_ID.equals(key.getValue()))

but then for structures its

if(key.equals(LootTables.BURIED_TREASURE_CHEST))

which when you think about it, it makes sense but still irritating