List of usage examples for net.minecraftforge.event LootTableLoadEvent getTable
public LootTable getTable()
From source file:appeng.loot.ChestLoot.java
License:Open Source License
@SubscribeEvent public void loadLootTable(LootTableLoadEvent event) { if (event.getName() == LootTableList.CHESTS_ABANDONED_MINESHAFT) { //TODO 1.9.4 aftermath - All these loot quality, pools and stuff. Figure it out and balance it. final IMaterials materials = AEApi.instance().definitions().materials(); materials.certusQuartzCrystal().maybeStack(1).ifPresent(is -> { event.getTable() .addPool(/*from w w w . j a v a2 s .c o m*/ new LootPool( new LootEntry[] { new LootEntryItem(is.getItem(), 2, 3, new LootFunction[] { new SetMetadata(null, new RandomValueRange(is.getItemDamage())) }, new LootCondition[] { new RandomChance(1) }, "AE2 Crystal_" + is.getItemDamage()) }, new LootCondition[0], new RandomValueRange(1, 4), new RandomValueRange(0, 2), "AE2 Crystals")); }); materials.certusQuartzDust().maybeStack(1).ifPresent(is -> { event.getTable() .addPool( new LootPool( new LootEntryItem[] { new LootEntryItem(is.getItem(), 2, 3, new LootFunction[] { new SetMetadata(null, new RandomValueRange(is.getItemDamage())) }, new LootCondition[] { new RandomChance(1) }, "AE2 Dust_" + is.getItemDamage()) }, new LootCondition[0], new RandomValueRange(1, 4), new RandomValueRange(0, 2), "AE2 Dusts")); }); } }
From source file:com.crackedzombie.common.CrackedZombie.java
License:Open Source License
@SuppressWarnings("unused") @SubscribeEvent//from ww w.j a va2s .co m public void onLootTableLoad(LootTableLoadEvent event) { if (event.getName().equals(LootTableList.CHESTS_ABANDONED_MINESHAFT)) { event.getTable().getPool("main").addEntry(iron_sword); } }
From source file:com.foudroyantfactotum.mod.fousarchive.init.InitLootSys.java
License:Open Source License
@SubscribeEvent public void lootTableLoad(LootTableLoadEvent event) { if (event.getName().equals(LootTableList.CHESTS_ABANDONED_MINESHAFT) || event.getName().equals(LootTableList.CHESTS_VILLAGE_BLACKSMITH) || event.getName().equals(LootTableList.CHESTS_IGLOO_CHEST) || event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON) || event.getName().equals(LootTableList.CHESTS_JUNGLE_TEMPLE) || event.getName().equals(LootTableList.CHESTS_STRONGHOLD_LIBRARY) || event.getName().equals(LootTableList.GAMEPLAY_FISHING_TREASURE) || event.getName().equals(LootTableList.CHESTS_DESERT_PYRAMID) || event.getName().equals(LootTableList.CHESTS_END_CITY_TREASURE)) { Optional.of(event.getTable()).ifPresent(lootTable -> lootTable.addPool(poolPianoRolls)); }/*w w w . j a va2 s .c o m*/ }
From source file:com.gmail.socraticphoenix.forge.randore.module.loot.RandoresLoot.java
License:Open Source License
@SubscribeEvent public void Table_Additives(LootTableLoadEvent event) { String name = event.getName().toString(); ConfigCategory config = Randores.getInstance().getConfiguration().getCategory("modules"); if (config.get("dungeonloot").getBoolean()) { if (is(name, chests)) { event.getTable() .addPool(new LootPool( new LootEntry[] { new FlexibleLootEntry(1, 2, true, 10, 20, new LootCondition[0], "randores_flexible_loot_entry") }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "randores_flexible_pool")); } else if (name.contains("end_city_treasure")) { event.getTable()// w w w . j a v a 2s. c o m .addPool(new LootPool( new LootEntry[] { new FlexibleLootEntry(1, 5, true, 20, 50, new LootCondition[0], "randores_flexible_loot_entry") }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "randores_flexible_pool")); } else if (name.contains("spawn_bonus_chest")) { event.getTable() .addPool(new LootPool( new LootEntry[] { new FlexibleLootEntry(1, 1, false, 0, 0, new LootCondition[0], "randores_flexible_loot_entry") }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "randores_flexible_pool")); } } }
From source file:com.lothrazar.cyclicmagic.module.LootTableModule.java
License:Open Source License
@SubscribeEvent public void onLootTableLoad(LootTableLoadEvent event) { LootPool main = event.getTable().getPool(LOOTPOOLNAME); if (main == null) { //create my own. EX: mobs that have no drops (bats) also have empty loot table, so i have to inject an entry in the table before I fill it event.getTable().addPool(new LootPool(new LootEntry[0], new LootCondition[0], new RandomValueRange(1F, 2F), new RandomValueRange(1F, 1F), LOOTPOOLNAME)); main = event.getTable().getPool(LOOTPOOLNAME); if (main == null) { ModCyclic.logger.error("could not insert Loot Pool for table :" + event.getName().toString()); return; }/*from ww w . jav a 2 s .com*/ } if (enableChestLoot) { onLootChestTableLoad(main, event); } }
From source file:cyano.alt.ALTEventHandler.java
License:Open Source License
@SubscribeEvent(priority = EventPriority.NORMAL) public void onLootLoad(LootTableLoadEvent event) { if (event.getName().getResourceDomain().equals("minecraft") == false) return; // loot table from another mod (too fancy for ALT) String categoryAndEntry = event.getName().getResourcePath(); // e.g. "chests/abandoned_mineshaft" if (categoryAndEntry.contains("/") == false) return; // not valid // category is "chests" or "entities" String category = categoryAndEntry.substring(0, categoryAndEntry.indexOf('/')); // entry is the name of the loot table (e.g. "abandoned_mineshaft") String entry = categoryAndEntry.substring(categoryAndEntry.indexOf('/') + 1, categoryAndEntry.length()); final Map<String, Map<String, List<LootPool>>> additional_loot = AdditionalLootTables .getAdditionalLootTables();//from ww w.j ava2s. c om if (additional_loot.containsKey(category) && additional_loot.get(category).containsKey(entry)) { List<LootPool> pools = additional_loot.get(category).get(entry); if (pools == null || pools.isEmpty()) return; // nothing to add if (event.getTable() == null) { // table was removed by another mod FMLLog.info("%s: creating new loot table %s", MODID, event.getName()); event.setTable(new LootTable(pools.toArray(new LootPool[pools.size()]))); } else { // table exists, add pools to it FMLLog.info("%s: adding more loot to loot table %s", MODID, event.getName()); for (LootPool pool : pools) { event.getTable().addPool(pool); } } } }
From source file:de.ellpeck.actuallyadditions.mod.misc.DungeonLoot.java
@SubscribeEvent public void onLootTableLoad(LootTableLoadEvent event) { if (ConfigBoolValues.DUNGEON_LOOT.isEnabled() && event.getName() != null && event.getTable() != null) { LootCondition[] noCondition = new LootCondition[0]; LootPool pool = event.getTable().getPool("main"); if (pool == null) { pool = new LootPool(new LootEntry[0], noCondition, new RandomValueRange(5, 10), new RandomValueRange(0), "main"); event.getTable().addPool(pool); }//from ww w . j a v a 2s .co m boolean addCrystals = false; boolean addDrillCore = false; boolean addQuartz = false; boolean addBatWings = false; boolean addBook = false; if (LootTableList.CHESTS_SIMPLE_DUNGEON.equals(event.getName())) { addCrystals = true; addDrillCore = true; addQuartz = true; } else if (LootTableList.CHESTS_ABANDONED_MINESHAFT.equals(event.getName())) { addCrystals = true; addDrillCore = true; } else if (LootTableList.CHESTS_VILLAGE_BLACKSMITH.equals(event.getName())) { addDrillCore = true; addQuartz = true; addBook = true; } else if (LootTableList.CHESTS_STRONGHOLD_LIBRARY.equals(event.getName())) { addBatWings = true; addBook = true; } else if (LootTableList.CHESTS_IGLOO_CHEST.equals(event.getName())) { addBatWings = true; } else if (LootTableList.CHESTS_DESERT_PYRAMID.equals(event.getName())) { addDrillCore = true; addBatWings = true; } else if (LootTableList.CHESTS_NETHER_BRIDGE.equals(event.getName())) { addBatWings = true; addCrystals = true; addDrillCore = true; addBook = true; } else if (LootTableList.CHESTS_END_CITY_TREASURE.equals(event.getName())) { addBatWings = true; addCrystals = true; addDrillCore = true; addQuartz = true; } else if (LootTableList.CHESTS_WOODLAND_MANSION.equals(event.getName())) { addBatWings = true; addCrystals = true; addDrillCore = true; addQuartz = true; addBook = true; } else if (JAM_HOUSE.equals(event.getName())) { LootFunction jamDamage = new SetMetadata(noCondition, new RandomValueRange(0, TheJams.values().length - 1)); LootFunction jamAmount = new SetCount(noCondition, new RandomValueRange(3, 5)); pool.addEntry(new LootEntryItem(InitItems.itemJams, 2, 0, new LootFunction[] { jamDamage, jamAmount }, noCondition, ModUtil.MOD_ID + ":jams")); LootFunction glassAmount = new SetCount(noCondition, new RandomValueRange(2)); pool.addEntry(new LootEntryItem(Items.GLASS_BOTTLE, 1, 0, new LootFunction[] { glassAmount }, noCondition, ModUtil.MOD_ID + ":bottles")); } else if (LUSH_CAVES.equals(event.getName())) { addBook = true; addQuartz = true; addBatWings = true; addCrystals = true; pool.addEntry(new LootEntryItem(Items.BOOK, 50, 0, new LootFunction[0], noCondition, ModUtil.MOD_ID + ":book")); LootFunction bonesAmount = new SetCount(noCondition, new RandomValueRange(1, 12)); pool.addEntry(new LootEntryItem(Items.BONE, 100, 0, new LootFunction[] { bonesAmount }, noCondition, ModUtil.MOD_ID + ":bones")); Item[] aiots = new Item[] { InitItems.woodenPaxel, InitItems.stonePaxel, InitItems.quartzPaxel, InitItems.itemPaxelCrystalBlack, InitItems.itemPaxelCrystalWhite }; for (int i = 0; i < aiots.length; i++) { LootFunction damage = new SetDamage(noCondition, new RandomValueRange(0F, 0.25F)); pool.addEntry(new LootEntryItem(aiots[i], 30 - i * 5, 0, new LootFunction[] { damage }, noCondition, ModUtil.MOD_ID + ":aiot" + i)); } Item[] armor = new Item[] { Items.LEATHER_HELMET, Items.LEATHER_CHESTPLATE, Items.LEATHER_LEGGINGS, Items.LEATHER_BOOTS }; for (int i = 0; i < armor.length; i++) { LootFunction damage = new SetDamage(noCondition, new RandomValueRange(0F, 0.75F)); pool.addEntry(new LootEntryItem(armor[i], 50, 0, new LootFunction[] { damage }, noCondition, ModUtil.MOD_ID + ":armor" + i)); } } else if (ENGINEER_HOUSE.equals(event.getName())) { addBook = true; addQuartz = true; addBatWings = true; addCrystals = true; addDrillCore = true; LootFunction woodCaseAmount = new SetCount(noCondition, new RandomValueRange(3, 10)); LootFunction woodCaseDamage = new SetMetadata(noCondition, new RandomValueRange(TheMiscBlocks.WOOD_CASING.ordinal())); pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 60, 0, new LootFunction[] { woodCaseAmount, woodCaseDamage }, noCondition, ModUtil.MOD_ID + ":woodenCase")); LootFunction ironCaseAmount = new SetCount(noCondition, new RandomValueRange(1, 3)); LootFunction ironCaseDamage = new SetMetadata(noCondition, new RandomValueRange(TheMiscBlocks.IRON_CASING.ordinal())); pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 40, 0, new LootFunction[] { ironCaseAmount, ironCaseDamage }, noCondition, ModUtil.MOD_ID + ":ironCase")); } if (addCrystals) { LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(0, TheCrystals.values().length - 1)); LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 3)); LootFunction[] functions = new LootFunction[] { damage, amount }; pool.addEntry(new LootEntryItem(InitItems.itemCrystal, 50, 0, functions, noCondition, ModUtil.MOD_ID + ":crystalItems")); pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockCrystal), 5, 0, functions, noCondition, ModUtil.MOD_ID + ":crystalBlocks")); } if (addDrillCore) { LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.DRILL_CORE.ordinal())); pool.addEntry(new LootEntryItem(InitItems.itemMisc, 10, 0, new LootFunction[] { damage }, noCondition, ModUtil.MOD_ID + ":drillCore")); } if (addQuartz) { LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.QUARTZ.ordinal())); LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 10)); pool.addEntry(new LootEntryItem(InitItems.itemMisc, 80, 0, new LootFunction[] { damage, amount }, noCondition, ModUtil.MOD_ID + ":quartz")); } if (addBatWings) { LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.BAT_WING.ordinal())); LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 2)); pool.addEntry(new LootEntryItem(InitItems.itemMisc, 5, 0, new LootFunction[] { damage, amount }, noCondition, ModUtil.MOD_ID + ":batWings")); } if (addBook) { LootFunction amount = new SetCount(noCondition, new RandomValueRange(1)); pool.addEntry(new LootEntryItem(InitItems.itemBooklet, 100, 0, new LootFunction[] { amount }, noCondition, ModUtil.MOD_ID + ":booklet")); } } }
From source file:hellfirepvp.astralsorcery.common.util.LootTableUtil.java
License:Open Source License
@SubscribeEvent public void onLootLoad(LootTableLoadEvent event) { ResourceLocation name = event.getName(); if (constellationPaperTables.contains(name)) { event.getTable().getPool("main") .addEntry(new LootEntryItem(ItemsAS.constellationPaper, Config.constellationPaperRarity, Config.constellationPaperQuality, new LootFunction[0], new LootCondition[0], "astralsorcery:constellation_paper")); }//w ww . j a v a 2 s . c o m }
From source file:nightkosh.gravestone_extended.core.GSLootTables.java
License:LGPL
public static void inject(LootTableLoadEvent event) { if (event.getName().toString().equals("minecraft:entities/bat")) { LootEntry entry = new LootEntryTable(new ResourceLocation(ModInfo.ID, "inject/bat"), 1, 1, new LootCondition[0], "bat_wing"); LootPool pool = new LootPool(new LootEntry[] { entry }, new LootCondition[] {}, new RandomValueRange(1, 1), new RandomValueRange(0, 1), "bat_wing"); event.getTable().addPool(pool); }// ww w. j a v a 2 s .c o m }
From source file:org.blockartistry.Debris.data.RubbleLootTable.java
License:MIT License
@SubscribeEvent(priority = EventPriority.HIGH, receiveCanceled = false) public static void onLootTableLoad(@Nonnull final LootTableLoadEvent event) { if (!TABLES.contains(event.getName())) return;//www . j a v a 2 s .co m final String poolName = event.getName().getResourcePath(); final LootPool pool = event.getTable().getPool(poolName); if (pool == null) { ModLog.warn("Can't find pool [%s] in loot table [%s]", poolName, event.getName()); return; } pool.setRolls(new RandomValueRange(ModOptions.rubbleRollsMin, ModOptions.rubbleRollsMax)); pool.setBonusRolls(new RandomValueRange(ModOptions.bonusRollsMin, ModOptions.bonusRollsMax)); if ("pile_of_rubble".equals(poolName)) { applyDictionary(pool, "oreCopper", 50, 1, 2); applyDictionary(pool, "oreTin", 50, 1, 2); } for (final ModEnvironment me : ModEnvironment.values()) if (me.isLoaded()) process(event.getTable(), me.getModId(), poolName); for (final String external : ModOptions.externalScriptFiles) { final File file = new File(Debris.dataDirectory(), external); if (file.exists()) process(event.getTable(), file, poolName); else ModLog.warn("Unable to locate external configuration file [%s]", file.toString()); } }