Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ua.Nikeron2517.ElectroMagic;
- import java.util.Random;
- import cpw.mods.fml.common.IWorldGenerator;
- import net.minecraft.block.Block;
- import net.minecraft.init.Blocks;
- import net.minecraft.world.World;
- import net.minecraft.world.chunk.IChunkProvider;
- import net.minecraft.world.gen.feature.WorldGenMinable;
- public class ElectroMagicGenerator implements IWorldGenerator{
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator,
- IChunkProvider chunkProvider) {
- switch(world.provider.dimensionId)
- {
- case 1:
- generateEnd(world, random, chunkX, chunkZ);
- break;
- case 0:
- generateOverworld(world, random, chunkX, chunkZ);
- break;
- case -1:
- generateNether(world, random, chunkX, chunkZ);
- break;
- }
- }
- public void generateEnd(World world, Random rand, int x, int z){
- generateOre(Main.boxit, world, rand, x, z, 2, 10, 5, 0, 100, Blocks.end_stone);
- }
- public void generateOverworld(World world, Random rand, int x, int z) {
- generateOre(Main.boxit, world, rand, x, z, 15, 50, 5, 0, 100, Blocks.stone);
- }
- //Блок номер 1 (block1)
- public void generateOverworld(World world, Random rand, int x, int z) {
- generateOre(Main.boxit, world, rand, x, z, 15, 50, 5, 0, 100, Main.block1);
- }
- //Блок номер 2 (block2)
- public void generateOverworld(World world, Random rand, int x, int z) {
- generateOre(Main.boxit, world, rand, x, z, 15, 50, 5, 0, 100, Main.block2);
- }
- public void generateNether(World world, Random rand, int x, int z) {
- generateOre(Main.boxit, world, rand, x, z, 2, 10, 5, 0, 100, Blocks.netherrack);
- }
- public void generateOre(Block block, World world, Random random, int chunkX, int chunkZ, int minVeinSize, int maxVeinSize, int chance, int minY, int maxY, Block generateIn) {
- int veinSize = minVeinSize = random.nextInt(maxVeinSize - minVeinSize);
- int heightRange = maxY - minY;
- WorldGenMinable gen = new WorldGenMinable(block, veinSize, generateIn);
- for(int i = 0; i < chance; i++) {
- int xRand = chunkX * 16 + random.nextInt(16);
- int yRand = random.nextInt(heightRange) + minY;
- int zRand = chunkX * 16 + random.nextInt(16);
- gen.generate(world, random, xRand, yRand, zRand);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement