Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.17 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.block.Block;
  6. import net.minecraft.init.Blocks;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.world.World;
  9. import net.minecraft.world.biome.BiomeGenBase;
  10. import net.minecraft.world.gen.feature.WorldGenerator;
  11. import net.minecraftforge.oredict.OreDictionary;
  12.  
  13. import java.util.*;
  14.  
  15. public class WorldGenColony extends WorldGenerator
  16. {
  17.     @Override
  18.     public boolean generate(World world, Random random, int x, int y, int z)
  19.     {
  20.         HashSet<Integer> topHeights = new HashSet<Integer>();
  21.         ArrayList<GameRegistry.UniqueIdentifier> treeBlocks = new ArrayList<GameRegistry.UniqueIdentifier>();
  22.  
  23.         for (ItemStack itemStack : OreDictionary.getOres("logWood"))
  24.             treeBlocks.add(GameRegistry.findUniqueIdentifierFor(itemStack.getItem()));
  25.  
  26.         for (ItemStack itemStack : OreDictionary.getOres("treeLeaves"))
  27.             treeBlocks.add(GameRegistry.findUniqueIdentifierFor(itemStack.getItem()));
  28.  
  29.         treeBlocks.add(GameRegistry.findUniqueIdentifierFor(Blocks.tallgrass));
  30.  
  31.         for (int xIter = -4; xIter < 4; ++xIter)
  32.         {
  33.             for (int zIter = -4; zIter <= 4; ++zIter)
  34.             {
  35.                 int topY = world.getTopSolidOrLiquidBlock(x, z) + 2;
  36.                 Block topBlock;
  37.                 do
  38.                 {
  39.                     topBlock = world.getBlock(x, --topY, z);
  40.                 }
  41.                 while (topBlock == Blocks.air || treeBlocks.contains(GameRegistry.findUniqueIdentifierFor(topBlock)));
  42.                 topHeights.add(topY);
  43.             }
  44.         }
  45.  
  46.         int heightVar = Collections.max(topHeights) - Collections.min(topHeights);
  47.  
  48.         BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
  49.         if ((biome.topBlock == Blocks.grass || biome.topBlock == Blocks.dirt) && heightVar < 2)
  50.         {
  51.             LogHelper.info("Generating at: (" + x + ", " + y + ", " + z + "), existing block: " + GameRegistry.findUniqueIdentifierFor(world.getBlock(x, y, z)));
  52.         }
  53.         return true;
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement