public GadgetEvents() { LootEntry entry = new LootEntryItem(TinkerGadgets.spaghetti, 1, 1, new LootFunction[0], new LootCondition[0], "moms_spaghetti"); LootCondition chance = new RandomChance(0.05f); pool = new LootPool(new LootEntry[] {entry}, new LootCondition[] {chance}, new RandomValueRange(1), new RandomValueRange(0), "moms_spaghetti"); }
private LootPool getInjectPool(String entryName) { return new LootPool(new LootEntry[] { getInjectEntry(entryName, 1) }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "botania_inject_pool"); }
@Override public boolean testCondition(@Nonnull Random rand, @Nonnull LootContext context) { return context.getLootedEntity() instanceof EntityDoppleganger && context.getKillerPlayer() == ((EntityDoppleganger) context.getLootedEntity()).trueKiller; }
@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")); } }
@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" ) ); } ); } }
public static List<ItemStack> getLoot(ResourceLocation loot, World world, EntityPlayer player, float luck) { LootContext.Builder lootcontext$builder = new LootContext.Builder((WorldServer) world); lootcontext$builder.withLuck(player.getLuck() + luck); lootcontext$builder.withPlayer(player); return world.getLootTableManager().getLootTableFromLocation(loot).generateLootForPools(world.rand, lootcontext$builder.build()); }
@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")); }
List<ItemStack> stacks = world.getLootTableManager().getLootTableFromLocation(lootTable).generateLootForPools(rand, new LootContext.Builder((WorldServer) world).build()); if (stacks.isEmpty()) return;
private static void createPoolIfNotExists(LootTable lootTable, String poolId) { if (poolId.equals(VANILLA_LOOT_POOL_ID) || lootTable.getPool(poolId) != null) return; lootTable.addPool(new LootPool(new LootEntry[] {}, new LootCondition[] {}, new RandomValueRange(1), new RandomValueRange(0), poolId)); }
public LootHandler() { for (String s : TABLES) { LootTableList.register(new ResourceLocation(LibMisc.MOD_ID, s)); } LootConditionManager.registerCondition(new TrueGuardianKiller.Serializer()); LootConditionManager.registerCondition(new EnableRelics.Serializer()); LootFunctionManager.registerFunction(new BindUuid.Serializer()); }
private void addLoot(LootPool main, Item item, int rando) { if (item != null) {//shortcut fix bc of new module config system that can delete items main.addEntry(new LootEntryItem(item, rando, 0, new LootFunction[0], new LootCondition[0], Const.MODRES + item.getTranslationKey())); } }
@SubscribeEvent public void onLootTableLoad(LootTableLoadEvent event) { if(SPAGHETTI_LOCATIONS.contains(event.getName().toString())) { event.getTable().addPool(pool); } } }
private static LootEntryItem createLootEntryItem(Item item, int weight, int quality, LootFunction[] lootFunctions, LootCondition... lootConditions) { return new LootEntryItem(item, weight, quality, lootFunctions, lootConditions, "harvestcraft." + item.getUnlocalizedName()); } }
private LootEntryTable getInjectEntry(String name, int weight) { return new LootEntryTable(new ResourceLocation(LibMisc.MOD_ID, "inject/" + name), weight, 0, new LootCondition[0], "botania_inject_entry"); }
@Nonnull @Override public ItemStack apply(@Nonnull ItemStack stack, @Nonnull Random rand, @Nonnull LootContext context) { if (context.getKillerPlayer() != null) { ((ItemRelic) ModItems.dice).bindToUUID(context.getKillerPlayer().getUniqueID(), stack); } return stack; }
public LootPool createDefaultLootPool() { return new LootPool(lootEntries, new LootCondition[] {}, new RandomValueRange(1), new RandomValueRange(0), LootHandler.VANILLA_LOOT_POOL_ID); } }
private static void registerDungeonLoot() { LootTableList.register(Constants.VILLAGE_NATURALIST_LOOT_KEY); }
@SubscribeEvent public void lootLoad(LootTableLoadEvent evt) { String prefix = "minecraft:chests/"; String name = evt.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": evt.getTable().addPool(getInjectPool(file)); break; default: break; } } }
public LootPool build() { LootEntry[] entries = this.entries.toArray(new LootEntry[this.entries.size()]); LootCondition[] conditions = this.conditions.toArray(new LootCondition[this.conditions.size()]); return new LootPool(entries, conditions, new RandomValueRange(this.minRolls, this.maxRolls), new RandomValueRange(this.minBonusRolls, this.maxBonusRolls), this.name); } }