@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")); } }
public boolean testCondition(Random rand, LootContext context) { Entity entity = context.getEntity(this.target); if (entity == null) { return false; } else { Scoreboard scoreboard = entity.world.getScoreboard(); for (Entry<String, RandomValueRange> entry : this.scores.entrySet()) { if (!this.entityScoreMatch(entity, scoreboard, (String)entry.getKey(), (RandomValueRange)entry.getValue())) { return false; } } return true; } }
public boolean testCondition(Random rand, LootContext context) { Entity entity = context.getEntity(this.target); if (entity == null) { return false; } else { Scoreboard scoreboard = entity.worldObj.getScoreboard(); for (Entry<String, RandomValueRange> entry : this.scores.entrySet()) { if (!this.entityScoreMatch(entity, scoreboard, (String)entry.getKey(), (RandomValueRange)entry.getValue())) { return false; } } return true; } }
protected List<ItemStack> getToxicWaterCatch(Set<BiomeDictionary.Type> biomeTypesList) { List<ItemStack> tempList = new ArrayList<>(); int chance = this.rand.nextInt(100) + Math.round(luck); if (chance < 50) { tempList.add(new ItemStack(Items.BONE)); tempList.add(new ItemStack(Items.ROTTEN_FLESH)); tempList.add(new ItemStack(Items.SPIDER_EYE)); tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.GREEN_JELLYFISH.ordinal())); tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.BONE_FISH.ordinal())); } else if (chance < 80) { tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.SPOOKYFIN.ordinal())); } else if (chance < 95) { tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.CURSED_KOI.ordinal())); } else { if (chance < 98) { tempList.add(new ItemStack(Blocks.SKULL, 1, 0)); // SKELETON tempList.add(new ItemStack(Blocks.SKULL, 1, 2)); // ZOMBIE } else { EnchantmentHelper.addRandomEnchantment(rand, new ItemStack(GSItem.ENCHANTED_SKULL, 1, 0), new RandomValueRange(30, 40).generateInt(rand), true); } } return tempList; }
@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; } } if (enableChestLoot) { onLootChestTableLoad(main, event); } }
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")); } } }
protected boolean entityScoreMatch(Entity entityIn, Scoreboard scoreboardIn, String objectiveStr, RandomValueRange rand) { ScoreObjective scoreobjective = scoreboardIn.getObjective(objectiveStr); if (scoreobjective == null) { return false; } else { String s = entityIn instanceof EntityPlayerMP ? entityIn.getName() : entityIn.getCachedUniqueIdString(); return !scoreboardIn.entityHasObjective(s, scoreobjective) ? false : rand.isInRange(scoreboardIn.getOrCreateScore(s, scoreobjective).getScorePoints()); } }
public void serialize(JsonObject json, EntityHasScore value, JsonSerializationContext context) { JsonObject jsonobject = new JsonObject(); for (Entry<String, RandomValueRange> entry : value.scores.entrySet()) { jsonobject.add((String)entry.getKey(), context.serialize(entry.getValue())); } json.add("scores", jsonobject); json.add("entity", context.serialize(value.target)); }
public EntityHasScore deserialize(JsonObject json, JsonDeserializationContext context) { Set<Entry<String, JsonElement>> set = JsonUtils.getJsonObject(json, "scores").entrySet(); Map<String, RandomValueRange> map = Maps.<String, RandomValueRange>newLinkedHashMap(); for (Entry<String, JsonElement> entry : set) { map.put(entry.getKey(), JsonUtils.deserializeClass((JsonElement)entry.getValue(), "score", context, RandomValueRange.class)); } return new EntityHasScore(map, (LootContext.EntityTarget)JsonUtils.deserializeClass(json, "entity", context, LootContext.EntityTarget.class)); }
private Modifier(String modifName, String attrName, int operationIn, RandomValueRange randomAmount, EntityEquipmentSlot[] slotsIn, @Nullable UUID uuidIn) { this.modifierName = modifName; this.attributeName = attrName; this.operation = operationIn; this.amount = randomAmount; this.uuid = uuidIn; this.slots = slotsIn; }
@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); } }
/** * Converts a LootTable to a list of possible drops, only looks for Item and metadata. * @param table the loot table to get items from * @return a LinkedList of the stacks in the loot table */ public static List<ItemStack> tableToItemStacks(LootTable table){ List<ItemStack> stacks = new LinkedList<>(); for(LootPool p:getPools(table)){ for(LootEntry entry:getEntries(p)){ if(entry instanceof LootEntryItem){ LootEntryItem ei = (LootEntryItem)entry; Item item = getItem(ei); LootFunction[] functs = getFunctions(ei); boolean metaSet = false; for(LootFunction func:functs){ if(func instanceof SetMetadata){ metaSet=true; RandomValueRange range = (RandomValueRange)ReflectionHelper.getPrivateValue(SetMetadata.class, (SetMetadata)func, "metaRange","field_186573_b"); int meta = MathHelper.floor(range.getMin()); stacks.add(new ItemStack(item,1,meta)); } } if(!metaSet)stacks.add(new ItemStack(item)); } /* won't bother with this case for now else if(entry instanceof LootEntryTable){ //restart with that table ResourceLocation location = (ResourceLocation) ReflectionHelper.getPrivateValue(LootEntryTable.class, (LootEntryTable)entry, "table","field_186371_a"); } */ } } return stacks; }
@Override protected List<ItemStack> getLavaCatch(Set<BiomeDictionary.Type> biomeTypesList) { List<ItemStack> tempList = new ArrayList<>(); int chance = this.rand.nextInt(100) + Math.round(luck); if (!biomeTypesList.contains(BiomeDictionary.Type.NETHER)) { if (chance < 80) { tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.OBSIDIFISH.ordinal())); } else if (chance < 95) { tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.MAGMA_JELLYFISH.ordinal())); } else { if (chance < 98) { tempList.add(new ItemStack(Blocks.SKULL, 1, 1)); //WITHER SKULL } else { EnchantmentHelper.addRandomEnchantment(rand, new ItemStack(GSItem.ENCHANTED_SKULL, 1, 1), new RandomValueRange(40, 50).generateInt(rand), true); } } } else { if (chance < 40) { tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.NETHER_SALMON.ordinal())); } else if (chance < 80) { tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.MAGMA_JELLYFISH.ordinal())); tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.QUARTZ_COD.ordinal())); tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.WITHERED_CRUCIAN.ordinal())); } else if (chance < 95) { tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.FLAREFIN_KOI.ordinal())); tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.BLAZE_COD.ordinal())); } else { if (chance < 98) { tempList.add(new ItemStack(Blocks.SKULL, 1, 1)); //WITHER SKULL } else { EnchantmentHelper.addRandomEnchantment(rand, new ItemStack(GSItem.ENCHANTED_SKULL, 1, 1), new RandomValueRange(40, 50).generateInt(rand), true); } } } return tempList; }
@SubscribeEvent public void onLootTablesLoaded (LootTableLoadEvent event) { // Checks to see if the loot table being loaded is the basic dungeon chest. if (event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) { // Gets pool2 from the loot table. This pool is where common loot like zombie flesh // bones and string goes. final LootPool pool2 = event.getTable().getPool("pool2"); // Makes sure the pool has not been deleted. if (pool2 != null) { // Adds cookies to the loot pool. Has a weight of 10 and spawns in stacks of 1 // to 5. pool2.addEntry(new LootEntryItem(Items.COOKIE, 10, 0, new LootFunction[] { new SetCount(new LootCondition[0], new RandomValueRange(1, 5)) }, new LootCondition[0], "tutorial:cookie")); // Adds Lime Green Dye to the loot pool. Has a weight of 10. pool2.addEntry(new LootEntryItem(Items.DYE, 10, 0, new LootFunction[] { new SetDamage(new LootCondition[0], new RandomValueRange(10, 10)) }, new LootCondition[0], "tutorial:dyes")); } } // Checks to see if the loot table being loaded is for the mob we are looking for if (event.getName().equals(LootTableList.ENTITIES_PIG)) { // Gets main from the loot table. This pool is where the basic drops like porkchop are. final LootPool main = event.getTable().getPool("main"); // Makes sure that the main pool actually exists. It can be deleted by other mods. if (main != null) { // Adds a carrot to the pool. Carrots will now drop just as often as pork chops. main.addEntry(new LootEntryItem(Items.CARROT, 1, 0, new LootFunction[0], new LootCondition[0], "tutorial:carrot")); // Adds an apple to the loot pool. This entry is only used if the pig was killed by a player. main.addEntry(new LootEntryItem(Items.APPLE, 1, 0, new LootFunction[0], new LootCondition[] { new KilledByPlayer(false)}, "tutorial:player")); } } }
@SubscribeEvent public void onLootTableLoad (LootTableLoadEvent event) { if (allowDungeonLoot && event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) { final LootPool main = event.getTable().getPool("main"); if (main != null) { main.addEntry(new LootEntryItem(itemRing, weight, 0, new LootFunction[] { new SetDamage(new LootCondition[0], new RandomValueRange(0, ItemRing.varients.length - 1)) }, new LootCondition[0], "darkutils:nether_rings")); } } }
@SubscribeEvent public void onLootTableLoad(LootTableLoadEvent event) { String name = event.getName().toString(); if (name.startsWith("minecraft:chests/simple_dungeon") || name.startsWith("minecraft:chests/desert_pyramid") || name.startsWith("minecraft:chests/jungle_temple")) { event.getTable().addPool(new LootPool(new LootEntry[] { new LootEntryTable(new ResourceLocation(Allomancy.MODID, "inject/lerasium"), 1, 0, new LootCondition[0], "allomancy_inject_entry") }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "allomancy_inject_pool")); } }
protected RandoresLootEntry(int weightIn, int qualityIn, boolean doEnchant, int minLevel, int maxLevel, LootCondition[] conditionsIn, String entryName) { super(weightIn, qualityIn, conditionsIn, entryName); if (doEnchant) { this.enchantFunc = new EnchantWithLevels(new LootCondition[0], new RandomValueRange(minLevel, maxLevel), true); } }
public EntityHasScore(Map<String, RandomValueRange> scoreIn, LootContext.EntityTarget targetIn) { this.scores = scoreIn; this.target = targetIn; }
public static SetAttributes.Modifier deserialize(JsonObject jsonObj, JsonDeserializationContext context) { String s = JsonUtils.getString(jsonObj, "name"); String s1 = JsonUtils.getString(jsonObj, "attribute"); int i = getOperationFromInt(JsonUtils.getString(jsonObj, "operation")); RandomValueRange randomvaluerange = (RandomValueRange)JsonUtils.deserializeClass(jsonObj, "amount", context, RandomValueRange.class); UUID uuid = null; EntityEquipmentSlot[] aentityequipmentslot; if (JsonUtils.isString(jsonObj, "slot")) { aentityequipmentslot = new EntityEquipmentSlot[] {EntityEquipmentSlot.fromString(JsonUtils.getString(jsonObj, "slot"))}; } else { if (!JsonUtils.isJsonArray(jsonObj, "slot")) { throw new JsonSyntaxException("Invalid or missing attribute modifier slot; must be either string or array of strings."); } JsonArray jsonarray = JsonUtils.getJsonArray(jsonObj, "slot"); aentityequipmentslot = new EntityEquipmentSlot[jsonarray.size()]; int j = 0; for (JsonElement jsonelement : jsonarray) { aentityequipmentslot[j++] = EntityEquipmentSlot.fromString(JsonUtils.getString(jsonelement, "slot")); } if (aentityequipmentslot.length == 0) { throw new JsonSyntaxException("Invalid attribute modifier slot; must contain at least one entry."); } } if (jsonObj.has("id")) { String s2 = JsonUtils.getString(jsonObj, "id"); try { uuid = UUID.fromString(s2); } catch (IllegalArgumentException var12) { throw new JsonSyntaxException("Invalid attribute modifier id \'" + s2 + "\' (must be UUID format, with dashes)"); } } return new SetAttributes.Modifier(s, s1, i, randomvaluerange, aentityequipmentslot, uuid); }
public EnchantWithLevels(LootCondition[] conditionsIn, RandomValueRange randomRange, boolean p_i46627_3_) { super(conditionsIn); this.randomLevel = randomRange; this.isTreasure = p_i46627_3_; }
public EnchantWithLevels deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { RandomValueRange randomvaluerange = (RandomValueRange)JsonUtils.deserializeClass(object, "levels", deserializationContext, RandomValueRange.class); boolean flag = JsonUtils.getBoolean(object, "treasure", false); return new EnchantWithLevels(conditionsIn, randomvaluerange, flag); }
public SetCount(LootCondition[] conditionsIn, RandomValueRange countRangeIn) { super(conditionsIn); this.countRange = countRangeIn; }
public SetCount deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { return new SetCount(conditionsIn, (RandomValueRange)JsonUtils.deserializeClass(object, "count", deserializationContext, RandomValueRange.class)); }
public SetMetadata(LootCondition[] conditionsIn, RandomValueRange metaRangeIn) { super(conditionsIn); this.metaRange = metaRangeIn; }
public SetMetadata deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { return new SetMetadata(conditionsIn, (RandomValueRange)JsonUtils.deserializeClass(object, "data", deserializationContext, RandomValueRange.class)); }
public LootingEnchantBonus(LootCondition[] p_i47145_1_, RandomValueRange p_i47145_2_, int p_i47145_3_) { super(p_i47145_1_); this.count = p_i47145_2_; this.limit = p_i47145_3_; }
public LootingEnchantBonus deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { int i = JsonUtils.getInt(object, "limit", 0); return new LootingEnchantBonus(conditionsIn, (RandomValueRange)JsonUtils.deserializeClass(object, "count", deserializationContext, RandomValueRange.class), i); }
public SetDamage(LootCondition[] conditionsIn, RandomValueRange damageRangeIn) { super(conditionsIn); this.damageRange = damageRangeIn; }
public SetDamage deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { return new SetDamage(conditionsIn, (RandomValueRange)JsonUtils.deserializeClass(object, "damage", deserializationContext, RandomValueRange.class)); }
public RandomWeaponFunction(LootCondition[] conditionsIn, RandomValueRange range, float valve) { super(conditionsIn); this.upgradeRange=range; this.valveWepChance=valve; }
@Override public RandomWeaponFunction deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditionsIn) { return new RandomWeaponFunction(conditionsIn, (RandomValueRange)JsonUtils.deserializeClass(object, "upgrade_range", deserializationContext, RandomValueRange.class), object.get("valve_chance").getAsFloat()); }
public static LootPool getLootPool(ResourceLocation res){ return new LootPool(new LootEntry[]{new LootEntryTable(res, 1, 0, new LootCondition[0], "combined")}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0), "combined"); }
public static SetCount createCountFunction(float min,float max, LootCondition... conditionsIn) { return new SetCount(conditionsIn, new RandomValueRange(min, max)); }
public static LootingEnchantBonus createLootingFunc(float min, float max, int limit, LootCondition... conditionsIn) { return new LootingEnchantBonus(conditionsIn, new RandomValueRange(min, max), limit); }