Added loot and rubber tree configs

This commit is contained in:
TheDoctorSoda 2016-02-23 21:26:57 -08:00
parent d7474fec45
commit 45047be17b
4 changed files with 96 additions and 66 deletions

View file

@ -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")

View file

@ -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);
}
}
}

View file

@ -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));
}
}
}

View file

@ -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;
}
}
}
}
}
}
}
}