Search in sources :

Example 1 with LootEntry

use of net.minecraft.world.storage.loot.LootEntry in project Adventurers-Toolbox by the-realest-stu.

the class LootTableHandler method lootTableLoad.

@SubscribeEvent
public static void lootTableLoad(LootTableLoadEvent event) {
    if (Config.ENABLE_SCHEMATICS) {
        if (!Config.DUNGEON_SCHEMATICS.isEmpty() && event.getName().toString().equals("minecraft:chests/simple_dungeon")) {
            LootEntry[] entries = new LootEntry[Config.DUNGEON_SCHEMATICS.size()];
            for (int i = 0; i < entries.length; i++) {
                NBTTagCompound nbt = new NBTTagCompound();
                nbt.setString(ItemSchematic.type_tag, Config.DUNGEON_SCHEMATICS.get(i));
                entries[i] = new LootEntryItem(ModItems.schematic, 1, 0, new LootFunction[] { new SetNBT(new LootCondition[0], nbt) }, new LootCondition[0], Config.DUNGEON_SCHEMATICS.get(i));
            }
            LootPool pool = new LootPool(entries, new LootCondition[0], new RandomValueRange(0, Math.min(3, entries.length)), new RandomValueRange(0), "schematics");
            event.getTable().addPool(pool);
        }
        if (!Config.BLACKSMITH_SCHEMATICS.isEmpty() && event.getName().toString().equals("minecraft:chests/village_blacksmith")) {
            LootEntry[] entries = new LootEntry[Config.BLACKSMITH_SCHEMATICS.size()];
            for (int i = 0; i < entries.length; i++) {
                NBTTagCompound nbt = new NBTTagCompound();
                nbt.setString(ItemSchematic.type_tag, Config.BLACKSMITH_SCHEMATICS.get(i));
                entries[i] = new LootEntryItem(ModItems.schematic, 1, 0, new LootFunction[] { new SetNBT(new LootCondition[0], nbt) }, new LootCondition[0], Config.BLACKSMITH_SCHEMATICS.get(i));
            }
            LootPool pool = new LootPool(entries, new LootCondition[0], new RandomValueRange(0, Math.min(3, entries.length)), new RandomValueRange(0), "schematics");
            event.getTable().addPool(pool);
        }
        if (!Config.BONUS_CHEST_SCHEMATICS.isEmpty() && event.getName().toString().equals("minecraft:chests/spawn_bonus_chest")) {
            LootEntry[] entries = new LootEntry[Config.BONUS_CHEST_SCHEMATICS.size()];
            for (int i = 0; i < entries.length; i++) {
                NBTTagCompound nbt = new NBTTagCompound();
                nbt.setString(ItemSchematic.type_tag, Config.BONUS_CHEST_SCHEMATICS.get(i));
                entries[i] = new LootEntryItem(ModItems.schematic, 1, 0, new LootFunction[] { new SetNBT(new LootCondition[0], nbt) }, new LootCondition[0], Config.BONUS_CHEST_SCHEMATICS.get(i));
            }
            LootPool pool = new LootPool(entries, new LootCondition[0], new RandomValueRange(0, Math.min(3, entries.length)), new RandomValueRange(0), "schematics");
            event.getTable().addPool(pool);
        }
    }
}
Also used : LootEntry(net.minecraft.world.storage.loot.LootEntry) RandomValueRange(net.minecraft.world.storage.loot.RandomValueRange) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SetNBT(net.minecraft.world.storage.loot.functions.SetNBT) LootEntryItem(net.minecraft.world.storage.loot.LootEntryItem) LootFunction(net.minecraft.world.storage.loot.functions.LootFunction) LootCondition(net.minecraft.world.storage.loot.conditions.LootCondition) LootPool(net.minecraft.world.storage.loot.LootPool) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with LootEntry

use of net.minecraft.world.storage.loot.LootEntry in project Gaspunk by Ladysnake.

the class ModItems method onLootTableLoad.

@SubscribeEvent
public static void onLootTableLoad(LootTableLoadEvent event) {
    if (event.getName().toString().equals("minecraft:chests/nether_bridge")) {
        ResourceLocation loc = new ResourceLocation(GasPunk.MOD_ID, "inject/nether_bridge");
        LootEntry entry = new LootEntryTable(loc, 1, 1, new LootCondition[0], "gaspunk_sulfur_entry");
        LootPool pool = new LootPool(new LootEntry[] { entry }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "gaspunk_sulfur_pool");
        event.getTable().addPool(pool);
    }
}
Also used : LootEntry(net.minecraft.world.storage.loot.LootEntry) RandomValueRange(net.minecraft.world.storage.loot.RandomValueRange) ResourceLocation(net.minecraft.util.ResourceLocation) LootPool(net.minecraft.world.storage.loot.LootPool) LootEntryTable(net.minecraft.world.storage.loot.LootEntryTable) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with LootEntry

use of net.minecraft.world.storage.loot.LootEntry in project pnc-repressurized by TeamPneumatic.

the class EventHandlerPneumaticCraft method onLootTableLoad.

