From 45047be17b9e5045aeeb7b12ddb6b66962f643f1 Mon Sep 17 00:00:00 2001 From: TheDoctorSoda Date: Tue, 23 Feb 2016 21:26:57 -0800 Subject: [PATCH] Added loot and rubber tree configs --- .../techreborn/config/ConfigTechReborn.java | 32 ++++++++- src/main/java/techreborn/init/ModLoot.java | 38 +++++++--- .../java/techreborn/world/DungeonLoot.java | 21 ------ .../java/techreborn/world/TreeGenerator.java | 71 ++++++++++--------- 4 files changed, 96 insertions(+), 66 deletions(-) delete mode 100644 src/main/java/techreborn/world/DungeonLoot.java diff --git a/src/main/java/techreborn/config/ConfigTechReborn.java b/src/main/java/techreborn/config/ConfigTechReborn.java index d83e7aea2..bade5c404 100644 --- a/src/main/java/techreborn/config/ConfigTechReborn.java +++ b/src/main/java/techreborn/config/ConfigTechReborn.java @@ -66,6 +66,16 @@ public class ConfigTechReborn { public static double FortuneSecondaryOreMultiplierPerLevel; + public static boolean RubberTreeGen; + + public static boolean RubberSaplingLoot; + + public static boolean TinIngotsLoot; + + public static boolean CopperIngotsLoot; + + public static boolean SteelIngotsLoot; + // Power public static int ThermalGenertaorOutput; public static int CentrifugeInputTick; @@ -246,7 +256,27 @@ public class ConfigTechReborn { .getBoolean(true); SodaliteOreTrue = config - .get(CATEGORY_WORLD, "Sodalite Peridot Ore", true, "Allow Sodalite Ore to generate in world") + .get(CATEGORY_WORLD, "Generate Sodalite Ore", true, "Allow Sodalite Ore to generate in world") + .getBoolean(true); + + RubberTreeGen = config + .get(CATEGORY_WORLD, "Rubber Tree Generation", true, "Allow Rubber Trees to generate in world") + .getBoolean(true); + + RubberSaplingLoot = config + .get(CATEGORY_WORLD, "Rubber Sapling Loot", true, "Allow Rubber Saplings to generate in loot chests") + .getBoolean(true); + + CopperIngotsLoot = config + .get(CATEGORY_WORLD, "Copper Ingots Loot", true, "Allow Copper Ingots to generate in loot chests") + .getBoolean(true); + + TinIngotsLoot = config + .get(CATEGORY_WORLD, "Tin Ingots Loot", true, "Allow Tin Ingots to generate in loot chests") + .getBoolean(true); + + SteelIngotsLoot = config + .get(CATEGORY_WORLD, "Steel Ingots Loot", true, "Allow Steel Ingots to generate in loot chests") .getBoolean(true); GalenaOreRare = config.get(CATEGORY_WORLD, "Galena Ore vein size", 8, "Set the max vein size for Galena Ore") diff --git a/src/main/java/techreborn/init/ModLoot.java b/src/main/java/techreborn/init/ModLoot.java index a5f5a7793..d2fbcec1e 100644 --- a/src/main/java/techreborn/init/ModLoot.java +++ b/src/main/java/techreborn/init/ModLoot.java @@ -1,23 +1,39 @@ package techreborn.init; +import java.util.Arrays; + +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandomChestContent; import net.minecraftforge.common.ChestGenHooks; +import techreborn.config.ConfigTechReborn; import techreborn.items.ItemIngots; public class ModLoot { - public static WeightedRandomChestContent rubberSaplingLoot = new WeightedRandomChestContent(new ItemStack(ModBlocks.rubberSapling), 1, 3, 50); - public static WeightedRandomChestContent copperIngotLoot = new WeightedRandomChestContent(ItemIngots.getIngotByName("copper"), 1, 4, 100); - public static WeightedRandomChestContent tinIngotLoot = new WeightedRandomChestContent(ItemIngots.getIngotByName("tin"), 1, 4, 100); + public static ConfigTechReborn config; + + public static WeightedRandomChestContent rubberSaplingLoot = new WeightedRandomChestContent(new ItemStack(ModBlocks.rubberSapling), 1, 3, 25); + public static WeightedRandomChestContent copperIngotLoot = new WeightedRandomChestContent(ItemIngots.getIngotByName("copper"), 1, 4, 20); + public static WeightedRandomChestContent tinIngotLoot = new WeightedRandomChestContent(ItemIngots.getIngotByName("tin"), 1, 4, 20); + public static WeightedRandomChestContent steelIngotLoot = new WeightedRandomChestContent(ItemIngots.getIngotByName("steel"), 1, 3, 5); public static void init(){ - ChestGenHooks.getInfo(ChestGenHooks.VILLAGE_BLACKSMITH).addItem(rubberSaplingLoot); - ChestGenHooks.getInfo(ChestGenHooks.BONUS_CHEST).addItem(rubberSaplingLoot); - ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(rubberSaplingLoot); - ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_DESERT_CHEST).addItem(rubberSaplingLoot); - ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_CHEST).addItem(rubberSaplingLoot); - - ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(copperIngotLoot); - ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(tinIngotLoot); + if(config.RubberSaplingLoot){ + generate(rubberSaplingLoot); + } + if(config.CopperIngotsLoot){ + generate(copperIngotLoot); + } + if(config.TinIngotsLoot){ + generate(tinIngotLoot); + } + if(config.SteelIngotsLoot){ + generate(steelIngotLoot); + } } + public static void generate(WeightedRandomChestContent chestContent) { + for (String category : Arrays.asList(ChestGenHooks.VILLAGE_BLACKSMITH, ChestGenHooks.MINESHAFT_CORRIDOR, ChestGenHooks.PYRAMID_DESERT_CHEST, ChestGenHooks.PYRAMID_JUNGLE_CHEST, ChestGenHooks.PYRAMID_JUNGLE_DISPENSER, ChestGenHooks.STRONGHOLD_CORRIDOR, ChestGenHooks.STRONGHOLD_LIBRARY, ChestGenHooks.STRONGHOLD_CROSSING, ChestGenHooks.BONUS_CHEST, ChestGenHooks.DUNGEON_CHEST)) { + ChestGenHooks.addItem(category, chestContent); + } + } } diff --git a/src/main/java/techreborn/world/DungeonLoot.java b/src/main/java/techreborn/world/DungeonLoot.java deleted file mode 100644 index 57fe31733..000000000 --- a/src/main/java/techreborn/world/DungeonLoot.java +++ /dev/null @@ -1,21 +0,0 @@ -package techreborn.world; - -import net.minecraft.item.Item; -import net.minecraft.util.WeightedRandomChestContent; -import net.minecraftforge.common.ChestGenHooks; -import techreborn.items.ItemIngots; - -import java.util.Arrays; - -public class DungeonLoot { - - public static void init() { - generate(ItemIngots.getIngotByName("steel").getItem(), 5); - } - - public static void generate(Item item, int rare) { - for (String category : Arrays.asList(ChestGenHooks.VILLAGE_BLACKSMITH, ChestGenHooks.MINESHAFT_CORRIDOR, ChestGenHooks.PYRAMID_DESERT_CHEST, ChestGenHooks.PYRAMID_JUNGLE_CHEST, ChestGenHooks.PYRAMID_JUNGLE_DISPENSER, ChestGenHooks.STRONGHOLD_CORRIDOR, ChestGenHooks.STRONGHOLD_LIBRARY, ChestGenHooks.STRONGHOLD_CROSSING, ChestGenHooks.BONUS_CHEST, ChestGenHooks.DUNGEON_CHEST)) { - ChestGenHooks.addItem(category, new WeightedRandomChestContent(item, 0, 1, 3, rare)); - } - } -} diff --git a/src/main/java/techreborn/world/TreeGenerator.java b/src/main/java/techreborn/world/TreeGenerator.java index 8356927a3..7e69277e2 100644 --- a/src/main/java/techreborn/world/TreeGenerator.java +++ b/src/main/java/techreborn/world/TreeGenerator.java @@ -6,6 +6,7 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.fml.common.IWorldGenerator; +import techreborn.config.ConfigTechReborn; import java.util.Random; @@ -14,40 +15,44 @@ import java.util.Random; */ public class TreeGenerator implements IWorldGenerator { - public static RubberTreeGenerator treeGenerator = new RubberTreeGenerator(); + public static ConfigTechReborn config; - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { - int chance = 75; - boolean isValidSpawn = false; - BiomeGenBase biomeGenBase = world.getBiomeGenForCoords(new BlockPos(chunkX * 16, 72, chunkZ * 16)); - if (BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.SWAMP)) { - chance -= random.nextInt(10) + 10; - isValidSpawn = true; - } - if (BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.FOREST) || BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.JUNGLE)) { - chance -= random.nextInt(5) + 3; - isValidSpawn = true; - } - if (!isValidSpawn) { - return; - } - if (world.provider.isSurfaceWorld()) { - if (random.nextInt(chance) == 0) { - int x = (chunkX * 16) + random.nextInt(15); - int z = (chunkZ * 16) + random.nextInt(15); - for (int i = 0; i < 7; i++) { - int y = world.getActualHeight() - 1; - while (world.isAirBlock(new BlockPos(x, y, z)) && y > 0) { - y--; - } - treeGenerator.generate(world, random, new BlockPos(x, 72, z)); - x += random.nextInt(16) - 8; - z += random.nextInt(16) - 8; - } + public static RubberTreeGenerator treeGenerator = new RubberTreeGenerator(); - } + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + if (config.RubberTreeGen) { + int chance = 75; + boolean isValidSpawn = false; + BiomeGenBase biomeGenBase = world.getBiomeGenForCoords(new BlockPos(chunkX * 16, 72, chunkZ * 16)); + if (BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.SWAMP)) { + chance -= random.nextInt(10) + 10; + isValidSpawn = true; + } + if (BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.FOREST) || BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.JUNGLE)) { + chance -= random.nextInt(5) + 3; + isValidSpawn = true; + } + if (!isValidSpawn) { + return; + } + if (world.provider.isSurfaceWorld()) { + if (random.nextInt(chance) == 0) { + int x = (chunkX * 16) + random.nextInt(15); + int z = (chunkZ * 16) + random.nextInt(15); + for (int i = 0; i < 7; i++) { + int y = world.getActualHeight() - 1; + while (world.isAirBlock(new BlockPos(x, y, z)) && y > 0) { + y--; + } + treeGenerator.generate(world, random, new BlockPos(x, 72, z)); + x += random.nextInt(16) - 8; + z += random.nextInt(16) - 8; + } - } - } + } + + } + } + } }