    001package net.minecraft.world.gen.structure;
    002
    003import java.util.Random;
    004import net.minecraft.block.Block;
    005import net.minecraft.entity.monster.EntityWitch;
    006import net.minecraft.world.World;
    007
    008public class ComponentScatteredFeatureSwampHut extends ComponentScatteredFeature
    009{
    010    /** Whether this swamp hut has a witch. */
    011    private boolean hasWitch;
    012
    013    public ComponentScatteredFeatureSwampHut(Random par1Random, int par2, int par3)
    014    {
    015        super(par1Random, par2, 64, par3, 7, 5, 9);
    016    }
    017
    018    /**
    019     * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
    020     * the end, it adds Fences...
    021     */
    022    public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox)
    023    {
    024        if (!this.func_74935_a(par1World, par3StructureBoundingBox, 0))
    025        {
    026            return false;
    027        }
    028        else
    029        {
    030            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 5, 1, 7, Block.planks.blockID, 1, Block.planks.blockID, 1, false);
    031            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 1, 4, 2, 5, 4, 7, Block.planks.blockID, 1, Block.planks.blockID, 1, false);
    032            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 2, 1, 0, 4, 1, 0, Block.planks.blockID, 1, Block.planks.blockID, 1, false);
    033            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 2, 2, 2, 3, 3, 2, Block.planks.blockID, 1, Block.planks.blockID, 1, false);
    034            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 1, 2, 3, 1, 3, 6, Block.planks.blockID, 1, Block.planks.blockID, 1, false);
    035            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 5, 2, 3, 5, 3, 6, Block.planks.blockID, 1, Block.planks.blockID, 1, false);
    036            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 2, 2, 7, 4, 3, 7, Block.planks.blockID, 1, Block.planks.blockID, 1, false);
    037            this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 2, 1, 3, 2, Block.wood.blockID, Block.wood.blockID, false);
    038            this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 0, 2, 5, 3, 2, Block.wood.blockID, Block.wood.blockID, false);
    039            this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 7, 1, 3, 7, Block.wood.blockID, Block.wood.blockID, false);
    040            this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 0, 7, 5, 3, 7, Block.wood.blockID, Block.wood.blockID, false);
    041            this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 2, 3, 2, par3StructureBoundingBox);
    042            this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 3, 3, 7, par3StructureBoundingBox);
    043            this.placeBlockAtCurrentPosition(par1World, 0, 0, 1, 3, 4, par3StructureBoundingBox);
    044            this.placeBlockAtCurrentPosition(par1World, 0, 0, 5, 3, 4, par3StructureBoundingBox);
    045            this.placeBlockAtCurrentPosition(par1World, 0, 0, 5, 3, 5, par3StructureBoundingBox);
    046            this.placeBlockAtCurrentPosition(par1World, Block.flowerPot.blockID, 7, 1, 3, 5, par3StructureBoundingBox);
    047            this.placeBlockAtCurrentPosition(par1World, Block.workbench.blockID, 0, 3, 2, 6, par3StructureBoundingBox);
    048            this.placeBlockAtCurrentPosition(par1World, Block.cauldron.blockID, 0, 4, 2, 6, par3StructureBoundingBox);
    049            this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 1, 2, 1, par3StructureBoundingBox);
    050            this.placeBlockAtCurrentPosition(par1World, Block.fence.blockID, 0, 5, 2, 1, par3StructureBoundingBox);
    051            int i = this.getMetadataWithOffset(Block.stairsWoodOak.blockID, 3);
    052            int j = this.getMetadataWithOffset(Block.stairsWoodOak.blockID, 1);
    053            int k = this.getMetadataWithOffset(Block.stairsWoodOak.blockID, 0);
    054            int l = this.getMetadataWithOffset(Block.stairsWoodOak.blockID, 2);
    055            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 0, 4, 1, 6, 4, 1, Block.stairsWoodSpruce.blockID, i, Block.stairsWoodSpruce.blockID, i, false);
    056            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 0, 4, 2, 0, 4, 7, Block.stairsWoodSpruce.blockID, k, Block.stairsWoodSpruce.blockID, k, false);
    057            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 6, 4, 2, 6, 4, 7, Block.stairsWoodSpruce.blockID, j, Block.stairsWoodSpruce.blockID, j, false);
    058            this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 0, 4, 8, 6, 4, 8, Block.stairsWoodSpruce.blockID, l, Block.stairsWoodSpruce.blockID, l, false);
    059            int i1;
    060            int j1;
    061
    062            for (i1 = 2; i1 <= 7; i1 += 5)
    063            {
    064                for (j1 = 1; j1 <= 5; j1 += 4)
    065                {
    066                    this.fillCurrentPositionBlocksDownwards(par1World, Block.wood.blockID, 0, j1, -1, i1, par3StructureBoundingBox);
    067                }
    068            }
    069
    070            if (!this.hasWitch)
    071            {
    072                i1 = this.getXWithOffset(2, 5);
    073                j1 = this.getYWithOffset(2);
    074                int k1 = this.getZWithOffset(2, 5);
    075
    076                if (par3StructureBoundingBox.isVecInside(i1, j1, k1))
    077                {
    078                    this.hasWitch = true;
    079                    EntityWitch entitywitch = new EntityWitch(par1World);
    080                    entitywitch.setLocationAndAngles((double)i1 + 0.5D, (double)j1, (double)k1 + 0.5D, 0.0F, 0.0F);
    081                    entitywitch.initCreature();
    082                    par1World.spawnEntityInWorld(entitywitch);
    083                }
    084            }
    085
    086            return true;
    087        }
    088    }
    089}