@SubscribeEvent
public void onLootTableLoad(LootTableLoadEvent event) {
    if (ConfigHandler.general.enableDungeonLoot) {
        String prefix = "minecraft:chests/";
        String name = event.getName().toString();
        if (name.startsWith(prefix)) {
            String file = name.substring(name.indexOf(prefix) + prefix.length());
            switch(file) {
                case "abandoned_mineshaft":
                case "desert_pyramid":
                case "jungle_temple":
                case "simple_dungeon":
                case "spawn_bonus_chest":
                case "stronghold_corridor":
                case "village_blacksmith":
                    LootEntry entry = new LootEntryTable(RL("inject/simple_dungeon_loot"), 1, 0, new LootCondition[0], "pneumaticcraft_inject_entry");
                    LootPool pool = new LootPool(new LootEntry[] { entry }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "pneumaticcraft_inject_pool");
                    event.getTable().addPool(pool);
                    break;
                default:
                    break;
            }
        }
    }
}
Also used : LootEntry(net.minecraft.world.storage.loot.LootEntry) RandomValueRange(net.minecraft.world.storage.loot.RandomValueRange) LootPool(net.minecraft.world.storage.loot.LootPool) LootEntryTable(net.minecraft.world.storage.loot.LootEntryTable) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with LootEntry

use of net.minecraft.world.storage.loot.LootEntry in project Random-Things by lumien231.

the class RTEventHandler method loadLootTable.

@SubscribeEvent
public void loadLootTable(LootTableLoadEvent event) {
    LootTable table = event.getTable();
    if (event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) {
        if (Worldgen.LAVA_CHARM)
            addSingleItemWithChance("lavaCharm", table, ModItems.lavaCharm, 0.1f);
        if (Worldgen.SUMMONING_PENDULUM)
            addSingleItemWithChance("summoningPendulum", table, ModItems.summoningPendulum, 0.1f);
        if (Worldgen.MAGIC_HOOD)
            addSingleItemWithChance("magicHood", table, ModItems.magicHood, 0.15f);
        if (Worldgen.SLIME_CUBE)
            addSingleItemWithChance("slimeCube", table, Item.getItemFromBlock(ModBlocks.slimeCube), 0.3f);
    } else if (Worldgen.LAVA_CHARM && event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) {
        addSingleItemWithChance("lavaCharm", table, ModItems.lavaCharm, 0.3f);
    } else if (Worldgen.MAGIC_HOOD && event.getName().equals(LootTableList.CHESTS_VILLAGE_BLACKSMITH)) {
        addSingleItemWithChance("magicHood", table, ModItems.magicHood, 0.02f);
    } else if (Worldgen.SUMMONING_PENDULUM && event.getName().equals(LootTableList.CHESTS_STRONGHOLD_CORRIDOR)) {
        addSingleItemWithChance("summoningPendulum", table, ModItems.summoningPendulum, 0.5f);
    } else if (Worldgen.SLIME_CUBE && event.getName().equals(LootTableList.CHESTS_JUNGLE_TEMPLE)) {
        addSingleItemWithChance("slimeCube", table, Item.getItemFromBlock(ModBlocks.slimeCube), 0.8f);
    }
    if (Worldgen.BIOME_CRYSTAL && event.getName().toString().startsWith("minecraft:chests/")) {
        LootEntry crystalEntry = new LootEntryItem(ModItems.biomeCrystal, 1, 0, new LootFunction[] { new LootFunction(new LootCondition[] {}) {

            @Override
            public ItemStack apply(ItemStack stack, Random rand, LootContext context) {
                Object[] locationArray = Biome.REGISTRY.getKeys().toArray();
                ResourceLocation randomLocation = (ResourceLocation) locationArray[rand.nextInt(locationArray.length)];
                stack.setTagCompound(new NBTTagCompound());
                stack.getTagCompound().setString("biomeName", randomLocation.toString());
                return stack;
            }
        } }, new LootCondition[] {}, "randomthings:biomeCrystal");
        LootPool crystalPool = new LootPool(new LootEntry[] { crystalEntry }, new LootCondition[] { new RandomChance(0.2f) }, new RandomValueRange(1, 1), new RandomValueRange(0, 0), "randomthings:biomeCrystal");
        table.addPool(crystalPool);
    }
}
Also used : LootTable(net.minecraft.world.storage.loot.LootTable) LootContext(net.minecraft.world.storage.loot.LootContext) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) RandomChance(net.minecraft.world.storage.loot.conditions.RandomChance) LootEntryItem(net.minecraft.world.storage.loot.LootEntryItem) LootFunction(net.minecraft.world.storage.loot.functions.LootFunction) LootCondition(net.minecraft.world.storage.loot.conditions.LootCondition) LootEntry(net.minecraft.world.storage.loot.LootEntry) Random(java.util.Random) RandomValueRange(net.minecraft.world.storage.loot.RandomValueRange) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) LootPool(net.minecraft.world.storage.loot.LootPool) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with LootEntry

use of net.minecraft.world.storage.loot.LootEntry in project harvestcraft by MatrexsVigil.

the class LootHandler method handleLootTableMod.

public static void handleLootTableMod(LootTableLoadEvent event) {
    final List<CustomLootPool> customLootPools = getCustomLootPools(event.getName());
    for (CustomLootPool customLootPool : customLootPools) {
        final String lootPoolId = customLootPool.isSeperateLootPool() ? SEPARATE_LOOT_POOL_ID : VANILLA_LOOT_POOL_ID;
        createPoolIfNotExists(event.getTable(), lootPoolId);
        final LootPool lootPool = event.getTable().getPool(lootPoolId);
        for (LootEntry entry : customLootPool.getLootEntries()) {
            lootPool.addEntry(entry);
        }
    }
}
Also used : LootEntry(net.minecraft.world.storage.loot.LootEntry) LootPool(net.minecraft.world.storage.loot.LootPool)

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