Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package degubi.teamcraft.infs.worldgen;
- import java.util.Random;
- 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.chunk.IChunkProvider;
- import net.minecraft.world.gen.feature.WorldGenMinable;
- import cpw.mods.fml.common.IWorldGenerator;
- import degubi.teamcraft.TeamCraft;
- public class OreGen implements IWorldGenerator {
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world,
- IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
- switch(world.provider.dimensionId){
- case -1: generateNether(world, random, chunkX * 16, chunkZ * 16);
- case 0: generateSurface(world, random, chunkX * 16, chunkZ * 16);
- case 1: generateEnd(world, random, chunkX * 16, chunkZ * 16);
- }
- }
- private void generateEnd(World world, Random random, int x, int z) {
- }
- private void generateNether(World world, Random random, int x, int z) {
- }
- private void generateSurface(World world, Random random, int x, int z) {
- this.addOreSpawn(TeamCraft.MarbleStone, world, random, x, z, 16, 16, 4+random.nextInt(10), 1, 40, 70);
- this.addOreSpawn(TeamCraft.Granite, world, random, x, z, 16, 16, 5+random.nextInt(8), 2, 20, 100);
- this.addOreSpawn(TeamCraft.Diorite, world, random, x, z, 16, 16, 5+random.nextInt(8), 2, 20, 100);
- this.addOreSpawn(TeamCraft.Andesite, world, random, x, z, 16, 16, 5+random.nextInt(8), 2, 20, 100);
- this.addOreSpawn1(Blocks.sponge, world, random, x, z, 16, 16, 3+random.nextInt(7), 10, 40, 100);
- BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x + 16, z + 16);
- if(biome == BiomeGenBase.extremeHills || biome == BiomeGenBase.extremeHillsEdge || biome == BiomeGenBase.extremeHillsPlus){
- this.addOreSpawn(Blocks.emerald_ore, world, random, x, z, 16, 16, 2+random.nextInt(4), 30, 20, 50);
- }
- }
- 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 addOreSpawn1(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 WorldGenSponge(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement