@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; } } } }
@SubscribeEvent public static void onLootTableLoad(LootTableLoadEvent event) { ResourceLocation tableName = event.getName(); LootPool pool = null; int bandage = 0, plaster = 0, morphine = 0; if (tableName.equals(LootTableList.CHESTS_SPAWN_BONUS_CHEST)) { pool = event.getTable().getPool("main"); bandage = 8; plaster = 16; morphine = 4; } else if (tableName.equals(LootTableList.CHESTS_STRONGHOLD_CORRIDOR) || tableName.equals(LootTableList.CHESTS_STRONGHOLD_CROSSING) || tableName.equals(LootTableList.CHESTS_ABANDONED_MINESHAFT)) { pool = event.getTable().getPool("main"); bandage = 20; plaster = 24; morphine = 8; } if (pool != null) { pool.addEntry(new LootEntryItem(FirstAidItems.BANDAGE, bandage, 0, new SetCount[]{new SetCount(new LootCondition[0], new RandomValueRange(1, 3))}, new LootCondition[0], FirstAid.MODID + "bandage")); pool.addEntry(new LootEntryItem(FirstAidItems.PLASTER, plaster, 0, new SetCount[]{new SetCount(new LootCondition[0], new RandomValueRange(1, 5))}, new LootCondition[0], FirstAid.MODID + "plaster")); pool.addEntry(new LootEntryItem(FirstAidItems.MORPHINE, morphine, 0, new SetCount[]{new SetCount(new LootCondition[0], new RandomValueRange(1, 2))}, new LootCondition[0], FirstAid.MODID + "morphine")); } }
@SubscribeEvent public void onLootTableEvent(LootTableLoadEvent event) { if(Clef.config.lootSpawnRate > 0) { for(String s : Clef.config.disabledLootChests) { if(event.getName().toString().equals(s)) { return; } } if(event.getName().getResourcePath().contains("chest")) { event.getTable().addPool(new LootPool(new LootEntry[] { new LootEntryItem(Clef.itemInstrument, Clef.config.lootSpawnRate, 0, new LootFunction[] { new LootFunction(new LootCondition[0]) { @Override public ItemStack apply(ItemStack stack, Random rand, LootContext context) { InstrumentLibrary.assignRandomInstrument(stack); return stack; } } }, new LootCondition[0], "clef_instrument_pool") }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0), "clef_instrument")); } } }
public SetAttributes deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { JsonArray jsonarray = JsonUtils.getJsonArray(object, "modifiers"); SetAttributes.Modifier[] asetattributes$modifier = new SetAttributes.Modifier[jsonarray.size()]; int i = 0; for (JsonElement jsonelement : jsonarray) { asetattributes$modifier[i++] = SetAttributes.Modifier.deserialize(JsonUtils.getJsonObject(jsonelement, "modifier"), deserializationContext); } if (asetattributes$modifier.length == 0) { throw new JsonSyntaxException("Invalid attribute modifiers array; cannot be empty"); } else { return new SetAttributes(conditionsIn, asetattributes$modifier); } }
public EnchantRandomly deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { List<Enchantment> list = Lists.<Enchantment>newArrayList(); if (object.has("enchantments")) { for (JsonElement jsonelement : JsonUtils.getJsonArray(object, "enchantments")) { String s = JsonUtils.getString(jsonelement, "enchantment"); Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getObject(new ResourceLocation(s)); if (enchantment == null) { throw new JsonSyntaxException("Unknown enchantment \'" + s + "\'"); } list.add(enchantment); } } return new EnchantRandomly(conditionsIn, list); }
public LootFunction deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "function"); ResourceLocation resourcelocation = new ResourceLocation(JsonUtils.getString(jsonobject, "function")); LootFunction.Serializer<?> serializer; try { serializer = LootFunctionManager.getSerializerForName(resourcelocation); } catch (IllegalArgumentException var8) { throw new JsonSyntaxException("Unknown function \'" + resourcelocation + "\'"); } return serializer.deserialize(jsonobject, p_deserialize_3_, (LootCondition[])JsonUtils.deserializeClass(jsonobject, "conditions", new LootCondition[0], p_deserialize_3_, LootCondition[].class)); }
public static LootEntryItem deserialize(JsonObject object, JsonDeserializationContext deserializationContext, int weightIn, int qualityIn, LootCondition[] conditionsIn) { Item item = JsonUtils.getItem(object, "name"); LootFunction[] alootfunction; if (object.has("functions")) { alootfunction = (LootFunction[])JsonUtils.deserializeClass(object, "functions", deserializationContext, LootFunction[].class); } else { alootfunction = new LootFunction[0]; } return new LootEntryItem(item, weightIn, qualityIn, alootfunction, conditionsIn); }
public EnchantRandomly deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { List<Enchantment> list = null; if (object.has("enchantments")) { list = Lists.<Enchantment>newArrayList(); for (JsonElement jsonelement : JsonUtils.getJsonArray(object, "enchantments")) { String s = JsonUtils.getString(jsonelement, "enchantment"); Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getObject(new ResourceLocation(s)); if (enchantment == null) { throw new JsonSyntaxException("Unknown enchantment \'" + s + "\'"); } list.add(enchantment); } } return new EnchantRandomly(conditionsIn, list); }
public static LootEntryItem deserialize(JsonObject object, JsonDeserializationContext deserializationContext, int weightIn, int qualityIn, LootCondition[] conditionsIn) { String name = net.minecraftforge.common.ForgeHooks.readLootEntryName(object, "item"); Item item = JsonUtils.getItem(object, "name"); LootFunction[] alootfunction; if (object.has("functions")) { alootfunction = (LootFunction[])JsonUtils.deserializeClass(object, "functions", deserializationContext, LootFunction[].class); } else { alootfunction = new LootFunction[0]; } return new LootEntryItem(item, weightIn, qualityIn, alootfunction, conditionsIn, name); }
private static void addPool(LootTable table) { LootEntry common = new LootEntryTable(new ResourceLocation("lootslashconquer:chests/common_chest"), 60, 1, new LootCondition[0], "common"); LootEntry uncommon = new LootEntryTable(new ResourceLocation("lootslashconquer:chests/uncommon_chest"), 25, 1, new LootCondition[0], "uncommon"); LootEntry rare = new LootEntryTable(new ResourceLocation("lootslashconquer:chests/rare_chest"), 10, 1, new LootCondition[0], "rare"); LootEntry legendary = new LootEntryTable(new ResourceLocation("lootslashconquer:chests/legendary_chest"), 5, 1, new LootCondition[0], "legendary"); LootEntry exotic = new LootEntryTable(new ResourceLocation("lootslashconquer:chests/exotic_chest"), 2, 1, new LootCondition[0], "exotic"); LootPool pool = new LootPool(new LootEntry[] { common, uncommon, rare, legendary, exotic }, new LootCondition[0], new RandomValueRange(0, 1), new RandomValueRange(0), "loot"); table.addPool(pool); }
@SubscribeEvent public void addTables(LootTableLoadEvent event){ String name = event.getName().toString(); if(Randores.getConfigObj().getModules().isDungeonLoot()) { if (is(name, chests)) { event.getTable().addPool(new LootPool(new LootEntry[] {new RandoresLootEntry(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().addPool(new LootPool(new LootEntry[] {new RandoresLootEntry(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 RandoresLootEntry(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")); } } }
public void addNotImportantToTable(LootTable table) { List<LootEntry> entrs = new ArrayList<>(); for (PapyrusData p : getPapyruses()) { if (!p.isImportant()) { NBTTagCompound tag = new NBTTagCompound(); tag.setString("papyrus_id", p.getPapyrusId()); entrs.add(new LootEntryItem(ItemRegistry.papyrus, 1, 1, new LootFunction[]{new SetNBT(new LootCondition[]{}, tag)}, new LootCondition[]{}, p.getPapyrusId())); } } table.addPool(new LootPool(entrs.toArray(new LootEntry[]{}), new LootCondition[]{}, new RandomValueRange(0, 1), new RandomValueRange(0), "papyruses")); }
@SubscribeEvent public void onLootTablesLoaded(LootTableLoadEvent event) { if ((event.getName().equals(LootTableList.CHESTS_ABANDONED_MINESHAFT)) || (event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) || (event.getName().equals(LootTableList.CHESTS_DESERT_PYRAMID)) || (event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) || (event.getName().equals(LootTableList.CHESTS_STRONGHOLD_LIBRARY)) || (event.getName().equals(LootTableList.CHESTS_END_CITY_TREASURE))) { LootPool mainPool = event.getTable().getPool("main"); if (mainPool != null) { if (event.getName().equals(LootTableList.CHESTS_ABANDONED_MINESHAFT) || event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE) || event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) { mainPool.addEntry(new LootEntryItem(ModItems.FRIENDER_PEARL, 10, 0, new LootFunction[] {}, new LootCondition[0], ModGlobals.MODID + ":friender_pearl_loot")); } } } }
public LootEntry deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "loot item"); String s = JsonUtils.getString(jsonobject, "type"); int i = JsonUtils.getInt(jsonobject, "weight", 1); int j = JsonUtils.getInt(jsonobject, "quality", 0); LootCondition[] alootcondition; if (jsonobject.has("conditions")) { alootcondition = (LootCondition[])JsonUtils.deserializeClass(jsonobject, "conditions", p_deserialize_3_, LootCondition[].class); } else { alootcondition = new LootCondition[0]; } if ("item".equals(s)) { return LootEntryItem.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition); } else if ("loot_table".equals(s)) { return LootEntryTable.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition); } else if ("empty".equals(s)) { return LootEntryEmpty.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition); } else { throw new JsonSyntaxException("Unknown loot entry type \'" + s + "\'"); } }
public LootPool(LootEntry[] lootEntriesIn, LootCondition[] poolConditionsIn, RandomValueRange rollsIn, RandomValueRange bonusRollsIn) { this.lootEntries = lootEntriesIn; this.poolConditions = poolConditionsIn; this.rolls = rollsIn; this.bonusRolls = bonusRollsIn; }
public LootPool deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "loot pool"); LootEntry[] alootentry = (LootEntry[])JsonUtils.deserializeClass(jsonobject, "entries", p_deserialize_3_, LootEntry[].class); LootCondition[] alootcondition = (LootCondition[])JsonUtils.deserializeClass(jsonobject, "conditions", new LootCondition[0], p_deserialize_3_, LootCondition[].class); RandomValueRange randomvaluerange = (RandomValueRange)JsonUtils.deserializeClass(jsonobject, "rolls", p_deserialize_3_, RandomValueRange.class); RandomValueRange randomvaluerange1 = (RandomValueRange)JsonUtils.deserializeClass(jsonobject, "bonus_rolls", new RandomValueRange(0.0F, 0.0F), p_deserialize_3_, RandomValueRange.class); return new LootPool(alootentry, alootcondition, randomvaluerange, randomvaluerange1); }
public SetNBT deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { try { NBTTagCompound nbttagcompound = JsonToNBT.getTagFromJson(JsonUtils.getString(object, "tag")); return new SetNBT(conditionsIn, nbttagcompound); } catch (NBTException nbtexception) { throw new JsonSyntaxException(nbtexception); } }
private static void replaceCookedWithCharred(LootPool targetPool, Item targetItem, ItemStack replacementStack, int minCount, int maxCount) { List<LootFunction> charredFunctions = Lists.newArrayList(); if(replacementStack.getItemDamage() != 0) charredFunctions.add(LootUtil.createSetMetadata(replacementStack.getItemDamage())); if(replacementStack.getTagCompound() != null) charredFunctions.add(LootUtil.createSetNBT(replacementStack.getTagCompound())); charredFunctions.add(LootUtil.createCountFunction(minCount, maxCount)); charredFunctions.add(LootUtil.createLootingFunc(0, 1)); LootCondition notOnFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(false)}, EntityTarget.THIS); LootCondition onFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(true)}, EntityTarget.THIS); targetPool.removeEntry(targetItem.getRegistryName().toString()); targetPool.addEntry(new LootEntryItem(targetItem, 1, 1, new LootFunction[] {LootUtil.createCountFunction(1, 3), LootUtil.createLootingFunc(0, 1)}, new LootCondition[] {notOnFire}, targetItem.getRegistryName().toString())); targetPool.addEntry(new LootEntryItem(replacementStack.getItem(), 1, 1, charredFunctions.toArray(new LootFunction[charredFunctions.size()]), new LootCondition[] {onFire}, ModMain.MODID + ":charred_+" + targetItem.getRegistryName().getResourcePath().toString())); }
private void removeSmeltFunction(LootPool pool, Item targetItem, Item replacement, int minCount, int maxCount) { LootCondition notOnFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(false)}, EntityTarget.THIS); LootCondition onFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(true)}, EntityTarget.THIS); pool.removeEntry(targetItem.getRegistryName().toString()); pool.addEntry(new LootEntryItem(targetItem, 1, 1, new LootFunction[] {LootUtil.createCountFunction(1, 3), LootUtil.createLootingFunc(0, 1)}, new LootCondition[] {notOnFire}, targetItem.getRegistryName().toString())); pool.addEntry(new LootEntryItem(replacement, 1, 1, new LootFunction[] {LootUtil.createCountFunction(1, 3), LootUtil.createLootingFunc(0, 1)}, new LootCondition[] {onFire}, replacement.getRegistryName().toString())); }
protected LootEntry(int weightIn, int qualityIn, LootCondition[] conditionsIn, String entryName) { this.weight = weightIn; this.quality = qualityIn; this.conditions = conditionsIn; this.entryName = entryName; }
public LootEntry deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "loot item"); String s = JsonUtils.getString(jsonobject, "type"); int i = JsonUtils.getInt(jsonobject, "weight", 1); int j = JsonUtils.getInt(jsonobject, "quality", 0); LootCondition[] alootcondition; if (jsonobject.has("conditions")) { alootcondition = (LootCondition[])JsonUtils.deserializeClass(jsonobject, "conditions", p_deserialize_3_, LootCondition[].class); } else { alootcondition = new LootCondition[0]; } LootEntry ret = net.minecraftforge.common.ForgeHooks.deserializeJsonLootEntry(s, jsonobject, i, j, alootcondition); if (ret != null) return ret; if ("item".equals(s)) { return LootEntryItem.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition); } else if ("loot_table".equals(s)) { return LootEntryTable.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition); } else if ("empty".equals(s)) { return LootEntryEmpty.deserialize(jsonobject, p_deserialize_3_, i, j, alootcondition); } else { throw new JsonSyntaxException("Unknown loot entry type \'" + s + "\'"); } }
public LootPool(LootEntry[] lootEntriesIn, LootCondition[] poolConditionsIn, RandomValueRange rollsIn, RandomValueRange bonusRollsIn, String name) { this.lootEntries = Lists.newArrayList(lootEntriesIn); this.poolConditions = Lists.newArrayList(poolConditionsIn); this.rolls = rollsIn; this.bonusRolls = bonusRollsIn; this.name = name; }
public LootPool deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "loot pool"); String name = net.minecraftforge.common.ForgeHooks.readPoolName(jsonobject); LootEntry[] alootentry = (LootEntry[])JsonUtils.deserializeClass(jsonobject, "entries", p_deserialize_3_, LootEntry[].class); LootCondition[] alootcondition = (LootCondition[])JsonUtils.deserializeClass(jsonobject, "conditions", new LootCondition[0], p_deserialize_3_, LootCondition[].class); RandomValueRange randomvaluerange = (RandomValueRange)JsonUtils.deserializeClass(jsonobject, "rolls", p_deserialize_3_, RandomValueRange.class); RandomValueRange randomvaluerange1 = (RandomValueRange)JsonUtils.deserializeClass(jsonobject, "bonus_rolls", new RandomValueRange(0.0F, 0.0F), p_deserialize_3_, RandomValueRange.class); return new LootPool(alootentry, alootcondition, randomvaluerange, randomvaluerange1, name); }
@SubscribeEvent public void lootTableLoad(final LootTableLoadEvent event) { if (NemesisConfig.DISCOVERY_ENABLED && isLootTarget(event)) { // TODO improve roll settings String name = LOOT_TABLE.toString(); LootEntry entry = new LootEntryTable(LOOT_TABLE, 1, 0, new LootCondition[0], name); RandomValueRange rolls = new RandomValueRange(0, 1); LootPool pool = new LootPool(new LootEntry[] { entry }, new LootCondition[0], rolls, rolls, name); event.getTable().addPool(pool); } }
protected CreateCommon(LootCondition[] conditionsIn) { super(conditionsIn); }
public CreateCommon deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { return new CreateCommon(conditionsIn); }
protected CreateStats(LootCondition[] conditionsIn) { super(conditionsIn); }
public CreateStats deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { return new CreateStats(conditionsIn); }
protected CreateLegendary(LootCondition[] conditionsIn) { super(conditionsIn); }
public CreateLegendary deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { return new CreateLegendary(conditionsIn); }
protected CreateUncommon(LootCondition[] conditionsIn) { super(conditionsIn); }
public CreateUncommon deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { return new CreateUncommon(conditionsIn); }
protected CreateRare(LootCondition[] conditionsIn) { super(conditionsIn); }
public CreateRare deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { return new CreateRare(conditionsIn); }
protected CreateExotic(LootCondition[] conditionsIn) { super(conditionsIn); }
public CreateExotic deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { return new CreateExotic(conditionsIn); }
protected CreateSpecial(LootCondition[] conditionsIn) { super(conditionsIn); }