@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( 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" ) ); } ); } }
@SubscribeEvent public void onLootTableLoad(LootTableLoadEvent event) { // wither skellies drop necrotic bones if(event.getName().equals(LootTableList.ENTITIES_WITHER_SKELETON)) { LootCondition[] lootConditions = new LootCondition[0]; LootEntry entry = new LootEntryItem(TinkerCommons.matNecroticBone.getItem(), 1, 0, new LootFunction[]{new SetMetadata(lootConditions, new RandomValueRange(TinkerCommons.matNecroticBone.getMetadata()))}, lootConditions, "necrotic_bone"); event.getTable().addPool(new LootPool(new LootEntry[]{entry}, new LootCondition[]{ new KilledByPlayer(false), new RandomChanceWithLooting(0.07f, 0.05f) }, new RandomValueRange(1), new RandomValueRange(0), "necrotic_bone")); } }
private @Nonnull static SetMetadata setMetadata(int meta) { return new SetMetadata(NO_CONDITIONS, new RandomValueRange(meta)); }
private @Nonnull static SetMetadata setMetadata(int metaMin, int metaMax) { return new SetMetadata(NO_CONDITIONS, new RandomValueRange(metaMin, metaMax)); }
public EntryBuilder data(int min, int max) { return this.function(new SetMetadata(new LootCondition[0], new RandomValueRange(min, max))); }
/** * Creates a new loot entry that will be added to the loot pools when a world is loaded. * * @param location The loot table to add the loot to. You can use * {@link net.minecraft.world.storage.loot.LootTableList} for convenience. * @param name The name of the entry being added. This will be prefixed with {@link #modid} * . * @param pool The name of the pool to add the entry to. This pool must already exist. * @param weight The weight of the entry. * @param item The item to add. * @param meta The metadata for the loot. * @return A builder object. It can be used to fine tune the loot entry. */ public LootBuilder addLoot (ResourceLocation location, String name, String pool, int weight, Item item, int meta) { final LootBuilder loot = this.addLoot(location, name, pool, weight, item); loot.addFunction(new SetMetadata(new LootCondition[0], new RandomValueRange(meta, meta))); return loot; }
@SubscribeEvent public void onLootTableLoad(LootTableLoadEvent event) { LootFunction[] funcs = new LootFunction[] { new SetMetadata(new LootCondition[0], new RandomValueRange(0, enableRainbowRuneChests ? 16 : 15)) }; if(event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) event.getTable().getPool("main").addEntry(new LootEntryItem(rune, dungeonWeight, itemQuality, funcs, new LootCondition[0], "quark:rune")); else if(event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) event.getTable().getPool("main").addEntry(new LootEntryItem(rune, netherFortressWeight, itemQuality, funcs, new LootCondition[0], "quark:rune")); else if(event.getName().equals(LootTableList.CHESTS_JUNGLE_TEMPLE)) event.getTable().getPool("main").addEntry(new LootEntryItem(rune, jungleTempleWeight, itemQuality, funcs, new LootCondition[0], "quark:rune")); else if(event.getName().equals(LootTableList.CHESTS_DESERT_PYRAMID)) event.getTable().getPool("main").addEntry(new LootEntryItem(rune, desertTempleWeight, itemQuality, funcs, new LootCondition[0], "quark:rune")); }
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, ActuallyAdditions.MODID+":jams")); 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, ActuallyAdditions.MODID+":woodenCase")); 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, ActuallyAdditions.MODID+":ironCase")); 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}; LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.DRILL_CORE.ordinal())); pool.addEntry(new LootEntryItem(InitItems.itemMisc, 5, 0, new LootFunction[]{damage}, noCondition, ActuallyAdditions.MODID+":drillCore")); LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.QUARTZ.ordinal())); LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 5)); pool.addEntry(new LootEntryItem(InitItems.itemMisc, 20, 0, new LootFunction[]{damage, amount}, noCondition, ActuallyAdditions.MODID+":quartz")); 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, ActuallyAdditions.MODID+":batWings"));