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.init.Blocks;
- import net.minecraft.world.World;
- import net.minecraft.world.gen.feature.WorldGenerator;
- import static java.lang.Math.abs;
- import static java.lang.Math.max;
- import java.util.Random;
- public class WorldGenColony extends WorldGenerator
- {
- @Override
- public boolean generate(World world, Random random, int x, int y, int z)
- {
- if (world.getBiomeGenForCoords(x, z).topBlock != Blocks.grass)
- {
- return false;
- }
- int height = world.getHeightValue(x,z);
- for (int xCoord = -4; xCoord < 4; ++xCoord)
- {
- for (int zCoord = -4; zCoord <= 4; ++zCoord)
- {
- if (world.getBlock(xCoord, height, zCoord) != Blocks.grass)
- {
- return false;
- }
- for (int yCoord = 1; yCoord < (max(abs(xCoord), abs(zCoord)) < 1 ? 4 : 2); ++yCoord)
- {
- if (world.getBlock(xCoord, height + yCoord, zCoord) != Blocks.air)
- {
- return false;
- }
- }
- }
- }
- 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