use of net.minecraft.world.storage.loot.conditions.RandomChance in project EnderIO by SleepyTrousers.
the class LootManager method createDarkSteelLootEntry.
@Nonnull
private LootEntry createDarkSteelLootEntry(@Nonnull Item item, int meta, int minStackSize, int maxStackSize, float chance) {
LootCondition[] chanceCond = new LootCondition[] { new RandomChance(chance) };
final ResourceLocation registryName = NullHelper.notnull(item.getRegistryName(), "found unregistered item");
return new LootEntryItem(item, 1, 1, new LootFunction[] { setCount(minStackSize, maxStackSize), setDamage(item, meta), setUpgrades(), setEnergy() }, chanceCond, registryName.toString() + ":" + meta);
}
use of net.minecraft.world.storage.loot.conditions.RandomChance in project EnderIO by SleepyTrousers.
the class LootManager method createLootEntry.
@Nonnull
private LootEntry createLootEntry(@Nonnull ItemStack stack, int minStackSize, int maxStackSize, float chance) {
LootCondition[] chanceCond = new LootCondition[] { new RandomChance(chance) };
final ResourceLocation registryName = NullHelper.notnull(stack.getItem().getRegistryName(), "found unregistered item");
return new LootEntryItem(stack.getItem(), 1, 1, new LootFunction[] { setCount(minStackSize, maxStackSize), setMetadata(stack.getMetadata()) }, chanceCond, registryName.toString() + ":" + stack.getMetadata());
}
use of net.minecraft.world.storage.loot.conditions.RandomChance in project EnderIO by SleepyTrousers.
the class LootManager method onLootTableLoad.
@SubscribeEvent
public void onLootTableLoad(@Nonnull LootTableLoadEvent evt) {
LootTable table = evt.getTable();
LootPool lp = new LootPool(new LootEntry[0], NO_CONDITIONS, new RandomValueRange(1, 3), new RandomValueRange(0, 0), EnderIO.MOD_NAME);
if (evt.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) {
lp.addEntry(createLootEntry(Alloy.DARK_STEEL.getStackIngot(), 1, 3, 0.25F));
lp.addEntry(createLootEntry(itemConduitProbe.getItemNN(), 0.10F));
lp.addEntry(createLootEntry(Items.QUARTZ, 3, 16, 0.25F));
lp.addEntry(createLootEntry(Items.NETHER_WART, 1, 4, 0.20F));
lp.addEntry(createLootEntry(Items.ENDER_PEARL, 1, 2, 0.30F));
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelSword.getItemNN(), 0.1F));
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelBoots.getItemNN(), 0.1F));
lp.addEntry(createLootEntry(Material.GEAR_WOOD.getStack(), 1, 2, 0.5F));
lp.addEntry(createLootCapacitor(0.15F));
lp.addEntry(createLootCapacitor(0.15F));
lp.addEntry(createLootCapacitor(0.15F));
} else if (evt.getName().equals(LootTableList.CHESTS_ABANDONED_MINESHAFT)) {
lp.addEntry(createLootEntry(Alloy.DARK_STEEL.getStackIngot(), 1, 3, 0.05F));
lp.addEntry(createLootEntry(Items.ENDER_PEARL, 1, 2, 0.10F));
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelSword.getItemNN(), 0.2F));
lp.addEntry(createLootEntry(Material.GEAR_WOOD.getStack(), 1, 2, 0.5F));
lp.addEntry(createLootCapacitor(0.15F));
lp.addEntry(createLootCapacitor(0.05F));
lp.addEntry(createLootEntry(ModObject.blockExitRail.getItemNN(), 1, 2, 0.15F));
} else if (evt.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) {
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelBoots.getItemNN(), 0.1F));
lp.addEntry(createLootEntry(Material.GEAR_IRON.getStack(), 1, 2, 0.5F));
lp.addEntry(createLootCapacitor(0.15F));
} else if (evt.getName().equals(LootTableList.CHESTS_IGLOO_CHEST)) {
final CapturedMob polarBear = CapturedMob.create(new ResourceLocation("minecraft", "polar_bear"));
if (polarBear != null) {
lp.addEntry(new LootEntryItem(ModObject.itemSoulVial.getItemNN(), 1, 1, new LootFunction[] { setCount(1, 1), new SetNBT(NO_CONDITIONS, polarBear.toNbt(null)) }, new LootCondition[] { new RandomChance(.2F) }, "PolarBearSoulVial"));
}
lp.addEntry(createLootEntry(ModObject.itemSoulVial.getItemNN(), 1, 3, 0.5F));
lp.addEntry(createLootCapacitor(0.05F));
} else if (evt.getName().equals(LootTableList.CHESTS_JUNGLE_TEMPLE_DISPENSER)) {
ItemStack bucket = Fluids.FIRE_WATER.getBucket();
lp.addEntry(new LootEntryItem(bucket.getItem(), 1, 1, new LootFunction[] { setCount(1, 1), setMetadata(bucket.getMetadata()), setNBT(bucket) }, new LootCondition[] { new RandomChance(.05F) }, bucket.getItem().getUnlocalizedName() + ":" + bucket.getMetadata()));
} else if (evt.getName().equals(LootTableList.CHESTS_VILLAGE_BLACKSMITH)) {
lp.addEntry(createLootEntry(Alloy.ELECTRICAL_STEEL.getStackIngot(), 2, 6, 0.20F));
lp.addEntry(createLootEntry(Alloy.REDSTONE_ALLOY.getStackIngot(), 3, 6, 0.35F));
lp.addEntry(createLootEntry(Alloy.DARK_STEEL.getStackIngot(), 3, 6, 0.35F));
lp.addEntry(createLootEntry(Alloy.PULSATING_IRON.getStackIngot(), 1, 2, 0.3F));
lp.addEntry(createLootEntry(Alloy.VIBRANT_ALLOY.getStackIngot(), 1, 2, 0.2F));
lp.addEntry(createLootEntry(Material.GEAR_WOOD.getStack(), 1, 2, 0.5F));
lp.addEntry(createLootEntry(Material.GEAR_STONE.getStack(), 1, 2, 0.4F));
lp.addEntry(createLootEntry(Material.GEAR_IRON.getStack(), 1, 2, 0.25F));
lp.addEntry(createLootEntry(Material.GEAR_ENERGIZED.getStack(), 1, 2, 0.125F));
lp.addEntry(createLootEntry(Material.GEAR_VIBRANT.getStack(), 1, 2, 0.0625F));
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelSword.getItemNN(), 1, 1, 0.25F));
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelBoots.getItemNN(), 1, 1, 0.25F));
lp.addEntry(createLootCapacitor(0.1F));
} else if (evt.getName().equals(LootTableList.CHESTS_DESERT_PYRAMID)) {
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelSword.getItemNN(), 0.2F));
lp.addEntry(createLootEntry(Material.GEAR_VIBRANT.getStack(), 1, 2, 0.0625F));
lp.addEntry(createLootEntry(itemTravelStaff.getItemNN(), 0.1F));
lp.addEntry(createLootCapacitor(25));
} else if (evt.getName().equals(LootTableList.CHESTS_JUNGLE_TEMPLE)) {
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelSword.getItemNN(), 1, 1, 0.25F));
lp.addEntry(createLootEntry(itemTravelStaff.getItemNN(), 1, 1, 0.1F));
lp.addEntry(createLootCapacitor(0.25F));
lp.addEntry(createLootCapacitor(0.25F));
} else if (evt.getName().equals(LootTableList.CHESTS_WOODLAND_MANSION)) {
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelBow.getItemNN(), 1, 1, 0.25F));
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelAxe.getItemNN(), 1, 1, 0.25F));
lp.addEntry(createLootEntry(Material.GEAR_STONE.getStack(), 1, 2, 0.4F));
lp.addEntry(createLootCapacitor(0.25F));
lp.addEntry(createLootEntry(itemTravelStaff.getItemNN(), 1, 1, 0.1F));
} else if (evt.getName().equals(LootTableList.CHESTS_END_CITY_TREASURE)) {
final CapturedMob shulker = CapturedMob.create(new ResourceLocation("minecraft", "shulker"));
if (shulker != null) {
lp.addEntry(new LootEntryItem(ModObject.itemSoulVial.getItemNN(), 1, 1, new LootFunction[] { setCount(1, 1), new SetNBT(NO_CONDITIONS, shulker.toNbt(null)) }, new LootCondition[] { new RandomChance(.2F) }, "ShulkerSoulVial"));
}
lp.addEntry(createLootEntry(ModObject.itemSoulVial.getItemNN(), 1, 3, 0.5F));
lp.addEntry(createLootEntry(Material.GEAR_ENERGIZED.getStack(), 1, 2, 0.125F));
lp.addEntry(createLootEntry(Material.GEAR_VIBRANT.getStack(), 1, 2, 0.125F));
lp.addEntry(createLootCapacitor(0.05F));
lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelBow.getItemNN(), 1, 1, 0.25F));
} else {
return;
}
if (table.isFrozen()) {
throw new RuntimeException("Some other mod (a list of suspects is printed in the log file) put a frozen loot table into the load event for loot table '" + evt.getName() + "'. This is a bug in that other mod. Ender IO is the victim here. Don't blame the victim!");
}
table.addPool(lp);
}
use of net.minecraft.world.storage.loot.conditions.RandomChance in project EnderIO by SleepyTrousers.
the class LootManager method createLootEntry.
/*
* All loot entries are given the same weight, the generation probabilities depend on the RandomChance condition.
*/
@Nonnull
private LootEntry createLootEntry(@Nonnull Item item, int meta, int minStackSize, int maxStackSize, float chance) {
LootCondition[] chanceCond = new LootCondition[] { new RandomChance(chance) };
final ResourceLocation registryName = NullHelper.notnull(item.getRegistryName(), "found unregistered item");
if (item.isDamageable()) {
return new LootEntryItem(item, 1, 1, new LootFunction[] { setCount(minStackSize, maxStackSize), setDamage(item, meta), setEnergy() }, chanceCond, registryName.toString() + ":" + meta);
} else {
return new LootEntryItem(item, 1, 1, new LootFunction[] { setCount(minStackSize, maxStackSize), setMetadata(meta) }, chanceCond, registryName.toString() + ":" + meta);
}
}
use of net.minecraft.world.storage.loot.conditions.RandomChance in project Random-Things by lumien231.
the class RTEventHandler method loadLootTable.
@SubscribeEvent
public void loadLootTable(LootTableLoadEvent event) {
LootTable table = event.getTable();
if (event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) {
if (Worldgen.LAVA_CHARM)
addSingleItemWithChance("lavaCharm", table, ModItems.lavaCharm, 0.1f);
if (Worldgen.SUMMONING_PENDULUM)
addSingleItemWithChance("summoningPendulum", table, ModItems.summoningPendulum, 0.1f);
if (Worldgen.MAGIC_HOOD)
addSingleItemWithChance("magicHood", table, ModItems.magicHood, 0.15f);
if (Worldgen.SLIME_CUBE)
addSingleItemWithChance("slimeCube", table, Item.getItemFromBlock(ModBlocks.slimeCube), 0.3f);
} else if (Worldgen.LAVA_CHARM && event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) {
addSingleItemWithChance("lavaCharm", table, ModItems.lavaCharm, 0.3f);
} else if (Worldgen.MAGIC_HOOD && event.getName().equals(LootTableList.CHESTS_VILLAGE_BLACKSMITH)) {
addSingleItemWithChance("magicHood", table, ModItems.magicHood, 0.02f);
} else if (Worldgen.SUMMONING_PENDULUM && event.getName().equals(LootTableList.CHESTS_STRONGHOLD_CORRIDOR)) {
addSingleItemWithChance("summoningPendulum", table, ModItems.summoningPendulum, 0.5f);
} else if (Worldgen.SLIME_CUBE && event.getName().equals(LootTableList.CHESTS_JUNGLE_TEMPLE)) {
addSingleItemWithChance("slimeCube", table, Item.getItemFromBlock(ModBlocks.slimeCube), 0.8f);
}
if (Worldgen.BIOME_CRYSTAL && event.getName().toString().startsWith("minecraft:chests/")) {
LootEntry crystalEntry = new LootEntryItem(ModItems.biomeCrystal, 1, 0, new LootFunction[] { new LootFunction(new LootCondition[] {}) {
@Override
public ItemStack apply(ItemStack stack, Random rand, LootContext context) {
Object[] locationArray = Biome.REGISTRY.getKeys().toArray();
ResourceLocation randomLocation = (ResourceLocation) locationArray[rand.nextInt(locationArray.length)];
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setString("biomeName", randomLocation.toString());
return stack;
}
} }, new LootCondition[] {}, "randomthings:biomeCrystal");
LootPool crystalPool = new LootPool(new LootEntry[] { crystalEntry }, new LootCondition[] { new RandomChance(0.2f) }, new RandomValueRange(1, 1), new RandomValueRange(0, 0), "randomthings:biomeCrystal");
table.addPool(crystalPool);
}
}
Aggregations