Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dem.tutorialmod.init.worldgen;
- import java.util.Random;
- import com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationException;
- import dem.tutorialmod.init.TutorialBlocks;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.World;
- import net.minecraft.world.chunk.IChunkGenerator;
- import net.minecraft.world.chunk.IChunkProvider;
- import net.minecraft.world.gen.feature.WorldGenerator;
- import net.minecraftforge.fml.common.IWorldGenerator;
- public class TutorialWorldGen implements IWorldGenerator
- {
- //OverWorldOres
- private WorldGenerator platinum_ore;
- private WorldGenerator tarium_ore;
- private WorldGenerator demium_ore;
- private WorldGenerator norite_ore;
- private WorldGenerator ollium_ore;
- private WorldGenerator tcb_ore;
- private WorldGenerator walrusite_ore;
- private WorldGenerator nether_diamond_ore;
- public TutorialWorldGen()
- {
- this.platinum_ore = new TutorialWorldGenMineable(TutorialBlocks.platinum_ore.getDefaultState(), 5); //3+ works best apparently (blocks together (vein))
- this.tarium_ore = new TutorialWorldGenMineable(TutorialBlocks.tarium_ore.getDefaultState(), 5);
- this.demium_ore = new TutorialWorldGenMineable(TutorialBlocks.demium_ore.getDefaultState(), 3);
- this.norite_ore = new TutorialWorldGenMineable(TutorialBlocks.norite_ore.getDefaultState(), 6);
- this.ollium_ore = new TutorialWorldGenMineable(TutorialBlocks.ollium_ore.getDefaultState(), 4);
- this.tcb_ore = new TutorialWorldGenMineable(TutorialBlocks.tcb_ore.getDefaultState(), 3);
- this.walrusite_ore = new TutorialWorldGenMineable(TutorialBlocks.walrusite_ore.getDefaultState(), 4);
- this.nether_diamond_ore = new TutorialWorldGenMineable(TutorialBlocks.nether_diamond_ore.getDefaultState(), 6);
- }
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
- {
- switch(world.provider.getDimension())
- {
- case 0: //OverWorld
- this.runGenerator(this.platinum_ore, world, random, chunkX, chunkZ, 40, 0, 120);
- this.runGenerator(this.tarium_ore, world, random, chunkX, chunkZ, 60, 0, 256);
- this.runGenerator(this.demium_ore, world, random, chunkX, chunkZ, 45, 5, 40);
- this.runGenerator(this.norite_ore, world, random, chunkX, chunkZ, 50, 0, 120);
- this.runGenerator(this.ollium_ore, world, random, chunkX, chunkZ, 40, 0, 256);
- this.runGenerator(this.tcb_ore, world, random, chunkX, chunkZ, 35, 10, 20);
- this.runGenerator(this.walrusite_ore, world, random, chunkX, chunkZ, 65, 10, 256);
- break;
- case -1: //Nether
- this.runGenerator(this.nether_diamond_ore, world, random, chunkX, chunkZ, 70, 10, 256);
- break;
- case 1: //EndWorld
- break;
- }
- }
- private void runGenerator(WorldGenerator generator, World world, Random random, int chunkX, int chunkZ, int chanceToSpawn, int minHeight, int maxHeight)
- {
- if(minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
- {
- throw new IllegalArgumentException("Minimum or Maximum Height out of bounds");
- }
- int heightDiff = maxHeight - minHeight +1;
- for(int i = 0; i < chanceToSpawn; i++)
- {
- int x = chunkX * 16 + random.nextInt(16);
- int y = minHeight + random.nextInt(heightDiff);
- int z = chunkZ * 16 + random.nextInt(16);
- generator.generate(world, random, new BlockPos(x, y, z));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment