Search in sources :

Example 6 with LootEntry

use of net.minecraft.world.storage.loot.LootEntry in project ImmersiveEngineering by BluSunrize.

the class EventHandler method lootLoad.

@SubscribeEvent
public void lootLoad(LootTableLoadEvent event) {
    if (event.getName().getNamespace().equals("minecraft"))
        for (ResourceLocation inject : lootInjections) if (event.getName().getPath().equals(inject.getPath())) {
            LootPool injectPool = Utils.loadBuiltinLootTable(inject, event.getLootTableManager()).getPool("immersiveengineering_loot_inject");
            LootPool mainPool = event.getTable().getPool("main");
            if (injectPool != null && mainPool != null)
                try {
                    if (f_lootEntries == null) {
                        // field_186453_a is srg for lootEntries
                        f_lootEntries = LootPool.class.getDeclaredField(ObfuscationReflectionHelper.remapFieldNames(LootPool.class.getName(), "field_186453_a")[0]);
                        f_lootEntries.setAccessible(true);
                    }
                    if (f_lootEntries != null) {
                        List<LootEntry> entryList = (List<LootEntry>) f_lootEntries.get(injectPool);
                        for (LootEntry entry : entryList) mainPool.addEntry(entry);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
        }
}
Also used : LootEntry(net.minecraft.world.storage.loot.LootEntry) ResourceLocation(net.minecraft.util.ResourceLocation) LootPool(net.minecraft.world.storage.loot.LootPool) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

LootEntry (net.minecraft.world.storage.loot.LootEntry)6 LootPool (net.minecraft.world.storage.loot.LootPool)6 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 RandomValueRange (net.minecraft.world.storage.loot.RandomValueRange)4 ResourceLocation (net.minecraft.util.ResourceLocation)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 LootEntryItem (net.minecraft.world.storage.loot.LootEntryItem)2 LootEntryTable (net.minecraft.world.storage.loot.LootEntryTable)2 LootCondition (net.minecraft.world.storage.loot.conditions.LootCondition)2 LootFunction (net.minecraft.world.storage.loot.functions.LootFunction)2 Random (java.util.Random)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 ItemStack (net.minecraft.item.ItemStack)1 LootContext (net.minecraft.world.storage.loot.LootContext)1 LootTable (net.minecraft.world.storage.loot.LootTable)1 RandomChance (net.minecraft.world.storage.loot.conditions.RandomChance)1 SetNBT (net.minecraft.world.storage.loot.functions.SetNBT)1