Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.richunderscore27.mites.worldgen;
- import com.richunderscore27.mites.utility.LogHelper;
- import cpw.mods.fml.common.registry.GameRegistry;
- import net.minecraft.block.Block;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.ItemStack;
- import net.minecraft.world.World;
- import net.minecraft.world.biome.BiomeGenBase;
- import net.minecraft.world.gen.feature.WorldGenerator;
- import net.minecraftforge.oredict.OreDictionary;
- import java.util.*;
- public class WorldGenColony extends WorldGenerator
- {
- @Override
- public boolean generate(World world, Random random, int x, int y, int z)
- {
- HashSet<Integer> topHeights = new HashSet<Integer>();
- ArrayList<GameRegistry.UniqueIdentifier> treeBlocks = new ArrayList<GameRegistry.UniqueIdentifier>();
- for (ItemStack itemStack : OreDictionary.getOres("logWood"))
- treeBlocks.add(GameRegistry.findUniqueIdentifierFor(itemStack.getItem()));
- for (ItemStack itemStack : OreDictionary.getOres("treeLeaves"))
- treeBlocks.add(GameRegistry.findUniqueIdentifierFor(itemStack.getItem()));
- treeBlocks.add(GameRegistry.findUniqueIdentifierFor(Blocks.tallgrass));
- for (int xIter = -4; xIter < 4; ++xIter)
- {
- for (int zIter = -4; zIter <= 4; ++zIter)
- {
- int topY = world.getTopSolidOrLiquidBlock(x, z) + 2;
- Block topBlock;
- do
- {
- topBlock = world.getBlock(x, --topY, z);
- }
- while (topBlock == Blocks.air || treeBlocks.contains(GameRegistry.findUniqueIdentifierFor(topBlock)));
- topHeights.add(topY);
- }
- }
- int heightVar = Collections.max(topHeights) - Collections.min(topHeights);
- BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
- if ((biome.topBlock == Blocks.grass || biome.topBlock == Blocks.dirt) && heightVar < 2)
- {
- LogHelper.info("Generating at: (" + x + ", " + y + ", " + z + "), existing block: " + GameRegistry.findUniqueIdentifierFor(world.getBlock(x, y, z)));
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement