Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ShadoTECH.Util;
- import java.util.Random;
- import ShadoTECH.sT_Blocks;
- import net.minecraft.block.Block;
- import net.minecraft.init.Blocks;
- import net.minecraft.world.World;
- import net.minecraft.world.biome.BiomeGenBase;
- import net.minecraft.world.biome.BiomeGenBeach;
- import net.minecraft.world.biome.BiomeGenDesert;
- import net.minecraft.world.biome.BiomeGenHills;
- import net.minecraft.world.biome.BiomeGenOcean;
- import net.minecraft.world.chunk.IChunkProvider;
- import net.minecraft.world.gen.feature.WorldGenMinable;
- import net.minecraftforge.common.BiomeDictionary;
- import net.minecraftforge.common.BiomeDictionary.Type;
- import cpw.mods.fml.common.IWorldGenerator;
- public class OreWorldGenerator implements IWorldGenerator
- {
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
- {
- switch(world.provider.dimensionId)
- {
- case 0:
- //Overworld
- generateSurface(world, random, chunkX * 16, chunkZ * 16);
- customOverworld(world, random, chunkX, chunkZ);
- case -1:
- //Nether
- customNether(world, random, chunkX, chunkZ);
- break;
- }
- }
- public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY)
- {
- int maxPossY = minY + (maxY - 1);
- assert maxY > minY: "The maximum Y must be greater than the Minimum Y";
- assert maxX > 0 && maxX <= 16: "addOreSpawn: The Maximum X must be greater than 0 and less than 16";
- assert minY > 0: "addOreSpawn: The Minimum Y must be greater than 0";
- assert maxY < 256 && maxY > 0: "addOreSpawn: The Maximum Y must be less than 256 but greater than 0";
- assert maxZ > 0 && maxZ <= 16: "addOreSpawn: The Maximum Z must be greater than 0 and less than 16";
- int diffBtwnMinMaxY = maxY - minY;
- for(int x = 0; x < chancesToSpawn; x++)
- {
- int posX = blockXPos + random.nextInt(maxX);
- int posY = minY + random.nextInt(diffBtwnMinMaxY);
- int posZ = blockZPos + random.nextInt(maxZ);
- (new WorldGenMinable(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
- }
- }
- public void customOverworld(World world, Random random, int chunkX, int chunkZ)
- {
- for(int x = 0; x < 16; x++)
- {
- for(int z = 0; z < 16; z++)
- {
- if(ConfigurationHandler.FlatBedrock)
- {
- for(int y = 5; y > 0; y--)
- {
- if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
- {
- world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.stone, 0, 2);
- }
- }
- }
- if(ConfigurationHandler.RemoveBedrock)
- {
- for(int y = 5; y >= 0; y--)
- {
- if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
- {
- world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.stone, 0, 2);
- }
- }
- }
- }
- }
- }
- public void customNether(World world, Random random, int chunkX, int chunkZ)
- {
- for(int x = 0; x < 16; x++)
- {
- for(int z = 0; z < 16; z++)
- {
- boolean isNether = world.getBiomeGenForCoords(chunkX, chunkZ).biomeName.toLowerCase().equals("hell");
- if(isNether)
- {
- if(ConfigurationHandler.FlatBedrockNether)
- {
- for(int y = 5; y > 0; y--)
- {
- if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
- {
- world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.netherrack, 0, 2);
- }
- }
- }
- if(ConfigurationHandler.FlatBedrockNetherCeiling)
- {
- for(int y = 126; y > 120; y--)
- {
- if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
- {
- world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.netherrack, 0, 2);
- }
- }
- }
- if(ConfigurationHandler.RemoveBedrockNether)
- {
- for(int y = 5; y >= 0; y--)
- {
- if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
- {
- world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.netherrack, 0, 2);
- }
- }
- }
- if(ConfigurationHandler.RemoveBedrockNetherCeiling)
- {
- for(int y = 127; y >= 120; y--)
- {
- if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
- {
- world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.netherrack, 0, 2);
- }
- }
- }
- }
- }
- }
- }
- public void generateSurface(World world, Random random, int chunkX, int chunkZ)
- {
- BiomeGenBase biome = world.getBiomeGenForCoords(chunkX, chunkZ);
- if(ConfigurationHandler.EnableCopper)
- {
- if(random.nextInt(100) <= ConfigurationHandler.RarityCopper)
- {
- this.addOreSpawn(sT_Blocks.oreCopper, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeCopper, ConfigurationHandler.VeinsPerChunkCopper, ConfigurationHandler.MinCopper, ConfigurationHandler.MaxCopper);
- }
- }
- if(ConfigurationHandler.EnableTin)
- {
- if(random.nextInt(100) <= ConfigurationHandler.RarityTin)
- {
- this.addOreSpawn(sT_Blocks.oreTin, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeTin, ConfigurationHandler.VeinsPerChunkTin, ConfigurationHandler.MinTin, ConfigurationHandler.MaxTin);
- }
- }
- if(ConfigurationHandler.EnableUranium)
- {
- if(random.nextInt(100) <= ConfigurationHandler.RarityUranium)
- {
- this.addOreSpawn(sT_Blocks.oreUranium, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeUranium, ConfigurationHandler.VeinsPerChunkUranium, ConfigurationHandler.MinUranium, ConfigurationHandler.MaxUranium);
- }
- }
- if(ConfigurationHandler.EnableSilver)
- {
- if(random.nextInt(100) <= ConfigurationHandler.RaritySilver)
- {
- this.addOreSpawn(sT_Blocks.oreSilver, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeSilver, ConfigurationHandler.VeinsPerChunkSilver, ConfigurationHandler.MinSilver, ConfigurationHandler.MaxSilver);
- }
- }
- if(ConfigurationHandler.EnableLead)
- {
- if(random.nextInt(100) <= ConfigurationHandler.RarityLead)
- {
- this.addOreSpawn(sT_Blocks.oreLead, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeLead, ConfigurationHandler.VeinsPerChunkLead, ConfigurationHandler.MinLead, ConfigurationHandler.MaxLead);
- }
- }
- if(ConfigurationHandler.EnableRuby)
- {
- if(random.nextInt(100) <= ConfigurationHandler.RarityRuby)
- {
- if(ConfigurationHandler.BiomeRuby == true)
- {
- if(biome instanceof BiomeGenDesert)
- {
- this.addOreSpawn(sT_Blocks.oreRuby, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeRuby, ConfigurationHandler.VeinsPerChunkRuby, ConfigurationHandler.MinRuby, ConfigurationHandler.MaxRuby);
- }
- }
- else
- {
- this.addOreSpawn(sT_Blocks.oreRuby, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeRuby, ConfigurationHandler.VeinsPerChunkRuby, ConfigurationHandler.MinRuby, ConfigurationHandler.MaxRuby);
- }
- }
- }
- if(ConfigurationHandler.EnableSapphire)
- {
- if(random.nextInt(100) <= ConfigurationHandler.RaritySapphire)
- {
- if(ConfigurationHandler.BiomeSapphire == true)
- {
- if(biome instanceof BiomeGenOcean)
- {
- this.addOreSpawn(sT_Blocks.oreSapphire, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeSapphire, ConfigurationHandler.VeinsPerChunkSapphire, ConfigurationHandler.MinSapphire, ConfigurationHandler.MaxSapphire);
- }
- }
- else
- {
- this.addOreSpawn(sT_Blocks.oreSapphire, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeSapphire, ConfigurationHandler.VeinsPerChunkSapphire, ConfigurationHandler.MinSapphire, ConfigurationHandler.MaxSapphire);
- }
- }
- }
- if(ConfigurationHandler.RemoveVanillaGen)
- {
- if(random.nextInt(100) <= ConfigurationHandler.RarityCoal)
- {
- this.addOreSpawn(Blocks.coal_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeCoal, ConfigurationHandler.VeinsPerChunkCoal, ConfigurationHandler.MinCoal, ConfigurationHandler.MaxCoal);
- }
- if(random.nextInt(100) <= ConfigurationHandler.RarityIron)
- {
- this.addOreSpawn(Blocks.iron_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeIron, ConfigurationHandler.VeinsPerChunkIron, ConfigurationHandler.MinIron, ConfigurationHandler.MaxIron);
- }
- if(random.nextInt(100) <= ConfigurationHandler.RarityGold)
- {
- this.addOreSpawn(Blocks.gold_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeGold, ConfigurationHandler.VeinsPerChunkGold, ConfigurationHandler.MinGold, ConfigurationHandler.MaxGold);
- }
- if(random.nextInt(100) <= ConfigurationHandler.RarityDiamond)
- {
- this.addOreSpawn(Blocks.diamond_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeDiamond, ConfigurationHandler.VeinsPerChunkDiamond, ConfigurationHandler.MinDiamond, ConfigurationHandler.MaxDiamond);
- }
- if(random.nextInt(100) <= ConfigurationHandler.RarityEmerald)
- {
- if(ConfigurationHandler.BiomeEmerald == true)
- {
- if(biome instanceof BiomeGenHills)
- {
- this.addOreSpawn(Blocks.emerald_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeEmerald, ConfigurationHandler.VeinsPerChunkEmerald, ConfigurationHandler.MinEmerald, ConfigurationHandler.MaxEmerald);
- }
- }
- else
- {
- this.addOreSpawn(Blocks.emerald_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeEmerald, ConfigurationHandler.VeinsPerChunkEmerald, ConfigurationHandler.MinEmerald, ConfigurationHandler.MaxEmerald);
- }
- }
- if(random.nextInt(100) <= ConfigurationHandler.RarityRedstone)
- {
- this.addOreSpawn(Blocks.redstone_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeRedstone, ConfigurationHandler.VeinsPerChunkRedstone, ConfigurationHandler.MinRedstone, ConfigurationHandler.MaxRedstone);
- }
- if(random.nextInt(100) <= ConfigurationHandler.RarityLapis)
- {
- this.addOreSpawn(Blocks.lapis_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeLapis, ConfigurationHandler.VeinsPerChunkLapis, ConfigurationHandler.MinLapis, ConfigurationHandler.MaxLapis);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement