Advertisement
robin4002

génération

Oct 6th, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.64 KB | None | 0 0
  1. package tutoriel.common;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.world.World;
  7. import net.minecraft.world.biome.BiomeGenBase;
  8. import net.minecraft.world.chunk.IChunkProvider;
  9. import net.minecraft.world.gen.feature.WorldGenMinable;
  10. import cpw.mods.fml.common.IWorldGenerator;
  11.  
  12. public class WorldGeneratorTutoriel 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 -1:
  21.             this.generateEnd(world, chunkX * 16, chunkZ * 16, random);
  22.         case 0:
  23.             this.generateSurface(world, chunkX * 16, chunkZ * 16, random);
  24.         case 1:
  25.             this.generateNether(world, chunkX * 16, chunkZ * 16, random);
  26.         }
  27.  
  28.     }
  29.  
  30.     private void generateSurface(World world, int x, int z, Random rand)
  31.     {
  32.         for(int i = 0; i < 2; i++)
  33.         {
  34.             int targetX1 = x + rand.nextInt(16);
  35.             int targetY1 = rand.nextInt(64);
  36.             int targetZ1 = z + rand.nextInt(16);
  37.             (new WorldGenMinable(ModTutoriel.TutorialMetadata.blockID, 0, 4, Block.stone.blockID)).generate(world, rand, targetX1, targetY1, targetZ1);
  38.         }
  39.        
  40.         if(world.getBiomeGenForCoords(x, z).equals(BiomeGenBase.extremeHills))
  41.         {
  42.             for(int i = 0; i < 8; i++)
  43.             {
  44.                 int targetX2 = x + rand.nextInt(16);
  45.                 int targetY2 = rand.nextInt(64);
  46.                 int targetZ2 = z + rand.nextInt(16);
  47.                 (new WorldGenMinable(ModTutoriel.TutorialMetadata.blockID, 5, 12, Block.stone.blockID)).generate(world, rand, targetX2, targetY2, targetZ2);
  48.             }
  49.         }
  50.     }
  51.  
  52.     private void generateEnd(World world, int x, int z, Random rand)
  53.     {
  54.         for(int i = 0; i < 4; i++)
  55.         {
  56.             int targetX2 = x + rand.nextInt(16);
  57.             int targetY2 = rand.nextInt(64);
  58.             int targetZ2 = z + rand.nextInt(16);
  59.             (new WorldGenMinable(ModTutoriel.BlockTutorial.blockID, 0, 12, Block.whiteStone.blockID)).generate(world, rand, targetX2, targetY2, targetZ2);
  60.         }
  61.     }
  62.  
  63.     private void generateNether(World world, int x, int z, Random rand)
  64.     {
  65.         for(int i = 0; i < 20; i++)
  66.         {
  67.             int targetX2 = x + rand.nextInt(16);
  68.             int targetY2 = rand.nextInt(64);
  69.             int targetZ2 = z + rand.nextInt(16);
  70.             (new WorldGenMinable(ModTutoriel.TutorialMetadata.blockID, 2, 12, Block.slowSand.blockID)).generate(world, rand, targetX2, targetY2, targetZ2);
  71.         }
  72.        
  73.         for(int i = 0; i < 10; i++)
  74.         {
  75.             int targetX2 = x + rand.nextInt(16);
  76.             int targetY2 = rand.nextInt(64);
  77.             int targetZ2 = z + rand.nextInt(16);
  78.             (new WorldGenMinable(ModTutoriel.TutorialMetadata.blockID, 3, 12, Block.netherrack.blockID)).generate(world, rand, targetX2, targetY2, targetZ2);
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement