Jump to content

Recommended Posts

Posted

Is there any chanche to get a village spawn in the nether? Because it seems that the Netherrack or all other nether-related blocks are not listed as terrain, so adding the Nether as a village biome is useless (the village will never spawn). So, there is any chanche to change this? To tell the game "also check if the terrain is netherrack or else" so the village can spawn there? I don't want to rewrite all the village generation system if is not necessary, so i'm asking for your help :)

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

No, but i thought you meant that. I've tried doing this

BiomeManager.addVillageBiome(BiomeGenBase.hell, true);

wich works with all other biomes in the overworld but it doesn't in the nether :/

So how can i make it work? :/

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

Ok, so i've tried doing this in my worldGenMinable class

for (int i = 0; i < 200; i++) {
		int posX = x + random.nextInt(16);
		int posZ = z + random.nextInt(16);
		int posY = 64 + random.nextInt(140);
		village.func_175794_a(world, random, new ChunkCoordIntPair(x, z));
	}

Where village is this

this.villageGenerator = new MapGenVillage();

	villageGenerator = (MapGenVillage)TerrainGen.getModdedMapGen(villageGenerator, VILLAGE);

	genNetherVillages(villageGenerator, world, random, x, z);

But still not working :/

I've looked into ChunkProviderGenerate and that is the method from where it starts generate the village

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

Trying to force the village generation in the nether (considering it like a normal structure)

I really don't understand what to do :(

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

So i need to do this?

MinecraftForge.TERRAIN_GEN_BUS.register(new NetherVillageHandler());

package blaze.world.village;

import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class NetherVillageHandler
{
  @SubscribeEvent
  public void genNetherVillages(PopulateChunkEvent.Pre event)
  {
  System.out.println("DOING NETHER STUFF");
  }
}

 

I'm really sorry if all this could seem dumb but i've never worked with terrain gen events :/ I think this is wrong since that string is never printed out

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

Woops, changed the registration to this

MinecraftForge.EVENT_BUS.register(new NetherVillageHandler());

Now the method is called, so now in there how to generate the village?

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

Ok, i've added this

this.villageGenerator = new MapGenVillage();
villageGenerator = (MapGenVillage)TerrainGen.getModdedMapGen(villageGenerator, EventType.VILLAGE);
villageGenerator.func_175792_a(event.chunkProvider, event.world, event.chunkX, event.chunkZ, new ChunkPrimer());

but still no villages are spawning :/ In ChunkProviderGenerate it does this

this.villageGenerator.func_175792_a(this, this.worldObj, x, z, chunkprimer);

or this

this.villageGenerator.func_175794_a(this.worldObj, this.rand, chunkcoordintpair);

but both of them doesn't spawn any village in the nether :(

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

When it calls the MapGenStructures class this value

Iterator iterator = this.structureMap.values().iterator();

is null, since  structureMap.values() it is.

EDIT:

doing this

villageGenerator.func_175792_a(event.chunkProvider, event.world, event.chunkX, event.chunkZ, new ChunkPrimer());
villageGenerator.func_175794_a(event.world, new Random(), new ChunkCoordIntPair(event.chunkX, event.chunkZ));

populate that value. Still looking into the code to see what it prevents to spawn

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

OK, so the village actually generate but it's generating over the bedrock

The village generation code does a check to get the TopSolidOrLiquidBlock, and this seems to return the bedrock top

oczAxIX.png

Is there any way to change this (so make the villages generate under the bedrock) ?

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

You shouldn't need a total rewrite from scratch. Can you extend the class in question and just override a method or two? Then where your event calls the village generator, instantiate a static one of your own and call the entry method on it instead.

 

You'd still want some kind of test for an upper surface, but it would only need maybe 16 blocks of air above solid blocks. See what kind of check is made for placing a nethergate. Anywhere the vanilla code would place a gate is probably good enough to place a village.

 

I think it would also be fun to substitute materials to suit the nether. Let's see... Nether-brick is so dark, but it's the only fencing. On the other hand, cobble could all be replaced by quartz double-slabs (as white as quartz but as hard as cobble). Proximity to lava (including possible lava falls from above) means avoiding wood like the plague, so you might want quartz stairs for roofing.

 

Good luck keeping the villagers out of the lava. Can't wait to find out how the zombie-pigmen treat them. Also: Was there water in the well?

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Thanks for your reply :) For the materials i have already a class that should change the vanilla materials (wich it works in all other biomes), for the villager, well... i'm not responsible for their action xD And of course the water will be changed with lava ;) I will do some more tests as soon as i can :)

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

I'm interested in this myself (I've long wanted to improve villagers/villages, but I haven't explored their code yet). Please post some source files when you're done (or stuck again). Also let me know if you release the finished mod at Curse. If it's close enough to what I'm hoping for, I may go with it.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Of course :) I will release the final mod at Curse (well, actually there is yet the old version for 1.7.10) :)

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

Ok, so i've tried copy-paste the vanilla village gen code, and now it gives me this error when generating a new world

java.lang.ClassCastException: blaze.world.village.MapGenVillageEventHandler cannot be cast to blaze.world.village.MapGenNetherVillage
at blaze.world.village.NetherVillageHandler.genNetherVillages(NetherVillageHandler.java:22)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_9_NetherVillageHandler_genNetherVillages_Pre.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138)
at net.minecraft.world.gen.ChunkProviderGenerate.populate(ChunkProviderGenerate.java:426)
at net.minecraft.world.gen.ChunkProviderServer.populate(ChunkProviderServer.java:292)
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1206)
at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:196)
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:138)
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:108)
at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:343)
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:113)
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:130)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:500)
at java.lang.Thread.run(Unknown Source)

 

This error is called from here

package blaze.world.village;

import java.util.Random;

import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.gen.structure.MapGenVillage;
import net.minecraftforge.event.terraingen.InitMapGenEvent.EventType;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.event.terraingen.TerrainGen;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class NetherVillageHandler
{
private MapGenNetherVillage villageGenerator;

@SubscribeEvent
public void genNetherVillages(PopulateChunkEvent.Pre event)
{
	this.villageGenerator = new MapGenNetherVillage();
	villageGenerator = (MapGenNetherVillage) TerrainGen.getModdedMapGen(villageGenerator, EventType.VILLAGE); //THIS LINE THROW THE ERROR!
	villageGenerator.func_175792_a(event.chunkProvider, event.world, event.chunkX, event.chunkZ, new ChunkPrimer());
	villageGenerator.func_175794_a(event.world, new Random(), new ChunkCoordIntPair(event.chunkX, event.chunkZ));
}

}

 

What i've done is creating this class

package blaze.world.village;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.structure.MapGenVillage;
import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureStart;

public class MapGenNetherVillage extends MapGenVillage
{
    /** A list of all the biomes villages can spawn in. */
    public static List villageSpawnBiomes = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.hell});
    /** World terrain type, 0 for normal, 1 for flat map */
    private int terrainType;
    private int field_82665_g;
    private int field_82666_h;

    public MapGenNetherVillage()
    {
       super();
    }

    public MapGenNetherVillage(Map map)
    {
        this();
        Iterator iterator = map.entrySet().iterator();

        while (iterator.hasNext())
        {
            Entry entry = (Entry)iterator.next();

            if (((String)entry.getKey()).equals("size"))
            {
                this.terrainType = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.terrainType, 0);
            }
            else if (((String)entry.getKey()).equals("distance"))
            {
                this.field_82665_g = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.field_82665_g, this.field_82666_h + 1);
            }
        }
    }

    public String getStructureName()
    {
        return "NetherVillage";
    }

    protected boolean canSpawnStructureAtCoords(int x, int z)
    {
        int k = x;
        int l = z;

        if (x < 0)
        {
            x -= this.field_82665_g - 1;
        }

        if (z < 0)
        {
            z -= this.field_82665_g - 1;
        }

        int i1 = x / this.field_82665_g;
        int j1 = z / this.field_82665_g;
        Random random = this.worldObj.setRandomSeed(i1, j1, 10387312);
        i1 *= this.field_82665_g;
        j1 *= this.field_82665_g;
        i1 += random.nextInt(this.field_82665_g - this.field_82666_h);
        j1 += random.nextInt(this.field_82665_g - this.field_82666_h);

        if (k == i1 && l == j1)
        {
            boolean flag = this.worldObj.getWorldChunkManager().areBiomesViable(k * 16 + 8, l * 16 + 8, 0, villageSpawnBiomes);

            if (flag)
            {
                return true;
            }
        }

        return false;
    }

    protected StructureStart getStructureStart(int x, int z)
    {
        return new MapGenNetherVillage.Start(this.worldObj, this.rand, x, z, this.terrainType);
    }

    public static class Start extends StructureStart
        {
            /** well ... thats what it does */
            private boolean hasMoreThanTwoComponents;

            public Start() {}

            public Start(World worldIn, Random random, int par3, int par4, int par5)
            {
                super(par3, par4);
                List list = StructureNetherVillagePieces.getStructureVillageWeightedPieceList(random, par5);
                StructureNetherVillagePieces.Start start = new StructureNetherVillagePieces.Start(worldIn.getWorldChunkManager(), 0, random, (par3 << 4) + 2, (par4 << 4) + 2, list, par5);
                this.components.add(start);
                start.buildComponent(start, this.components, random);
                List list1 = start.field_74930_j;
                List list2 = start.field_74932_i;
                int l;

                while (!list1.isEmpty() || !list2.isEmpty())
                {
                    StructureComponent structurecomponent;

                    if (list1.isEmpty())
                    {
                        l = random.nextInt(list2.size());
                        structurecomponent = (StructureComponent)list2.remove(l);
                        structurecomponent.buildComponent(start, this.components, random);
                    }
                    else
                    {
                        l = random.nextInt(list1.size());
                        structurecomponent = (StructureComponent)list1.remove(l);
                        structurecomponent.buildComponent(start, this.components, random);
                    }
                }

                this.updateBoundingBox();
                l = 0;
                Iterator iterator = this.components.iterator();

                while (iterator.hasNext())
                {
                    StructureComponent structurecomponent1 = (StructureComponent)iterator.next();

                    if (!(structurecomponent1 instanceof StructureNetherVillagePieces.Road))
                    {
                        ++l;
                    }
                }

                this.hasMoreThanTwoComponents = l > 2;
            }

            /**
             * currently only defined for Villages, returns true if Village has more than 2 non-road components
             */
            public boolean isSizeableStructure()
            {
                return this.hasMoreThanTwoComponents;
            }

            public void func_143022_a(NBTTagCompound nbtt)
            {
                super.func_143022_a(nbtt);
                nbtt.setBoolean("Valid", this.hasMoreThanTwoComponents);
            }

            public void func_143017_b(NBTTagCompound nbtt)
            {
                super.func_143017_b(nbtt);
                this.hasMoreThanTwoComponents = nbtt.getBoolean("Valid");
            }
        }
}

and this class

package blaze.world.village;

import static net.minecraftforge.common.ChestGenHooks.VILLAGE_BLACKSMITH;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

import com.google.common.collect.Lists;

import net.minecraft.block.Block;
import net.minecraft.block.BlockSandStone;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.WorldChunkManager;
import net.minecraft.world.gen.structure.MapGenStructureIO;
import net.minecraft.world.gen.structure.MapGenVillage;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.BiomeEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;

public class StructureNetherVillagePieces extends StructureVillagePieces
{

    public static void registerVillagePieces()
    {
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.House1.class, "ViBH");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.Field1.class, "ViDF");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.Field2.class, "ViF");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.Torch.class, "ViL");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.Hall.class, "ViPH");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.House4Garden.class, "ViSH");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.WoodHut.class, "ViSmH");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.Church.class, "ViST");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.House2.class, "ViS");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.Start.class, "ViStart");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.Path.class, "ViSR");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.House3.class, "ViTRH");
        MapGenStructureIO.registerStructureComponent(StructureNetherVillagePieces.Well.class, "ViW");
    }

    public static List getStructureVillageWeightedPieceList(Random random, int par2)
    {
        ArrayList arraylist = Lists.newArrayList();
        arraylist.add(new StructureNetherVillagePieces.PieceWeight(StructureNetherVillagePieces.House4Garden.class, 4, MathHelper.getRandomIntegerInRange(random, 2 + par2, 4 + par2 * 2)));
        arraylist.add(new StructureNetherVillagePieces.PieceWeight(StructureNetherVillagePieces.Church.class, 20, MathHelper.getRandomIntegerInRange(random, 0 + par2, 1 + par2)));
        arraylist.add(new StructureNetherVillagePieces.PieceWeight(StructureNetherVillagePieces.House1.class, 20, MathHelper.getRandomIntegerInRange(random, 0 + par2, 2 + par2)));
        arraylist.add(new StructureNetherVillagePieces.PieceWeight(StructureNetherVillagePieces.WoodHut.class, 3, MathHelper.getRandomIntegerInRange(random, 2 + par2, 5 + par2 * 3)));
        arraylist.add(new StructureNetherVillagePieces.PieceWeight(StructureNetherVillagePieces.Hall.class, 15, MathHelper.getRandomIntegerInRange(random, 0 + par2, 2 + par2)));
        arraylist.add(new StructureNetherVillagePieces.PieceWeight(StructureNetherVillagePieces.Field1.class, 3, MathHelper.getRandomIntegerInRange(random, 1 + par2, 4 + par2)));
        arraylist.add(new StructureNetherVillagePieces.PieceWeight(StructureNetherVillagePieces.Field2.class, 3, MathHelper.getRandomIntegerInRange(random, 2 + par2, 4 + par2 * 2)));
        arraylist.add(new StructureNetherVillagePieces.PieceWeight(StructureNetherVillagePieces.House2.class, 15, MathHelper.getRandomIntegerInRange(random, 0, 1 + par2)));
        arraylist.add(new StructureNetherVillagePieces.PieceWeight(StructureNetherVillagePieces.House3.class, 8, MathHelper.getRandomIntegerInRange(random, 0 + par2, 3 + par2 * 2)));
        net.minecraftforge.fml.common.registry.VillagerRegistry.addExtraVillageComponents(arraylist, random, par2);

        Iterator iterator = arraylist.iterator();

        while (iterator.hasNext())
        {
            if (((StructureNetherVillagePieces.PieceWeight)iterator.next()).villagePiecesLimit == 0)
            {
                iterator.remove();
            }
        }

        return arraylist;
    }

    private static int func_75079_a(List list)
    {
        boolean flag = false;
        int i = 0;
        StructureNetherVillagePieces.PieceWeight pieceweight;

        for (Iterator iterator = list.iterator(); iterator.hasNext(); i += pieceweight.villagePieceWeight)
        {
            pieceweight = (StructureNetherVillagePieces.PieceWeight)iterator.next();

            if (pieceweight.villagePiecesLimit > 0 && pieceweight.villagePiecesSpawned < pieceweight.villagePiecesLimit)
            {
                flag = true;
            }
        }

        return flag ? i : -1;
    }

    private static StructureNetherVillagePieces.Village func_176065_a(StructureNetherVillagePieces.Start start, StructureNetherVillagePieces.PieceWeight weight, List list, Random random, int par4, int par5, int par6, EnumFacing side, int par8)
    {
        Class oclass = weight.villagePieceClass;
        Object object = null;

        if (oclass == StructureNetherVillagePieces.House4Garden.class)
        {
            object = StructureNetherVillagePieces.House4Garden.func_175858_a(start, list, random, par4, par5, par6, side, par8);
        }
        else if (oclass == StructureNetherVillagePieces.Church.class)
        {
            object = StructureNetherVillagePieces.Church.func_175854_a(start, list, random, par4, par5, par6, side, par8);
        }
        else if (oclass == StructureNetherVillagePieces.House1.class)
        {
            object = StructureNetherVillagePieces.House1.func_175850_a(start, list, random, par4, par5, par6, side, par8);
        }
        else if (oclass == StructureNetherVillagePieces.WoodHut.class)
        {
            object = StructureNetherVillagePieces.WoodHut.func_175853_a(start, list, random, par4, par5, par6, side, par8);
        }
        else if (oclass == StructureNetherVillagePieces.Hall.class)
        {
            object = StructureNetherVillagePieces.Hall.func_175857_a(start, list, random, par4, par5, par6, side, par8);
        }
        else if (oclass == StructureNetherVillagePieces.Field1.class)
        {
            object = StructureNetherVillagePieces.Field1.func_175851_a(start, list, random, par4, par5, par6, side, par8);
        }
        else if (oclass == StructureNetherVillagePieces.Field2.class)
        {
            object = StructureNetherVillagePieces.Field2.func_175852_a(start, list, random, par4, par5, par6, side, par8);
        }
        else if (oclass == StructureNetherVillagePieces.House2.class)
        {
            object = StructureNetherVillagePieces.House2.func_175855_a(start, list, random, par4, par5, par6, side, par8);
        }
        else if (oclass == StructureNetherVillagePieces.House3.class)
        {
            object = StructureNetherVillagePieces.House3.func_175849_a(start, list, random, par4, par5, par6, side, par8);
        }
        /*else
        {
            object = net.minecraftforge.fml.common.registry.VillagerRegistry.getVillageComponent((StructureVillagePieces.PieceWeight)p_176065_1_, p_176065_0_ , p_176065_2_, p_176065_3_, p_176065_4_, p_176065_5_, p_176065_6_, p_176065_7_, p_176065_8_);
        }*/
        //THIS RETURNS ME AN ERROR
        return (StructureNetherVillagePieces.Village)object;
    }

    private static StructureNetherVillagePieces.Village func_176067_c(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, int par5, EnumFacing side, int par7)
    {
        int i1 = func_75079_a(start.structureVillageWeightedPieceList);

        if (i1 <= 0)
        {
            return null;
        }
        else
        {
            int j1 = 0;

            while (j1 < 5)
            {
                ++j1;
                int k1 = random.nextInt(i1);
                Iterator iterator = start.structureVillageWeightedPieceList.iterator();

                while (iterator.hasNext())
                {
                    StructureNetherVillagePieces.PieceWeight pieceweight = (StructureNetherVillagePieces.PieceWeight)iterator.next();
                    k1 -= pieceweight.villagePieceWeight;

                    if (k1 < 0)
                    {
                        if (!pieceweight.canSpawnMoreVillagePiecesOfType(par7) || pieceweight == start.structVillagePieceWeight && start.structureVillageWeightedPieceList.size() > 1)
                        {
                            break;
                        }

                        StructureNetherVillagePieces.Village village = func_176065_a(start, pieceweight, list, random, par3, par4, par5, side, par7);

                        if (village != null)
                        {
                            ++pieceweight.villagePiecesSpawned;
                            start.structVillagePieceWeight = pieceweight;

                            if (!pieceweight.canSpawnMoreVillagePieces())
                            {
                                start.structureVillageWeightedPieceList.remove(pieceweight);
                            }

                            return village;
                        }
                    }
                }
            }

            StructureBoundingBox structureboundingbox = StructureNetherVillagePieces.Torch.func_175856_a(start, list, random, par3, par4, par5, side);

            if (structureboundingbox != null)
            {
                return new StructureNetherVillagePieces.Torch(start, par7, random, structureboundingbox, side);
            }
            else
            {
                return null;
            }
        }
    }

    private static StructureComponent func_176066_d(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, int par5, EnumFacing side, int par7)
    {
        if (par7 > 50)
        {
            return null;
        }
        else if (Math.abs(par3 - start.getBoundingBox().minX) <= 112 && Math.abs(par5 - start.getBoundingBox().minZ) <= 112)
        {
            StructureNetherVillagePieces.Village village = func_176067_c(start, list, random, par3, par4, par5, side, par7 + 1);

            if (village != null)
            {
                int i1 = (village.getBoundingBox().minX + village.getBoundingBox().maxX) / 2;
                int j1 = (village.getBoundingBox().minZ + village.getBoundingBox().maxZ) / 2;
                int k1 = village.getBoundingBox().maxX - village.getBoundingBox().minX;
                int l1 = village.getBoundingBox().maxZ - village.getBoundingBox().minZ;
                int i2 = k1 > l1 ? k1 : l1;

                if (start.getWorldChunkManager().areBiomesViable(i1, j1, i2 / 2 + 4, MapGenVillage.villageSpawnBiomes))
                {
                    list.add(village);
                    start.field_74932_i.add(village);
                    return village;
                }
            }

            return null;
        }
        else
        {
            return null;
        }
    }

    private static StructureComponent func_176069_e(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, int par5, EnumFacing side, int par7)
    {
        if (par7 > 3 + start.terrainType)
        {
            return null;
        }
        else if (Math.abs(par3 - start.getBoundingBox().minX) <= 112 && Math.abs(par5 - start.getBoundingBox().minZ) <= 112)
        {
            StructureBoundingBox structureboundingbox = StructureNetherVillagePieces.Path.func_175848_a(start, list, random, par3, par4, par5, side);

            if (structureboundingbox != null && structureboundingbox.minY > 10)
            {
                StructureNetherVillagePieces.Path path = new StructureNetherVillagePieces.Path(start, par7, random, structureboundingbox, side);
                int i1 = (path.getBoundingBox().minX + path.getBoundingBox().maxX) / 2;
                int j1 = (path.getBoundingBox().minZ + path.getBoundingBox().maxZ) / 2;
                int k1 = path.getBoundingBox().maxX - path.getBoundingBox().minX;
                int l1 = path.getBoundingBox().maxZ - path.getBoundingBox().minZ;
                int i2 = k1 > l1 ? k1 : l1;

                if (start.getWorldChunkManager().areBiomesViable(i1, j1, i2 / 2 + 4, MapGenVillage.villageSpawnBiomes))
                {
                    list.add(path);
                    start.field_74930_j.add(path);
                    return path;
                }
            }

            return null;
        }
        else
        {
            return null;
        }
    }

    public static class Church extends StructureNetherVillagePieces.Village
        {

            public Church() {}

            public Church(StructureNetherVillagePieces.Start start, int par2, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par2);
                this.coordBaseMode = side;
                this.boundingBox = box;
            }

            public static StructureNetherVillagePieces.Church func_175854_a(StructureNetherVillagePieces.Start p_175854_0_, List p_175854_1_, Random p_175854_2_, int p_175854_3_, int p_175854_4_, int p_175854_5_, EnumFacing p_175854_6_, int p_175854_7_)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(p_175854_3_, p_175854_4_, p_175854_5_, 0, 0, 0, 5, 12, 9, p_175854_6_);
                return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(p_175854_1_, structureboundingbox) == null ? new StructureNetherVillagePieces.Church(p_175854_0_, p_175854_7_, p_175854_2_, structureboundingbox, p_175854_6_) : null;
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);
                    
                    System.out.println("GROUND: " +this.field_143015_k);
                    //TEST PRINT TO SEE WHAT GROUND LEVEL CALCULATES
                    
                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 12 - 1, 0);
                }

                this.func_175804_a(worldIn, box, 1, 1, 1, 3, 3, 7, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 5, 1, 3, 9, 3, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 0, 3, 0, 8, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 1, 0, 3, 10, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 1, 1, 0, 10, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 4, 1, 1, 4, 10, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 0, 4, 0, 4, 7, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 4, 0, 4, 4, 4, 7, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 1, 8, 3, 4, 8, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 5, 4, 3, 10, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 5, 5, 3, 5, 7, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 9, 0, 4, 9, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 4, 0, 4, 4, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 11, 2, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 4, 11, 2, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 2, 11, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 2, 11, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 1, 1, 6, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 1, 1, 7, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 2, 1, 7, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 3, 1, 6, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 3, 1, 7, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 1, 1, 5, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 2, 1, 6, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 3, 1, 5, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 1)), 1, 2, 7, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 0)), 3, 2, 7, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 3, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 4, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 4, 3, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 6, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 7, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 4, 6, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 4, 7, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 6, 0, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 7, 0, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 6, 4, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 7, 4, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 3, 6, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 4, 3, 6, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 3, 8, box);
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode.getOpposite()), 2, 4, 7, box);
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode.rotateY()), 1, 4, 6, box);
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode.rotateYCCW()), 3, 4, 6, box);
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode), 2, 4, 5, box);
                int i = this.getMetadataWithOffset(Blocks.ladder, 4);
                int j;

                for (j = 1; j <= 9; ++j)
                {
                    this.func_175811_a(worldIn, Blocks.ladder.getStateFromMeta(i), 3, j, 3, box);
                }

                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 2, 1, 0, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 2, 2, 0, box);
                this.func_175810_a(worldIn, box, random, 2, 1, 0, EnumFacing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1)));

                if (this.func_175807_a(worldIn, 2, 0, -1, box).getBlock().getMaterial() == Material.air && this.func_175807_a(worldIn, 2, -1, -1, box).getBlock().getMaterial() != Material.air)
                {
                    this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 2, 0, -1, box);
                }

                for (j = 0; j < 9; ++j)
                {
                    for (int k = 0; k < 5; ++k)
                    {
                        this.clearCurrentPositionBlocksUpwards(worldIn, k, 12, j, box);
                        this.func_175808_b(worldIn, Blocks.nether_brick.getDefaultState(), k, -1, j, box);
                    }
                }

                this.spawnVillagers(worldIn, box, 2, 1, 2, 1);
                return true;
            }

            protected int func_180779_c(int par1, int par2)
            {
                return 2;
            }
        }

    public static class Field1 extends StructureNetherVillagePieces.Village
        {
            /** First crop type for this field. */
            private Block cropTypeA;
            /** Second crop type for this field. */
            private Block cropTypeB;
            /** Third crop type for this field. */
            private Block cropTypeC;
            /** Fourth crop type for this field. */
            private Block cropTypeD;

            public Field1() {}

            public Field1(StructureNetherVillagePieces.Start start, int par2, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par2);
                this.coordBaseMode = side;
                this.boundingBox = box;
                this.cropTypeA = this.func_151559_a(random);
                this.cropTypeB = this.func_151559_a(random);
                this.cropTypeC = this.func_151559_a(random);
                this.cropTypeD = this.func_151559_a(random);
            }

            /**
             * (abstract) Helper method to write subclass data to NBT
             */
            protected void writeStructureToNBT(NBTTagCompound nbtt)
            {
                super.writeStructureToNBT(nbtt);
                nbtt.setInteger("CA", Block.blockRegistry.getIDForObject(this.cropTypeA));
                nbtt.setInteger("CB", Block.blockRegistry.getIDForObject(this.cropTypeB));
                nbtt.setInteger("CC", Block.blockRegistry.getIDForObject(this.cropTypeC));
                nbtt.setInteger("CD", Block.blockRegistry.getIDForObject(this.cropTypeD));
            }

            /**
             * (abstract) Helper method to read subclass data from NBT
             */
            protected void readStructureFromNBT(NBTTagCompound nbtt)
            {
                super.readStructureFromNBT(nbtt);
                this.cropTypeA = Block.getBlockById(nbtt.getInteger("CA"));
                this.cropTypeB = Block.getBlockById(nbtt.getInteger("CB"));
                this.cropTypeC = Block.getBlockById(nbtt.getInteger("CC"));
                this.cropTypeD = Block.getBlockById(nbtt.getInteger("CD"));
            }

            private Block func_151559_a(Random random)
            {
                switch (random.nextInt(5))
                {
                    case 0:
                        return Blocks.nether_wart;
                    case 1:
                        return Blocks.nether_wart;
                    default:
                        return Blocks.nether_wart;
                }
            }

            public static StructureNetherVillagePieces.Field1 func_175851_a(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, int par5, EnumFacing side, int par7)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(par3, par4, par5, 0, 0, 0, 13, 4, 9, side);
                return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(list, structureboundingbox) == null ? new StructureNetherVillagePieces.Field1(start, par7, random, structureboundingbox, side) : null;
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);

                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 4 - 1, 0);
                }

                this.func_175804_a(worldIn, box, 0, 1, 0, 12, 4, 8, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 1, 2, 0, 7, Blocks.soul_sand.getDefaultState(), Blocks.soul_sand.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 4, 0, 1, 5, 0, 7, Blocks.soul_sand.getDefaultState(), Blocks.soul_sand.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 7, 0, 1, 8, 0, 7, Blocks.soul_sand.getDefaultState(), Blocks.soul_sand.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 10, 0, 1, 11, 0, 7, Blocks.soul_sand.getDefaultState(), Blocks.soul_sand.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 0, 0, 0, 0, 8, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 6, 0, 0, 6, 0, 8, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 12, 0, 0, 12, 0, 8, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 0, 11, 0, 0, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 8, 11, 0, 8, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 3, 0, 1, 3, 0, 7, Blocks.lava.getDefaultState(), Blocks.lava.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 9, 0, 1, 9, 0, 7, Blocks.lava.getDefaultState(), Blocks.lava.getDefaultState(), false);
                int i;

                for (i = 1; i <= 7; ++i)
                {
                    this.func_175811_a(worldIn, this.cropTypeA.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 1, 1, i, box);
                    this.func_175811_a(worldIn, this.cropTypeA.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 2, 1, i, box);
                    this.func_175811_a(worldIn, this.cropTypeB.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 4, 1, i, box);
                    this.func_175811_a(worldIn, this.cropTypeB.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 5, 1, i, box);
                    this.func_175811_a(worldIn, this.cropTypeC.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 7, 1, i, box);
                    this.func_175811_a(worldIn, this.cropTypeC.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 8, 1, i, box);
                    this.func_175811_a(worldIn, this.cropTypeD.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 10, 1, i, box);
                    this.func_175811_a(worldIn, this.cropTypeD.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 11, 1, i, box);
                }

                for (i = 0; i < 9; ++i)
                {
                    for (int j = 0; j < 13; ++j)
                    {
                        this.clearCurrentPositionBlocksUpwards(worldIn, j, 4, i, box);
                        this.func_175808_b(worldIn, Blocks.netherrack.getDefaultState(), j, -1, i, box);
                    }
                }

                return true;
            }
        }

    public static class Field2 extends StructureNetherVillagePieces.Village
        {
            /** First crop type for this field. */
            private Block cropTypeA;
            /** Second crop type for this field. */
            private Block cropTypeB;

            public Field2() {}

            public Field2(StructureNetherVillagePieces.Start start, int par2, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par2);
                this.coordBaseMode = side;
                this.boundingBox = box;
                this.cropTypeA = this.func_151560_a(random);
                this.cropTypeB = this.func_151560_a(random);
            }

            /**
             * (abstract) Helper method to write subclass data to NBT
             */
            protected void writeStructureToNBT(NBTTagCompound nbtt)
            {
                super.writeStructureToNBT(nbtt);
                nbtt.setInteger("CA", Block.blockRegistry.getIDForObject(this.cropTypeA));
                nbtt.setInteger("CB", Block.blockRegistry.getIDForObject(this.cropTypeB));
            }

            /**
             * (abstract) Helper method to read subclass data from NBT
             */
            protected void readStructureFromNBT(NBTTagCompound nbtt)
            {
                super.readStructureFromNBT(nbtt);
                this.cropTypeA = Block.getBlockById(nbtt.getInteger("CA"));
                this.cropTypeB = Block.getBlockById(nbtt.getInteger("CB"));
            }

            private Block func_151560_a(Random random)
            {
                switch (random.nextInt(5))
                {
                    case 0:
                        return Blocks.nether_wart;
                    case 1:
                        return Blocks.nether_wart;
                    default:
                        return Blocks.nether_wart;
                }
            }

            public static StructureNetherVillagePieces.Field2 func_175852_a(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, 
            		int par5, EnumFacing side, int par7)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(par3, par4, par5, 0, 0, 0, 7, 4, 9, side);
                return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(list, structureboundingbox) == null ? new StructureNetherVillagePieces.Field2(start, par7, random, structureboundingbox, side) : null;
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);

                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 4 - 1, 0);
                }

                this.func_175804_a(worldIn, box, 0, 1, 0, 6, 4, 8, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 1, 2, 0, 7, Blocks.soul_sand.getDefaultState(), Blocks.soul_sand.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 4, 0, 1, 5, 0, 7, Blocks.soul_sand.getDefaultState(), Blocks.soul_sand.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 0, 0, 0, 0, 8, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 6, 0, 0, 6, 0, 8, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 0, 5, 0, 0, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 8, 5, 0, 8, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 3, 0, 1, 3, 0, 7, Blocks.lava.getDefaultState(), Blocks.lava.getDefaultState(), false);
                int i;

                for (i = 1; i <= 7; ++i)
                {
                    this.func_175811_a(worldIn, this.cropTypeA.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 1, 1, i, box);
                    this.func_175811_a(worldIn, this.cropTypeA.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 2, 1, i, box);
                    this.func_175811_a(worldIn, this.cropTypeB.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 4, 1, i, box);
                    this.func_175811_a(worldIn, this.cropTypeB.getStateFromMeta(MathHelper.getRandomIntegerInRange(random, 2, 7)), 5, 1, i, box);
                }

                for (i = 0; i < 9; ++i)
                {
                    for (int j = 0; j < 7; ++j)
                    {
                        this.clearCurrentPositionBlocksUpwards(worldIn, j, 4, i, box);
                        this.func_175808_b(worldIn, Blocks.netherrack.getDefaultState(), j, -1, i, box);
                    }
                }

                return true;
            }
        }

    public static class Hall extends StructureNetherVillagePieces.Village
        {

            public Hall() {}

            public Hall(StructureNetherVillagePieces.Start start, int par2, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par2);
                this.coordBaseMode = side;
                this.boundingBox = box;
            }

            public static StructureNetherVillagePieces.Hall func_175857_a(StructureNetherVillagePieces.Start p_175857_0_, List p_175857_1_, Random p_175857_2_, int p_175857_3_, int p_175857_4_, int p_175857_5_, EnumFacing p_175857_6_, int p_175857_7_)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(p_175857_3_, p_175857_4_, p_175857_5_, 0, 0, 0, 9, 7, 11, p_175857_6_);
                return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(p_175857_1_, structureboundingbox) == null ? new StructureNetherVillagePieces.Hall(p_175857_0_, p_175857_7_, p_175857_2_, structureboundingbox, p_175857_6_) : null;
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random par2, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);

                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 7 - 1, 0);
                }

                this.func_175804_a(worldIn, box, 1, 1, 1, 7, 4, 4, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 2, 1, 6, 8, 4, 10, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 2, 0, 6, 8, 0, 10, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 6, 0, 6, box);
                this.func_175804_a(worldIn, box, 2, 1, 6, 2, 1, 10, Blocks.nether_brick_fence.getDefaultState(), Blocks.nether_brick_fence.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 8, 1, 6, 8, 1, 10, Blocks.nether_brick_fence.getDefaultState(), Blocks.nether_brick_fence.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 3, 1, 10, 7, 1, 10, Blocks.nether_brick_fence.getDefaultState(), Blocks.nether_brick_fence.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 1, 7, 0, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 0, 0, 0, 3, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 8, 0, 0, 8, 3, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 0, 7, 1, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 5, 7, 1, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 2, 0, 7, 3, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 2, 5, 7, 3, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 4, 1, 8, 4, 1, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 4, 4, 8, 4, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 5, 2, 8, 5, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 4, 2, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 4, 3, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 8, 4, 2, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 8, 4, 3, box);
                int i = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3);
                int j = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 2);
                int k;
                int l;

                for (k = -1; k <= 2; ++k)
                {
                    for (l = 0; l <= 8; ++l)
                    {
                        this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(i), l, 4 + k, k, box);
                        this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(j), l, 4 + k, 5 - k, box);
                    }
                }
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 0, 2, 1, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 0, 2, 4, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 8, 2, 1, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 8, 2, 4, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 3, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 8, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 8, 2, 3, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 2, 5, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 3, 2, 5, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 5, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 6, 2, 5, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 2, 1, 3, box);
                this.func_175811_a(worldIn, Blocks.stone_pressure_plate.getDefaultState(), 2, 2, 3, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 1, 1, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 2, 1, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 1)), 1, 1, 3, box);
                this.func_175804_a(worldIn, box, 5, 0, 1, 7, 0, 3, Blocks.double_stone_slab.getDefaultState(), Blocks.double_stone_slab.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.double_stone_slab.getDefaultState(), 6, 1, 1, box);
                this.func_175811_a(worldIn, Blocks.double_stone_slab.getDefaultState(), 6, 1, 2, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 2, 1, 0, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 2, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode), 2, 3, 1, box);
                this.func_175810_a(worldIn, box, par2, 2, 1, 0, EnumFacing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1)));

                if (this.func_175807_a(worldIn, 2, 0, -1, box).getBlock().getMaterial() == Material.air && this.func_175807_a(worldIn, 2, -1, -1, box).getBlock().getMaterial() != Material.air)
                {
                    this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 2, 0, -1, box);
                }

                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 6, 1, 5, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 6, 2, 5, box);
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode.getOpposite()), 6, 3, 4, box);
                this.func_175810_a(worldIn, box, par2, 6, 1, 5, EnumFacing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1)));

                for (k = 0; k < 5; ++k)
                {
                    for (l = 0; l < 9; ++l)
                    {
                        this.clearCurrentPositionBlocksUpwards(worldIn, l, 7, k, box);
                        this.func_175808_b(worldIn, Blocks.nether_brick.getDefaultState(), l, -1, k, box);
                    }
                }

                this.spawnVillagers(worldIn, box, 4, 1, 2, 2);
                return true;
            }

            protected int func_180779_c(int par1, int par2)
            {
                return par1 == 0 ? 4 : super.func_180779_c(par1, par2);
            }
        }

    public static class House1 extends StructureNetherVillagePieces.Village
        {

            public House1() {}

            public House1(StructureNetherVillagePieces.Start start, int par1, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par1);
                this.coordBaseMode = side;
                this.boundingBox = box;
            }

            public static StructureNetherVillagePieces.House1 func_175850_a(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, int par5, EnumFacing side, int par7)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(par3, par4, par5, 0, 0, 0, 9, 9, 6, side);
                return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(list, structureboundingbox) == null ? new StructureNetherVillagePieces.House1(start, par7, random, structureboundingbox, side) : null;
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);

                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 9 - 1, 0);
                }

                this.func_175804_a(worldIn, box, 1, 1, 1, 7, 5, 4, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 0, 0, 8, 0, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 5, 0, 8, 5, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 6, 1, 8, 6, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 7, 2, 8, 7, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                int i = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3);
                int j = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 2);
                int k;
                int l;

                for (k = -1; k <= 2; ++k)
                {
                    for (l = 0; l <= 8; ++l)
                    {
                        this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(i), l, 6 + k, k, box);
                        this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(j), l, 6 + k, 5 - k, box);
                    }
                }

                this.func_175804_a(worldIn, box, 0, 1, 0, 0, 1, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 1, 5, 8, 1, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 8, 1, 0, 8, 1, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 2, 1, 0, 7, 1, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 2, 0, 0, 4, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 2, 5, 0, 4, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 8, 2, 5, 8, 4, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 8, 2, 0, 8, 4, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 2, 1, 0, 4, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 2, 5, 7, 4, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 8, 2, 1, 8, 4, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 2, 0, 7, 4, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 4, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 5, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 6, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 4, 3, 0, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 5, 3, 0, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 6, 3, 0, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 3, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 3, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 3, 3, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 8, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 8, 2, 3, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 8, 3, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 8, 3, 3, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 2, 5, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 3, 2, 5, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 5, 2, 5, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 6, 2, 5, box);
                this.func_175804_a(worldIn, box, 1, 4, 1, 7, 4, 1, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 4, 4, 7, 4, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 3, 4, 7, 3, 4, Blocks.bookshelf.getDefaultState(), Blocks.bookshelf.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 7, 1, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 0)), 7, 1, 3, box);
                k = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(k), 6, 1, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(k), 5, 1, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(k), 4, 1, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(k), 3, 1, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 6, 1, 3, box);
                this.func_175811_a(worldIn, Blocks.stone_pressure_plate.getDefaultState(), 6, 2, 3, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 4, 1, 3, box);
                this.func_175811_a(worldIn, Blocks.stone_pressure_plate.getDefaultState(), 4, 2, 3, box);
                this.func_175811_a(worldIn, Blocks.crafting_table.getDefaultState(), 7, 1, 1, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 1, 1, 0, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 1, 2, 0, box);
                this.func_175810_a(worldIn, box, random, 1, 1, 0, EnumFacing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1)));

                if (this.func_175807_a(worldIn, 1, 0, -1, box).getBlock().getMaterial() == Material.air && this.func_175807_a(worldIn, 1, -1, -1, box).getBlock().getMaterial() != Material.air)
                {
                    this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 1, 0, -1, box);
                }

                for (l = 0; l < 6; ++l)
                {
                    for (int i1 = 0; i1 < 9; ++i1)
                    {
                        this.clearCurrentPositionBlocksUpwards(worldIn, i1, 9, l, box);
                        this.func_175808_b(worldIn, Blocks.nether_brick.getDefaultState(), i1, -1, l, box);
                    }
                }

                this.spawnVillagers(worldIn, box, 2, 1, 2, 1);
                return true;
            }

            protected int func_180779_c(int p_180779_1_, int p_180779_2_)
            {
                return 1;
            }
        }

    public static class House2 extends StructureNetherVillagePieces.Village
        {
            /** List of items that Village's Blacksmith chest can contain. */
            private static final List villageBlacksmithChestContents = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.diamond, 0, 1, 3, 3), new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), new WeightedRandomChestContent(Items.gold_ingot, 0, 1, 3, 5), new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), new WeightedRandomChestContent(Items.apple, 0, 1, 3, 15), new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_sword, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_chestplate, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_helmet, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_leggings, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_boots, 0, 1, 1, 5), new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.obsidian), 0, 3, 7, 5), new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.sapling), 0, 3, 7, 5), new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 3), new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 1), new WeightedRandomChestContent(Items.golden_horse_armor, 0, 1, 1, 1), new WeightedRandomChestContent(Items.diamond_horse_armor, 0, 1, 1, 1)});
            private boolean hasMadeChest;

            public House2() {}

            static
            {
                ChestGenHooks.init(VILLAGE_BLACKSMITH, villageBlacksmithChestContents, 3, ;
            }

            public House2(StructureNetherVillagePieces.Start start, int par2, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par2);
                this.coordBaseMode = side;
                this.boundingBox = box;
            }

            public static StructureNetherVillagePieces.House2 func_175855_a(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, int par5, EnumFacing side, int par7)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(par3, par4, par5, 0, 0, 0, 10, 6, 7, side);
                return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(list, structureboundingbox) == null ? new StructureNetherVillagePieces.House2(start, par7, random, structureboundingbox, side) : null;
            }

            /**
             * (abstract) Helper method to write subclass data to NBT
             */
            protected void writeStructureToNBT(NBTTagCompound nbtt)
            {
                super.writeStructureToNBT(nbtt);
                nbtt.setBoolean("Chest", this.hasMadeChest);
            }

            /**
             * (abstract) Helper method to read subclass data from NBT
             */
            protected void readStructureFromNBT(NBTTagCompound nbtt)
            {
                super.readStructureFromNBT(nbtt);
                this.hasMadeChest = nbtt.getBoolean("Chest");
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);

                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 6 - 1, 0);
                }

                this.func_175804_a(worldIn, box, 0, 1, 0, 9, 4, 6, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 0, 0, 9, 0, 6, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 4, 0, 9, 4, 6, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 5, 0, 9, 5, 6, Blocks.stone_slab.getDefaultState(), Blocks.stone_slab.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 5, 1, 8, 5, 5, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 1, 0, 2, 3, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 1, 0, 0, 4, 0, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 3, 1, 0, 3, 4, 0, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 1, 6, 0, 4, 6, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 3, 3, 1, box);
                this.func_175804_a(worldIn, box, 3, 1, 2, 3, 3, 2, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 4, 1, 3, 5, 3, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 1, 1, 0, 3, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 1, 6, 5, 3, 6, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 5, 1, 0, 5, 3, 0, Blocks.nether_brick_fence.getDefaultState(), Blocks.nether_brick_fence.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 9, 1, 0, 9, 3, 0, Blocks.nether_brick_fence.getDefaultState(), Blocks.nether_brick_fence.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 6, 1, 4, 9, 4, 6, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.flowing_lava.getDefaultState(), 7, 1, 5, box);
                this.func_175811_a(worldIn, Blocks.flowing_lava.getDefaultState(), 8, 1, 5, box);
                this.func_175811_a(worldIn, Blocks.iron_bars.getDefaultState(), 9, 2, 5, box);
                this.func_175811_a(worldIn, Blocks.iron_bars.getDefaultState(), 9, 2, 4, box);
                this.func_175804_a(worldIn, box, 7, 2, 4, 8, 2, 5, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 6, 1, 3, box);
                this.func_175811_a(worldIn, Blocks.furnace.getDefaultState(), 6, 2, 3, box);
                this.func_175811_a(worldIn, Blocks.furnace.getDefaultState(), 6, 3, 3, box);
                this.func_175811_a(worldIn, Blocks.double_stone_slab.getDefaultState(), 8, 1, 1, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 4, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 2, 6, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 4, 2, 6, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 2, 1, 4, box);
                this.func_175811_a(worldIn, Blocks.stone_pressure_plate.getDefaultState(), 2, 2, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 1, 1, 5, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 2, 1, 5, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 1)), 1, 1, 4, box);

                if (!this.hasMadeChest && box.func_175898_b(new BlockPos(this.getXWithOffset(5, 5), this.getYWithOffset(1), this.getZWithOffset(5, 5))))
                {
                    this.hasMadeChest = true;
                    this.func_180778_a(worldIn, box, random, 5, 1, 5, ChestGenHooks.getItems(VILLAGE_BLACKSMITH, random), ChestGenHooks.getCount(VILLAGE_BLACKSMITH, random));
                }

                int i;

                for (i = 6; i <= 8; ++i)
                {
                    if (this.func_175807_a(worldIn, i, 0, -1, box).getBlock().getMaterial() == Material.air && this.func_175807_a(worldIn, i, -1, -1, box).getBlock().getMaterial() != Material.air)
                    {
                        this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), i, 0, -1, box);
                    }
                }

                for (i = 0; i < 7; ++i)
                {
                    for (int j = 0; j < 10; ++j)
                    {
                        this.clearCurrentPositionBlocksUpwards(worldIn, j, 6, i, box);
                        this.func_175808_b(worldIn, Blocks.nether_brick.getDefaultState(), j, -1, i, box);
                    }
                }

                this.spawnVillagers(worldIn, box, 7, 1, 1, 1);
                return true;
            }

            protected int func_180779_c(int par1, int par2)
            {
                return 3;
            }
        }

    public static class House3 extends StructureNetherVillagePieces.Village
        {

            public House3() {}

            public House3(StructureNetherVillagePieces.Start start, int par2, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par2);
                this.coordBaseMode = side;
                this.boundingBox = box;
            }

            public static StructureNetherVillagePieces.House3 func_175849_a(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, int par5, EnumFacing side, int par7)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(par3, par4, par5, 0, 0, 0, 9, 7, 12, side);
                return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(list, structureboundingbox) == null ? new StructureNetherVillagePieces.House3(start, par7, random, structureboundingbox, side) : null;
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);

                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 7 - 1, 0);
                }

                this.func_175804_a(worldIn, box, 1, 1, 1, 7, 4, 4, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 2, 1, 6, 8, 4, 10, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 2, 0, 5, 8, 0, 10, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 1, 7, 0, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 0, 0, 0, 3, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 8, 0, 0, 8, 3, 10, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 0, 7, 2, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 5, 2, 1, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 2, 0, 6, 2, 3, 10, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 3, 0, 10, 7, 3, 10, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 2, 0, 7, 3, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 2, 5, 2, 3, 5, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 4, 1, 8, 4, 1, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 4, 4, 3, 4, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 5, 2, 8, 5, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 4, 2, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 4, 3, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 8, 4, 2, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 8, 4, 3, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 8, 4, 4, box);
                int i = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3);
                int j = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 2);
                int k;
                int l;

                for (k = -1; k <= 2; ++k)
                {
                    for (l = 0; l <= 8; ++l)
                    {
                        this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(i), l, 4 + k, k, box);

                        if ((k > -1 || l <= 1) && (k > 0 || l <= 3) && (k > 1 || l <= 4 || l >= 6))
                        {
                            this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(j), l, 4 + k, 5 - k, box);
                        }
                    }
                }

                this.func_175804_a(worldIn, box, 3, 4, 5, 3, 4, 10, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 7, 4, 2, 7, 4, 10, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 4, 5, 4, 4, 5, 10, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 6, 5, 4, 6, 5, 10, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 5, 6, 3, 5, 6, 10, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                k = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 0);
                int i1;

                for (l = 4; l >= 1; --l)
                {
                    this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), l, 2 + l, 7 - l, box);

                    for (i1 = 8 - l; i1 <= 10; ++i1)
                    {
                        this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(k), l, 2 + l, i1, box);
                    }
                }

                l = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 1);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 6, 6, 3, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 7, 5, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(l), 6, 6, 4, box);
                int j1;

                for (i1 = 6; i1 <= 8; ++i1)
                {
                    for (j1 = 5; j1 <= 10; ++j1)
                    {
                        this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(l), i1, 12 - i1, j1, box);
                    }
                }

                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 0, 2, 1, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 0, 2, 4, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 3, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 4, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 5, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 6, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 8, 2, 1, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 8, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 8, 2, 3, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 8, 2, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 8, 2, 5, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 8, 2, 6, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 8, 2, 7, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 8, 2, 8, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 8, 2, 9, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 2, 2, 6, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 2, 7, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 2, 8, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 2, 2, 9, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 4, 4, 10, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 5, 4, 10, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 6, 4, 10, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 5, 5, 10, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 2, 1, 0, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 2, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode), 2, 3, 1, box);
                this.func_175810_a(worldIn, box, random, 2, 1, 0, EnumFacing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1)));
                this.func_175804_a(worldIn, box, 1, 0, -1, 3, 2, -1, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);

                if (this.func_175807_a(worldIn, 2, 0, -1, box).getBlock().getMaterial() == Material.air && this.func_175807_a(worldIn, 2, -1, -1, box).getBlock().getMaterial() != Material.air)
                {
                    this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 2, 0, -1, box);
                }

                for (i1 = 0; i1 < 5; ++i1)
                {
                    for (j1 = 0; j1 < 9; ++j1)
                    {
                        this.clearCurrentPositionBlocksUpwards(worldIn, j1, 7, i1, box);
                        this.func_175808_b(worldIn, Blocks.nether_brick.getDefaultState(), j1, -1, i1, box);
                    }
                }

                for (i1 = 5; i1 < 11; ++i1)
                {
                    for (j1 = 2; j1 < 9; ++j1)
                    {
                        this.clearCurrentPositionBlocksUpwards(worldIn, j1, 7, i1, box);
                        this.func_175808_b(worldIn, Blocks.nether_brick.getDefaultState(), j1, -1, i1, box);
                    }
                }

                this.spawnVillagers(worldIn, box, 4, 1, 2, 2);
                return true;
            }
        }

    public static class House4Garden extends StructureNetherVillagePieces.Village
        {
            private boolean isRoofAccessible;

            public House4Garden() {}

            public House4Garden(StructureNetherVillagePieces.Start start, int par2, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par2);
                this.coordBaseMode = side;
                this.boundingBox = box;
                this.isRoofAccessible = random.nextBoolean();
            }

            /**
             * (abstract) Helper method to write subclass data to NBT
             */
            protected void writeStructureToNBT(NBTTagCompound nbtt)
            {
                super.writeStructureToNBT(nbtt);
                nbtt.setBoolean("Terrace", this.isRoofAccessible);
            }

            /**
             * (abstract) Helper method to read subclass data from NBT
             */
            protected void readStructureFromNBT(NBTTagCompound nbtt)
            {
                super.readStructureFromNBT(nbtt);
                this.isRoofAccessible = nbtt.getBoolean("Terrace");
            }

            public static StructureNetherVillagePieces.House4Garden func_175858_a(StructureNetherVillagePieces.Start start, List list, Random random, int par3, 
            		int par4, int par5, EnumFacing side, int par7)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(par3, par4, par5, 0, 0, 0, 5, 6, 5, side);
                return StructureComponent.findIntersecting(list, structureboundingbox) != null ? null : new StructureNetherVillagePieces.House4Garden(start, par7, random, structureboundingbox, side);
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);

                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 6 - 1, 0);
                }

                this.func_175804_a(worldIn, box, 0, 0, 0, 4, 0, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 4, 0, 4, 4, 4, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 4, 1, 3, 4, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 1, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 3, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 4, 1, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 4, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 4, 3, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 1, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 2, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 0, 3, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 4, 1, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 4, 2, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 4, 3, 4, box);
                this.func_175804_a(worldIn, box, 0, 1, 1, 0, 3, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 4, 1, 1, 4, 3, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 1, 4, 3, 3, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 2, 2, 4, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 4, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 1, 1, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 1, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 1, 3, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 2, 3, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 3, 3, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 3, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick.getDefaultState(), 3, 1, 0, box);

                if (this.func_175807_a(worldIn, 2, 0, -1, box).getBlock().getMaterial() == Material.air && this.func_175807_a(worldIn, 2, -1, -1, box).getBlock().getMaterial() != Material.air)
                {
                    this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 2, 0, -1, box);
                }

                this.func_175804_a(worldIn, box, 1, 1, 1, 3, 3, 3, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);

                if (this.isRoofAccessible)
                {
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 0, 5, 0, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 1, 5, 0, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 2, 5, 0, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 3, 5, 0, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 4, 5, 0, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 0, 5, 4, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 1, 5, 4, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 2, 5, 4, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 3, 5, 4, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 4, 5, 4, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 4, 5, 1, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 4, 5, 2, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 4, 5, 3, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 0, 5, 1, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 0, 5, 2, box);
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 0, 5, 3, box);
                }

                int i;

                if (this.isRoofAccessible)
                {
                    i = this.getMetadataWithOffset(Blocks.ladder, 3);
                    this.func_175811_a(worldIn, Blocks.ladder.getStateFromMeta(i), 3, 1, 3, box);
                    this.func_175811_a(worldIn, Blocks.ladder.getStateFromMeta(i), 3, 2, 3, box);
                    this.func_175811_a(worldIn, Blocks.ladder.getStateFromMeta(i), 3, 3, 3, box);
                    this.func_175811_a(worldIn, Blocks.ladder.getStateFromMeta(i), 3, 4, 3, box);
                }

                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode), 2, 3, 1, box);

                for (i = 0; i < 5; ++i)
                {
                    for (int j = 0; j < 5; ++j)
                    {
                        this.clearCurrentPositionBlocksUpwards(worldIn, j, 6, i, box);
                        this.func_175808_b(worldIn, Blocks.nether_brick.getDefaultState(), j, -1, i, box);
                    }
                }

                this.spawnVillagers(worldIn, box, 1, 1, 2, 1);
                return true;
            }
        }

    public static class Path extends StructureNetherVillagePieces.Road
        {
            private int averageGroundLevel;

            public Path() {}

            public Path(StructureNetherVillagePieces.Start start, int par2, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par2);
                this.coordBaseMode = side;
                this.boundingBox = box;
                this.averageGroundLevel = Math.max(box.getXSize(), box.getZSize());
            }

            /**
             * (abstract) Helper method to write subclass data to NBT
             */
            protected void writeStructureToNBT(NBTTagCompound nbtt)
            {
                super.writeStructureToNBT(nbtt);
                nbtt.setInteger("Length", this.averageGroundLevel);
            }

            /**
             * (abstract) Helper method to read subclass data from NBT
             */
            protected void readStructureFromNBT(NBTTagCompound nbtt)
            {
                super.readStructureFromNBT(nbtt);
                this.averageGroundLevel = nbtt.getInteger("Length");
            }

            /**
             * Initiates construction of the Structure Component picked, at the current Location of StructGen
             */
            public void buildComponent(StructureComponent component, List list, Random random)
            {
                boolean flag = false;
                int i;
                StructureComponent structurecomponent1;

                for (i = random.nextInt(5); i < this.averageGroundLevel - 8; i += 2 + random.nextInt(5))
                {
                    structurecomponent1 = this.getNextComponentNN((StructureNetherVillagePieces.Start)component, list, random, 0, i);

                    if (structurecomponent1 != null)
                    {
                        i += Math.max(structurecomponent1.getBoundingBox().getXSize(), structurecomponent1.getBoundingBox().getZSize());
                        flag = true;
                    }
                }

                for (i = random.nextInt(5); i < this.averageGroundLevel - 8; i += 2 + random.nextInt(5))
                {
                    structurecomponent1 = this.getNextComponentPP((StructureNetherVillagePieces.Start)component, list, random, 0, i);

                    if (structurecomponent1 != null)
                    {
                        i += Math.max(structurecomponent1.getBoundingBox().getXSize(), structurecomponent1.getBoundingBox().getZSize());
                        flag = true;
                    }
                }

                if (flag && random.nextInt(3) > 0 && this.coordBaseMode != null)
                {
                    switch (StructureNetherVillagePieces.SwitchEnumFacing.field_176064_a[this.coordBaseMode.ordinal()])
                    {
                        case 1:
                            StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ, EnumFacing.WEST, this.getComponentType());
                            break;
                        case 2:
                            StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.maxZ - 2, EnumFacing.WEST, this.getComponentType());
                            break;
                        case 3:
                            StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ - 1, EnumFacing.NORTH, this.getComponentType());
                            break;
                        case 4:
                            StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.maxX - 2, this.boundingBox.minY, this.boundingBox.minZ - 1, EnumFacing.NORTH, this.getComponentType());
                    }
                }

                if (flag && random.nextInt(3) > 0 && this.coordBaseMode != null)
                {
                    switch (StructureNetherVillagePieces.SwitchEnumFacing.field_176064_a[this.coordBaseMode.ordinal()])
                    {
                        case 1:
                            StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ, EnumFacing.EAST, this.getComponentType());
                            break;
                        case 2:
                            StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.maxZ - 2, EnumFacing.EAST, this.getComponentType());
                            break;
                        case 3:
                            StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, this.getComponentType());
                            break;
                        case 4:
                            StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.maxX - 2, this.boundingBox.minY, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, this.getComponentType());
                    }
                }
            }

            public static StructureBoundingBox func_175848_a(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, int par5, EnumFacing side)
            {
                for (int l = 7 * MathHelper.getRandomIntegerInRange(random, 3, 5); l >= 7; l -= 7)
                {
                    StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(par3, par4, par5, 0, 0, 0, 3, 3, l, side);

                    if (StructureComponent.findIntersecting(list, structureboundingbox) == null)
                    {
                        return structureboundingbox;
                    }
                }

                return null;
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                IBlockState iblockstate = this.func_175847_a(Blocks.gravel.getDefaultState());
                IBlockState iblockstate1 = this.func_175847_a(Blocks.nether_brick.getDefaultState());

                for (int i = this.boundingBox.minX; i <= this.boundingBox.maxX; ++i)
                {
                    for (int j = this.boundingBox.minZ; j <= this.boundingBox.maxZ; ++j)
                    {
                        BlockPos blockpos = new BlockPos(i, 64, j);

                        if (box.func_175898_b(blockpos))
                        {
                            blockpos = worldIn.getTopSolidOrLiquidBlock(blockpos).down();
                            worldIn.setBlockState(blockpos, iblockstate, 2);
                            worldIn.setBlockState(blockpos.down(), iblockstate1, 2);
                        }
                    }
                }

                return true;
            }
        }

    public static class PieceWeight
        {
            /** The Class object for the represantation of this village piece. */
            public Class villagePieceClass;
            public final int villagePieceWeight;
            public int villagePiecesSpawned;
            public int villagePiecesLimit;

            public PieceWeight(Class clazz, int par2, int par3)
            {
                this.villagePieceClass = clazz;
                this.villagePieceWeight = par2;
                this.villagePiecesLimit = par3;
            }

            public boolean canSpawnMoreVillagePiecesOfType(int par1)
            {
                return this.villagePiecesLimit == 0 || this.villagePiecesSpawned < this.villagePiecesLimit;
            }

            public boolean canSpawnMoreVillagePieces()
            {
                return this.villagePiecesLimit == 0 || this.villagePiecesSpawned < this.villagePiecesLimit;
            }
        }

    public abstract static class Road extends StructureNetherVillagePieces.Village
        {

            public Road() {}

            protected Road(StructureNetherVillagePieces.Start start, int par2)
            {
                super(start, par2);
            }
        }

    public static class Start extends StructureNetherVillagePieces.Well
        {
            public WorldChunkManager worldChunkMngr;
            /** Boolean that determines if the village is in a desert or not. */
            public boolean inDesert;
            /** World terrain type, 0 for normal, 1 for flap map */
            public int terrainType;
            public StructureNetherVillagePieces.PieceWeight structVillagePieceWeight;
            /**
             * Contains List of all spawnable Structure Piece Weights. If no more Pieces of a type can be spawned, they
             * are removed from this list
             */
            public List structureVillageWeightedPieceList;
            public List field_74932_i = Lists.newArrayList();
            public List field_74930_j = Lists.newArrayList();
            public BiomeGenBase biome;

            public Start() {}

            public Start(WorldChunkManager chunkManager, int par2, Random random, int par4, int par5, List list, int par7)
            {
                super((StructureNetherVillagePieces.Start)null, 0, random, par4, par5);
                this.worldChunkMngr = chunkManager;
                this.structureVillageWeightedPieceList = list;
                this.terrainType = par7;
                BiomeGenBase biomegenbase = chunkManager.func_180300_a(new BlockPos(par4, 0, par5), BiomeGenBase.field_180279_ad);
                this.inDesert = biomegenbase == BiomeGenBase.desert || biomegenbase == BiomeGenBase.desertHills;
                this.biome = biomegenbase;
                this.func_175846_a(this.inDesert);
            }

            public WorldChunkManager getWorldChunkManager()
            {
                return this.worldChunkMngr;
            }
        }

    static final class SwitchEnumFacing
        {
            static final int[] field_176064_a = new int[EnumFacing.values().length];

            static
            {
                try
                {
                    field_176064_a[EnumFacing.NORTH.ordinal()] = 1;
                }
                catch (NoSuchFieldError var4)
                {
                    ;
                }

                try
                {
                    field_176064_a[EnumFacing.SOUTH.ordinal()] = 2;
                }
                catch (NoSuchFieldError var3)
                {
                    ;
                }

                try
                {
                    field_176064_a[EnumFacing.WEST.ordinal()] = 3;
                }
                catch (NoSuchFieldError var2)
                {
                    ;
                }

                try
                {
                    field_176064_a[EnumFacing.EAST.ordinal()] = 4;
                }
                catch (NoSuchFieldError var1)
                {
                    ;
                }
            }
        }

    public static class Torch extends StructureNetherVillagePieces.Village
        {

            public Torch() {}

            public Torch(StructureNetherVillagePieces.Start start, int par2, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par2);
                this.coordBaseMode = side;
                this.boundingBox = box;
            }

            public static StructureBoundingBox func_175856_a(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, int par5, EnumFacing side)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(par3, par4, par5, 0, 0, 0, 3, 4, 2, side);
                return StructureComponent.findIntersecting(list, structureboundingbox) != null ? null : structureboundingbox;
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);

                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 4 - 1, 0);
                }

                this.func_175804_a(worldIn, box, 0, 0, 0, 2, 3, 1, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 1, 0, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 1, 1, 0, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 1, 2, 0, box);
                this.func_175811_a(worldIn, Blocks.wool.getStateFromMeta(EnumDyeColor.WHITE.getDyeDamage()), 1, 3, 0, box);
                boolean flag = this.coordBaseMode == EnumFacing.EAST || this.coordBaseMode == EnumFacing.NORTH;
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode.rotateY()), flag ? 2 : 0, 3, 0, box);
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode), 1, 3, 1, box);
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode.rotateYCCW()), flag ? 0 : 2, 3, 0, box);
                this.func_175811_a(worldIn, Blocks.torch.getDefaultState().withProperty(BlockTorch.FACING, this.coordBaseMode.getOpposite()), 1, 3, -1, box);
                return true;
            }
        }

    public abstract static class Village extends StructureComponent
        {
            protected int field_143015_k = -1;
            /** The number of villagers that have been spawned in this component. */
            private int villagersSpawned;
            private boolean field_143014_b;
            private StructureNetherVillagePieces.Start startPiece;

            public Village() {}

            protected Village(StructureNetherVillagePieces.Start start, int par2)
            {
                super(par2);

                if (start != null)
                {
                    this.field_143014_b = start.inDesert;
                    startPiece = start;
                }
            }

            /**
             * (abstract) Helper method to write subclass data to NBT
             */
            protected void writeStructureToNBT(NBTTagCompound nbtt)
            {
                nbtt.setInteger("HPos", this.field_143015_k);
                nbtt.setInteger("VCount", this.villagersSpawned);
                nbtt.setBoolean("Desert", this.field_143014_b);
            }

            /**
             * (abstract) Helper method to read subclass data from NBT
             */
            protected void readStructureFromNBT(NBTTagCompound nbtt)
            {
                this.field_143015_k = nbtt.getInteger("HPos");
                this.villagersSpawned = nbtt.getInteger("VCount");
                this.field_143014_b = nbtt.getBoolean("Desert");
            }

            /**
             * Gets the next village component, with the bounding box shifted -1 in the X and Z direction.
             */
            protected StructureComponent getNextComponentNN(StructureNetherVillagePieces.Start start, List list, Random random, int x, int z)
            {
                if (this.coordBaseMode != null)
                {
                    switch (StructureNetherVillagePieces.SwitchEnumFacing.field_176064_a[this.coordBaseMode.ordinal()])
                    {
                        case 1:
                            return StructureNetherVillagePieces.func_176066_d(start, list, random, this.boundingBox.minX - 1, this.boundingBox.minY + x, this.boundingBox.minZ + z, EnumFacing.WEST, this.getComponentType());
                        case 2:
                            return StructureNetherVillagePieces.func_176066_d(start, list, random, this.boundingBox.minX - 1, this.boundingBox.minY + x, this.boundingBox.minZ + z, EnumFacing.WEST, this.getComponentType());
                        case 3:
                            return StructureNetherVillagePieces.func_176066_d(start, list, random, this.boundingBox.minX + z, this.boundingBox.minY + x, this.boundingBox.minZ - 1, EnumFacing.NORTH, this.getComponentType());
                        case 4:
                            return StructureNetherVillagePieces.func_176066_d(start, list, random, this.boundingBox.minX + z, this.boundingBox.minY + x, this.boundingBox.minZ - 1, EnumFacing.NORTH, this.getComponentType());
                    }
                }

                return null;
            }

            /**
             * Gets the next village component, with the bounding box shifted +1 in the X and Z direction.
             */
            protected StructureComponent getNextComponentPP(StructureNetherVillagePieces.Start start, List list, Random random, int x, int z)
            {
                if (this.coordBaseMode != null)
                {
                    switch (StructureNetherVillagePieces.SwitchEnumFacing.field_176064_a[this.coordBaseMode.ordinal()])
                    {
                        case 1:
                            return StructureNetherVillagePieces.func_176066_d(start, list, random, this.boundingBox.maxX + 1, this.boundingBox.minY + x, this.boundingBox.minZ + z, EnumFacing.EAST, this.getComponentType());
                        case 2:
                            return StructureNetherVillagePieces.func_176066_d(start, list, random, this.boundingBox.maxX + 1, this.boundingBox.minY + x, this.boundingBox.minZ + z, EnumFacing.EAST, this.getComponentType());
                        case 3:
                            return StructureNetherVillagePieces.func_176066_d(start, list, random, this.boundingBox.minX + z, this.boundingBox.minY + x, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, this.getComponentType());
                        case 4:
                            return StructureNetherVillagePieces.func_176066_d(start, list, random, this.boundingBox.minX + z, this.boundingBox.minY + x, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, this.getComponentType());
                    }
                }

                return null;
            }

            /**
             * Discover the y coordinate that will serve as the ground level of the supplied BoundingBox. (A median of
             * all the levels in the BB's horizontal rectangle).
             */
            protected int getAverageGroundLevel(World worldIn, StructureBoundingBox box)
            {
                int i = 0;
                int j = 0;

                for (int k = this.boundingBox.minZ; k <= this.boundingBox.maxZ; ++k)
                {
                    for (int l = this.boundingBox.minX; l <= this.boundingBox.maxX; ++l)
                    {
                        BlockPos blockpos = new BlockPos(l, 64, k);

                        if (box.func_175898_b(blockpos))
                        {
                            i += Math.max(worldIn.getTopSolidOrLiquidBlock(blockpos).getY(), worldIn.provider.getAverageGroundLevel());
                            ++j;
                        }
                    }
                }

                if (j == 0)
                {
                    return -1;
                }
                else
                {
                    return i / j;
                }
            }

            protected static boolean canVillageGoDeeper(StructureBoundingBox box)
            {
                return box != null && box.minY > 10;
            }

            /**
             * Spawns a number of villagers in this component. Parameters: world, component bounding box, x offset, y
             * offset, z offset, number of villagers
             */
            protected void spawnVillagers(World worldIn, StructureBoundingBox box, int x, int y, int z, int par6)
            {
                if (this.villagersSpawned < par6)
                {
                    for (int i1 = this.villagersSpawned; i1 < par6; ++i1)
                    {
                        int j1 = this.getXWithOffset(x + i1, z);
                        int k1 = this.getYWithOffset(y);
                        int l1 = this.getZWithOffset(x + i1, z);

                        if (!box.func_175898_b(new BlockPos(j1, k1, l1)))
                        {
                            break;
                        }

                        ++this.villagersSpawned;
                        EntityVillager entityvillager = new EntityVillager(worldIn);
                        entityvillager.setLocationAndAngles((double)j1 + 0.5D, (double)k1, (double)l1 + 0.5D, 0.0F, 0.0F);
                        entityvillager.func_180482_a(worldIn.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null);
                        entityvillager.setProfession(this.func_180779_c(i1, entityvillager.getProfession()));
                        worldIn.spawnEntityInWorld(entityvillager);
                    }
                }
            }

            protected int func_180779_c(int par1, int par2)
            {
                return par2;
            }

            protected IBlockState func_175847_a(IBlockState par1)
            {
                BiomeEvent.GetVillageBlockID event = new BiomeEvent.GetVillageBlockID(startPiece == null ? null : startPiece.biome, par1);
                MinecraftForge.TERRAIN_GEN_BUS.post(event);
                if (event.getResult() == Result.DENY) return event.replacement;
               /* if (this.field_143014_b)
                {
                    if (p_175847_1_.getBlock() == Blocks.netherrack || p_175847_1_.getBlock() == Blocks.netherrack2)
                    {
                        return Blocks.sandstone.getDefaultState();
                    }

                    if (p_175847_1_.getBlock() == Blocks.nether_brick)
                    {
                        return Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.DEFAULT.getMetadata());
                    }

                    if (p_175847_1_.getBlock() == Blocks.nether_brick)
                    {
                        return Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata());
                    }

                    if (p_175847_1_.getBlock() == Blocks.nether_brick_stairs)
                    {
                        return Blocks.nether_brick_stairs.getDefaultState().withProperty(BlockStairs.FACING, p_175847_1_.getValue(BlockStairs.FACING));
                    }

                    if (p_175847_1_.getBlock() == Blocks.nether_brick_stairs)
                    {
                        return Blocks.nether_brick_stairs.getDefaultState().withProperty(BlockStairs.FACING, p_175847_1_.getValue(BlockStairs.FACING));
                    }

                    if (p_175847_1_.getBlock() == Blocks.gravel)
                    {
                        return Blocks.sandstone.getDefaultState();
                    }
                }*/

                return par1;
            }

            protected void func_175811_a(World worldIn, IBlockState state, int x, int y, int z, StructureBoundingBox box)
            {
                IBlockState iblockstate1 = this.func_175847_a(state);
                super.func_175811_a(worldIn, iblockstate1, x, y, z, box);
            }

            protected void func_175804_a(World worldIn, StructureBoundingBox box, int x, int y, int z, int par6, int par7, int par8, IBlockState state, IBlockState state2, boolean par11)
            {
                IBlockState iblockstate2 = this.func_175847_a(state);
                IBlockState iblockstate3 = this.func_175847_a(state2);
                super.func_175804_a(worldIn, box, x, y, z, par6, par7, par8, iblockstate2, iblockstate3, par11);
            }

            protected void func_175808_b(World worldIn, IBlockState state, int x, int y, int z, StructureBoundingBox box)
            {
                IBlockState iblockstate1 = this.func_175847_a(state);
                super.func_175808_b(worldIn, iblockstate1, x, y, z, box);
            }

            protected void func_175846_a(boolean par1)
            {
                this.field_143014_b = par1;
            }
        }

    public static class Well extends StructureNetherVillagePieces.Village
        {

            public Well() {}

            public Well(StructureNetherVillagePieces.Start start, int par2, Random random, int par4, int par5)
            {
                super(start, par2);
                this.coordBaseMode = EnumFacing.Plane.HORIZONTAL.random(random);

                switch (StructureNetherVillagePieces.SwitchEnumFacing.field_176064_a[this.coordBaseMode.ordinal()])
                {
                    case 1:
                    case 2:
                        this.boundingBox = new StructureBoundingBox(par4, 64, par5, par4 + 6 - 1, 78, par5 + 6 - 1);
                        break;
                    default:
                        this.boundingBox = new StructureBoundingBox(par4, 64, par5, par4 + 6 - 1, 78, par5 + 6 - 1);
                }
            }

            /**
             * Initiates construction of the Structure Component picked, at the current Location of StructGen
             */
            public void buildComponent(StructureComponent component, List list, Random random)
            {
                StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.minX - 1, this.boundingBox.maxY - 4, this.boundingBox.minZ + 1, EnumFacing.WEST, this.getComponentType());
                StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.maxX + 1, this.boundingBox.maxY - 4, this.boundingBox.minZ + 1, EnumFacing.EAST, this.getComponentType());
                StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.minX + 1, this.boundingBox.maxY - 4, this.boundingBox.minZ - 1, EnumFacing.NORTH, this.getComponentType());
                StructureNetherVillagePieces.func_176069_e((StructureNetherVillagePieces.Start)component, list, random, this.boundingBox.minX + 1, this.boundingBox.maxY - 4, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, this.getComponentType());
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);

                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 3, 0);
                }

                this.func_175804_a(worldIn, box, 1, 0, 1, 4, 12, 4, Blocks.nether_brick.getDefaultState(), Blocks.flowing_water.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 2, 12, 2, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 3, 12, 2, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 2, 12, 3, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 3, 12, 3, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 1, 13, 1, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 1, 14, 1, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 4, 13, 1, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 4, 14, 1, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 1, 13, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 1, 14, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 4, 13, 4, box);
                this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), 4, 14, 4, box);
                this.func_175804_a(worldIn, box, 1, 15, 1, 4, 15, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);

                for (int i = 0; i <= 5; ++i)
                {
                    for (int j = 0; j <= 5; ++j)
                    {
                        if (j == 0 || j == 5 || i == 0 || i == 5)
                        {
                            this.func_175811_a(worldIn, Blocks.gravel.getDefaultState(), j, 11, i, box);
                            this.clearCurrentPositionBlocksUpwards(worldIn, j, 12, i, box);
                        }
                    }
                }

                return true;
            }
        }

    public static class WoodHut extends StructureNetherVillagePieces.Village
        {
            private boolean isTallHouse;
            private int tablePosition;

            public WoodHut() {}

            public WoodHut(StructureNetherVillagePieces.Start start, int par2, Random random, StructureBoundingBox box, EnumFacing side)
            {
                super(start, par2);
                this.coordBaseMode = side;
                this.boundingBox = box;
                this.isTallHouse = random.nextBoolean();
                this.tablePosition = random.nextInt(3);
            }

            /**
             * (abstract) Helper method to write subclass data to NBT
             */
            protected void writeStructureToNBT(NBTTagCompound nbtt)
            {
                super.writeStructureToNBT(nbtt);
                nbtt.setInteger("T", this.tablePosition);
                nbtt.setBoolean("C", this.isTallHouse);
            }

            /**
             * (abstract) Helper method to read subclass data from NBT
             */
            protected void readStructureFromNBT(NBTTagCompound nbtt)
            {
                super.readStructureFromNBT(nbtt);
                this.tablePosition = nbtt.getInteger("T");
                this.isTallHouse = nbtt.getBoolean("C");
            }

            public static StructureNetherVillagePieces.WoodHut func_175853_a(StructureNetherVillagePieces.Start start, List list, Random random, int par3, int par4, int par5, EnumFacing side, int par7)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.func_175897_a(par3, par4, par5, 0, 0, 0, 4, 6, 5, side);
                return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(list, structureboundingbox) == null ? new StructureNetherVillagePieces.WoodHut(start, par7, random, structureboundingbox, side) : null;
            }

            /**
             * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
             * Mineshafts at the end, it adds Fences...
             */
            public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox box)
            {
                if (this.field_143015_k < 0)
                {
                    this.field_143015_k = this.getAverageGroundLevel(worldIn, box);

                    if (this.field_143015_k < 0)
                    {
                        return true;
                    }

                    this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 6 - 1, 0);
                }

                this.func_175804_a(worldIn, box, 1, 1, 1, 3, 5, 4, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 0, 0, 3, 0, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 0, 1, 2, 0, 3, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                if (this.isTallHouse)
                {
                    this.func_175804_a(worldIn, box, 1, 4, 1, 2, 4, 3, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                }
                else
                {
                    this.func_175804_a(worldIn, box, 1, 5, 1, 2, 5, 3, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                }

                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 1, 4, 0, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 2, 4, 0, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 1, 4, 4, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 2, 4, 4, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 0, 4, 1, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 0, 4, 2, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 0, 4, 3, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 3, 4, 1, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 3, 4, 2, box);
                this.func_175811_a(worldIn, Blocks.netherrack.getDefaultState(), 3, 4, 3, box);
                this.func_175804_a(worldIn, box, 0, 1, 0, 0, 3, 0, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 3, 1, 0, 3, 3, 0, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 1, 4, 0, 3, 4, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 3, 1, 4, 3, 3, 4, Blocks.netherrack.getDefaultState(), Blocks.netherrack.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 0, 1, 1, 0, 3, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 3, 1, 1, 3, 3, 3, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 1, 0, 2, 3, 0, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175804_a(worldIn, box, 1, 1, 4, 2, 3, 4, Blocks.nether_brick.getDefaultState(), Blocks.nether_brick.getDefaultState(), false);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 0, 2, 2, box);
                this.func_175811_a(worldIn, Blocks.glass_pane.getDefaultState(), 3, 2, 2, box);

                if (this.tablePosition > 0)
                {
                    this.func_175811_a(worldIn, Blocks.nether_brick_fence.getDefaultState(), this.tablePosition, 1, 3, box);
                    this.func_175811_a(worldIn, Blocks.stone_pressure_plate.getDefaultState(), this.tablePosition, 2, 3, box);
                }

                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 1, 1, 0, box);
                this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 1, 2, 0, box);
                this.func_175810_a(worldIn, box, random, 1, 1, 0, EnumFacing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1)));

                if (this.func_175807_a(worldIn, 1, 0, -1, box).getBlock().getMaterial() == Material.air && this.func_175807_a(worldIn, 1, -1, -1, box).getBlock().getMaterial() != Material.air)
                {
                    this.func_175811_a(worldIn, Blocks.nether_brick_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3)), 1, 0, -1, box);
                }

                for (int i = 0; i < 5; ++i)
                {
                    for (int j = 0; j < 4; ++j)
                    {
                        this.clearCurrentPositionBlocksUpwards(worldIn, j, 6, i, box);
                        this.func_175808_b(worldIn, Blocks.nether_brick.getDefaultState(), j, -1, i, box);
                    }
                }

                this.spawnVillagers(worldIn, box, 1, 1, 2, 1);
                return true;
            }
        }
}

wich as i said before they are only copy-paste of vanilla classes (just for testing)

Then i register this events here

package blaze.core;

import blaze.world.village.MapGenEventHandler;
import blaze.world.village.NetherVillageHandler;
import blaze.world.village.VillageMaterialEventHandler;
import blaze.world.village.VillageMetadadaEventHandler;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.MinecraftForge;

public class BLVillage {


public static void createVillager()
{

	BiomeManager.addVillageBiome(BiomeGenBase.extremeHills, true);
	BiomeManager.addVillageBiome(BiomeGenBase.forest, true);
	BiomeManager.addVillageBiome(BiomeGenBase.forest.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.swampland, true);
	BiomeManager.addVillageBiome(BiomeGenBase.swampland.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.taiga, true);
	BiomeManager.addVillageBiome(BiomeGenBase.taiga.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.icePlains, true);
	BiomeManager.addVillageBiome(BiomeGenBase.icePlains.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.mushroomIsland, true);
	BiomeManager.addVillageBiome(BiomeGenBase.mushroomIslandShore, true);
	BiomeManager.addVillageBiome(BiomeGenBase.jungle, true);
	BiomeManager.addVillageBiome(BiomeGenBase.jungle.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.roofedForest, true);
	BiomeManager.addVillageBiome(BiomeGenBase.roofedForest.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.birchForest, true);
	BiomeManager.addVillageBiome(BiomeGenBase.birchForest.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.coldTaiga, true);
	BiomeManager.addVillageBiome(BiomeGenBase.coldTaiga.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.mesa, true);
	BiomeManager.addVillageBiome(BiomeGenBase.mesa.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.mesaPlateau, true);
	BiomeManager.addVillageBiome(BiomeGenBase.mesaPlateau.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.mesaPlateau_F, true);
	BiomeManager.addVillageBiome(BiomeGenBase.mesaPlateau_F.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.megaTaiga, true);
	BiomeManager.addVillageBiome(BiomeGenBase.megaTaiga.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.megaTaigaHills, true);
	BiomeManager.addVillageBiome(BiomeGenBase.megaTaigaHills.createMutation(), true);
	BiomeManager.addVillageBiome(BiomeGenBase.savanna, true);
	BiomeManager.addVillageBiome(BiomeGenBase.savannaPlateau, true);
	//BiomeManager.addVillageBiome(BiomeGenBase.hell, true);


	MinecraftForge.TERRAIN_GEN_BUS.register(new MapGenEventHandler());
	MinecraftForge.TERRAIN_GEN_BUS.register(new VillageMaterialEventHandler());
	MinecraftForge.TERRAIN_GEN_BUS.register(new VillageMetadadaEventHandler());
	MinecraftForge.EVENT_BUS.register(new NetherVillageHandler());

}
}

wich is called from the preInit method.

This is the other class involved (the class that says it cannot be cated to)

package blaze.world.village;

import net.minecraft.world.gen.structure.MapGenVillage;
import net.minecraftforge.fml.relauncher.ReflectionHelper;

public class MapGenVillageEventHandler
  extends MapGenVillage
{
  public MapGenVillageEventHandler()
  {
    ReflectionHelper.setPrivateValue(MapGenVillage.class, this, Integer.valueOf(16), new String[] { "field_82665_g" });
    ReflectionHelper.setPrivateValue(MapGenVillage.class, this, Integer.valueOf(4), new String[] { "field_82666_h" });
  }
}

 

How can i figured out this? :/ If any other class is need, please ask it :)

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

If I'm reading this right, MapGenVillageEventHandler and your class are each extending the same parent, but they're not in line with each other. I think your class needs to extend MapGenVillageEventHandler in order to cast it into your own class.

 

You might try casting MapGenVillageEventHandler to its parent and then casting that to your own class, but don't be surprised if bad things happen (or some data become unavailable).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

And infact doing this

package blaze.world.village;

import net.minecraft.world.gen.structure.MapGenVillage;
import net.minecraftforge.fml.relauncher.ReflectionHelper;

public class MapGenVillageEventHandler
  extends MapGenNetherVillage
{
  public MapGenVillageEventHandler()
  {
    ReflectionHelper.setPrivateValue(MapGenVillage.class, this, Integer.valueOf(16), new String[] { "field_82665_g" });
    ReflectionHelper.setPrivateValue(MapGenVillage.class, this, Integer.valueOf(4), new String[] { "field_82666_h" });
  }
}

package blaze.world.village;

import java.util.Random;

import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.gen.structure.MapGenVillage;
import net.minecraftforge.event.terraingen.InitMapGenEvent.EventType;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.event.terraingen.TerrainGen;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class NetherVillageHandler extends MapGenVillageEventHandler
{
private MapGenNetherVillage villageGenerator;

@SubscribeEvent
public void genNetherVillages(PopulateChunkEvent.Pre event)
{
	this.villageGenerator = new MapGenNetherVillage();
	villageGenerator = (MapGenNetherVillage) TerrainGen.getModdedMapGen(villageGenerator, EventType.VILLAGE);
	villageGenerator.func_175792_a(event.chunkProvider, event.world, event.chunkX, event.chunkZ, new ChunkPrimer());
	villageGenerator.func_175794_a(event.world, new Random(), new ChunkCoordIntPair(event.chunkX, event.chunkZ));
}

}

gives this

java.lang.ArithmeticException: / by zero
at blaze.world.village.MapGenNetherVillage.canSpawnStructureAtCoords(MapGenNetherVillage.java:72)
at net.minecraft.world.gen.structure.MapGenStructure.func_180701_a(MapGenStructure.java:43)
at net.minecraft.world.gen.MapGenBase.func_175792_a(MapGenBase.java:33)
at net.minecraft.world.gen.ChunkProviderGenerate.provideChunk(ChunkProviderGenerate.java:252)
at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:178)
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:138)
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:108)
at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:209)
at net.minecraft.world.World.getChunkFromChunkCoords(World.java:360)
at net.minecraft.world.World.getChunkFromBlockCoords(World.java:349)
at net.minecraft.world.World.getBlockState(World.java:901)
at net.minecraft.world.World.isAirBlock(World.java:271)
at net.minecraft.world.World.getGroundAboveSeaLevel(World.java:247)
at net.minecraft.world.WorldProvider.canCoordinateBeSpawn(WorldProvider.java:87)
at net.minecraft.world.WorldServer.createSpawnPosition(WorldServer.java:910)
at net.minecraft.world.WorldServer.initialize(WorldServer.java:829)
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:92)
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:130)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:500)
at java.lang.Thread.run(Unknown Source)

 

Called by this

this.field_82665_g = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.field_82665_g, this.field_82666_h + 1);
....
int i1 = x / this.field_82665_g;

so field_82665_g is equal to 0

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted
public class MapGenVillageEventHandler

  extends MapGenNetherVillage

 

Looks like these are out of order. The more general village event-handling or generation should be parent (or grandparent), and the more specific nether generator should be child (or grandchild). Also, your class hierarchy is somewhat hard to parse because you have both generators and event handlers with very similar names. Can any of these be collapsed into each other? In other words, can your event handler perform the generating internally?

 

Once you've cleaned up your patterns of inheritance (and construction), your problems with uninitialized data should go away.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.