Advertisement
Guest User

WorldGenerator

a guest
Aug 20th, 2017
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.02 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.init.Blocks;
  5. import net.minecraft.util.math.BlockPos;
  6. import net.minecraft.world.World;
  7. import net.minecraft.world.biome.Biome;
  8. import net.minecraft.world.biome.BiomeCache;
  9. import net.minecraft.world.chunk.IChunkGenerator;
  10. import net.minecraft.world.chunk.IChunkProvider;
  11. import net.minecraft.world.gen.feature.WorldGenerator;
  12. import net.minecraftforge.fml.common.IWorldGenerator;
  13.  
  14. public class WorldGeneratorxlfoodmod implements IWorldGenerator{
  15.  
  16.     public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
  17.     {
  18.         int blockX = chunkX * 16;
  19.         int blockZ = chunkZ * 16;
  20.        
  21.         switch(world.provider.getDimension())
  22.         {
  23.         case -1: generateNether(world, random, blockX, blockZ);
  24.         break;
  25.         case 0: generateOverworld(world, random, blockX, blockZ);
  26.         break;
  27.         case 1: generateEnd(world, random, blockX, blockZ);
  28.         break;
  29.         }
  30.  
  31.     }
  32.  
  33.     private void generateNether(World world, Random rand, int blockX, int blockZ)
  34.     {
  35.        
  36.     }
  37.  
  38.     private void generateOverworld(World world, Random rand, int blockX, int blockZ)
  39.     {
  40.         WorldGenerator genVanillaFlower = new WorldGenxlfoodmod();
  41.         Biome biome = world.getBiomeForCoordsBody(new BlockPos(blockX, 64, blockZ));       
  42.         {
  43.             int MIN = 0;
  44.             int MAX = 8;
  45.             int numBushes = MIN + rand.nextInt(MAX - MIN);
  46.             for(int i = 0; i < numBushes; i++)
  47.             {
  48.                 int randX = blockX + rand.nextInt(16);
  49.                 int randZ = blockZ + rand.nextInt(16);
  50.                 genVanillaFlower.generate(world, rand, new BlockPos(randX, 24, randZ));
  51.             }
  52.         }
  53.     }
  54.  
  55.     private void generateEnd(World world, Random rand, int blockX, int blockZ)
  56.     {
  57.  
  58.     }
  59.  
  60.     public static int getGroundFromAbove(World world, int x, int z)
  61.     {
  62.         int y = 255;
  63.         boolean foundGround = false;
  64.         while(!foundGround && y-- >= 0)
  65.         {
  66.             Block blockAt = world.getBlockState(new BlockPos(x,y,z)).getBlock();
  67.             foundGround = blockAt == Blocks.DIRT || blockAt == Blocks.GRASS;
  68.         }
  69.  
  70.         return y;
  71.     }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement