Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. package com.richunderscore27.mites.worldgen;
  2.  
  3. import com.richunderscore27.mites.utility.LogHelper;
  4. import cpw.mods.fml.common.registry.GameRegistry;
  5. import net.minecraft.init.Blocks;
  6. import net.minecraft.world.World;
  7. import net.minecraft.world.gen.feature.WorldGenerator;
  8.  
  9. import static java.lang.Math.abs;
  10. import static java.lang.Math.max;
  11. import java.util.Random;
  12.  
  13. public class WorldGenColony extends WorldGenerator
  14. {
  15.     @Override
  16.     public boolean generate(World world, Random random, int x, int y, int z)
  17.     {
  18.  
  19.         if (world.getBiomeGenForCoords(x, z).topBlock != Blocks.grass)
  20.         {
  21.             return false;
  22.         }
  23.  
  24.         int height = world.getHeightValue(x,z);
  25.  
  26.         for (int xCoord = -4; xCoord < 4; ++xCoord)
  27.         {
  28.             for (int zCoord = -4; zCoord <= 4; ++zCoord)
  29.             {
  30.                 if (world.getBlock(xCoord, height, zCoord) != Blocks.grass)
  31.                 {
  32.                     return false;
  33.                 }
  34.                 for (int yCoord = 1; yCoord < (max(abs(xCoord), abs(zCoord)) < 1 ? 4 : 2); ++yCoord)
  35.                 {
  36.                     if (world.getBlock(xCoord, height + yCoord, zCoord) != Blocks.air)
  37.                     {
  38.                         return false;
  39.                     }
  40.                 }
  41.             }
  42.         }
  43.  
  44.         LogHelper.info("Generating at: (" + x + ", " + y + ", " + z + "), existing block: " + GameRegistry.findUniqueIdentifierFor(world.getBlock(x, y, z)));
  45.         return true;
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement