Advertisement
Guest User

Untitled

a guest
Jan 13th, 2018
1,154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.97 KB | None | 0 0
  1. package com.theishiopian.foragecraft.world.generation;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.theishiopian.foragecraft.config.ConfigVariables;
  6. import net.minecraft.util.math.BlockPos;
  7. import net.minecraft.world.World;
  8. import net.minecraft.world.chunk.IChunkProvider;
  9. import net.minecraft.world.gen.feature.WorldGenerator;
  10. import net.minecraftforge.common.BiomeDictionary;
  11. import net.minecraftforge.fml.common.IWorldGenerator;
  12.  
  13. /*
  14. /  World generation based on sky_01's MC forums tutorial
  15. /  http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2666351-1-8-x-and-1-9-structure-generation-tutorial
  16. */
  17.  
  18. public class FCMasterWorldGenerator implements IWorldGenerator
  19. {
  20.     @Override
  21.     public void generate(Random random, int chunkX, int chunkZ, World world, net.minecraft.world.gen.IChunkGenerator chunkGenerator,
  22.             IChunkProvider chunkProvider)
  23.     {
  24.         int blockX = chunkX * 16;
  25.         int blockZ = chunkZ * 16;
  26.        
  27.         switch (world.provider.getDimension())
  28.         {
  29.             case -1:
  30.                 generateNether(world, random, blockX, blockZ);
  31.             break;
  32.             case 0:
  33.                 generateOverworld(world, random, blockX, blockZ);
  34.             break;
  35.             case 1:
  36.                 generateEnd(world, random, blockX, blockZ);
  37.             break;
  38.         }
  39.     }
  40.  
  41.     private void generateNether(World world, Random rand, int blockX, int blockZ)
  42.     {
  43.  
  44.     }
  45.  
  46.     private void generateOverworld(World world, Random rand, int blockX, int blockZ)
  47.     {
  48.         WorldGenerator rocky = new RockGenerator();
  49.         WorldGenerator sticky = new StickGenerator();
  50.  
  51.         int MIN = 32;
  52.         int MAX = 1024;
  53.         int rockRange = MIN + rand.nextInt(MAX - MIN);
  54.         int stickRange = MIN + rand.nextInt(MAX - MIN);
  55.         BlockPos biomeCheckPos = new BlockPos(blockX, 64, blockZ);
  56.        
  57.         // If the player decides to disable rocks.
  58.         if(ConfigVariables.enableRocks)
  59.         {
  60.             // rocks can be found everywhere, even mushroom isles
  61.             //this is intentional, since they generate underground.
  62.             for (int i = 0; i < rockRange; i++)
  63.             {
  64.                 int randX = blockX + rand.nextInt(16)+8;
  65.                 int randY = rand.nextInt(255);
  66.                 int randZ = blockZ + rand.nextInt(16)+8;
  67.                 BlockPos pos = new BlockPos(randX, randY, randZ);
  68.                 rocky.generate(world, rand, pos);
  69.             }
  70.         }
  71.  
  72.         //sticks can only be found in places where it makes sense to find them
  73.         if
  74.         (
  75.             BiomeDictionary.hasType(world.getBiome(biomeCheckPos), BiomeDictionary.Type.FOREST)||
  76.             BiomeDictionary.hasType(world.getBiome(biomeCheckPos), BiomeDictionary.Type.JUNGLE)||
  77.             BiomeDictionary.hasType(world.getBiome(biomeCheckPos), BiomeDictionary.Type.SWAMP)
  78.         )
  79.  
  80.         // If the player decides to disable sticks
  81.         if(ConfigVariables.enableSticks)
  82.         {
  83.             for (int i = 0; i < stickRange; i++)
  84.             {
  85.                 int randX = blockX + rand.nextInt(16)+8;
  86.                 int randY = rand.nextInt(255);//I long for cubic chunks :(
  87.                 int randZ = blockZ + rand.nextInt(16)+8;
  88.  
  89.                 sticky.generate(world, rand, new BlockPos(randX, randY, randZ));
  90.             }
  91.         }
  92.     }
  93.  
  94.     private void generateEnd(World world, Random rand, int blockX, int blockZ)
  95.     {
  96.  
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement