Advertisement
Guest User

Untitled

a guest
Jan 12th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. package packteste.generation;
  2.  
  3. import java.util.Random;
  4.  
  5. import cpw.mods.fml.common.IWorldGenerator;
  6. import net.minecraft.block.Block;
  7. import net.minecraft.init.Blocks;
  8. import net.minecraft.world.World;
  9. import net.minecraft.world.chunk.IChunkProvider;
  10. import net.minecraft.world.gen.feature.WorldGenMinable;
  11.  
  12. public class ModTesteWorldGeneration implements IWorldGenerator
  13. {
  14.    
  15.     @Override
  16.     public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
  17.     {
  18.         switch (world.provider.dimensionId)
  19.         {
  20.             case 0:
  21.                 generateSurface(world, random, chunkX * 16, chunkZ * 16);
  22.             case -1:
  23.                 generateNether(world, random, chunkX * 16, chunkZ * 16);
  24.             case 1:
  25.                 generateEnd(world, random, chunkX * 16, chunkZ * 16);
  26.  
  27.         }
  28.     }
  29.    
  30.     private void generateSurface(World world, Random random, int x, int z)
  31.     {
  32.         addOreSpawn(Blocks.diamond_block, world, random, x, z, 16, 16, 100 + random.nextInt(30), 80, 40, 150);
  33.     }
  34.  
  35.     private void generateNether(World world, Random random, int x, int z)
  36.     {
  37.    
  38.     }
  39.  
  40.     private void generateEnd(World world, Random random, int x, int z)
  41.     {
  42.    
  43.     }
  44.  
  45.     private void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chanceToSpawn, int minY, int maxY)
  46.     {
  47.         for (int i = 0; i < chanceToSpawn; i++)
  48.         {
  49.             int posX = blockXPos + random.nextInt(maxX);
  50.             int posY = minY + random.nextInt(maxY - minY);
  51.             int posZ = blockZPos + random.nextInt(maxZ);
  52.             new WorldGenMinable(block, maxVeinSize).generate(world, random, posX, posY, posZ);
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement