Jump to content

[1.15][solved] Chest LootTables


marcowflash

Recommended Posts

Hi, I am trying to add new loot to chests. I started with the bonus spawn chest :

Spoiler

@Mod.EventBusSubscriber(modid = ThelastofcraftMod.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public class LootTablesSetup {

    @SubscribeEvent
    public void onLootTablesLoaded(LootTableLoadEvent event) {

        if (event.getName().equals(LootTables.CHESTS_SPAWN_BONUS_CHEST)) {
            LootTable table = event.getLootTableManager().getLootTableFromLocation(LootTables.CHESTS_SPAWN_BONUS_CHEST);
            table.addPool(LootPool.builder().name("TLOC_tool")
                        .addEntry(ItemLootEntry.builder(Registration.MODTOOL.get()).weight(20).acceptFunction(SetCount.builder(ConstantRange.of(1))))
                        .addEntry(ItemLootEntry.builder(Registration.SIGHT.get()).weight(15).acceptFunction(SetCount.builder(BinomialRange.of(1, 0.3F))))
                        .build());
            table.addPool(LootPool.builder().name("TLOC_misc")
                        .rolls(RandomValueRange.of(20.0F, 30.0F))
                        .addEntry(ItemLootEntry.builder(Registration.WEAPONPART.get()).weight(15))
                        .addEntry(ItemLootEntry.builder(Registration.BULLET_ITEM.get()).weight(20))
                        .build());
            table.addPool(LootPool.builder().name("TLOC_gun")
                        .rolls(ConstantRange.of(1))
                        .addEntry(ItemLootEntry.builder(Registration.SHOTGUN.get()).weight(5))
                        .addEntry(ItemLootEntry.builder(Registration.RIFLE.get()).weight(5))
                        .addEntry(ItemLootEntry.builder(Registration.REVOLVER.get()).weight(15))
                        .addEntry(ItemLootEntry.builder(Registration.PISTOL.get()).weight(10))
                        .addEntry(ItemLootEntry.builder(Items.AIR).weight(3))
                        .build());
            table.addPool(LootPool.builder().name("TLOC_throwable")
                        .rolls(RandomValueRange.of(1.0F, 3.0F))
                        .addEntry(ItemLootEntry.builder(Registration.MOLOTOV_ITEM.get()).weight(20))
                        .addEntry(ItemLootEntry.builder(Registration.NAILBOMB_ITEM.get()).weight(15))
                        .build());
        }
    }
}

 

Is this the right way to do it ? I suppose not since it doesn't work.

Link to comment
Share on other sites

  • marcowflash changed the title to [1.15][solved] Chest LootTables

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.