    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import java.util.Random;
    005
    006    public class ComponentStrongholdPortalRoom extends ComponentStronghold
    007    {
    008        private boolean hasSpawner;
    009
    010        public ComponentStrongholdPortalRoom(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4)
    011        {
    012            super(par1);
    013            this.coordBaseMode = par4;
    014            this.boundingBox = par3StructureBoundingBox;
    015        }
    016
    017        /**
    018         * Initiates construction of the Structure Component picked, at the current Location of StructGen
    019         */
    020        public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random)
    021        {
    022            if (par1StructureComponent != null)
    023            {
    024                ((ComponentStrongholdStairs2)par1StructureComponent).portalRoom = this;
    025            }
    026        }
    027
    028        public static ComponentStrongholdPortalRoom findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6)
    029        {
    030            StructureBoundingBox var7 = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -4, -1, 0, 11, 8, 16, par5);
    031            return canStrongholdGoDeeper(var7) && StructureComponent.findIntersecting(par0List, var7) == null ? new ComponentStrongholdPortalRoom(par6, par1Random, var7, par5) : null;
    032        }
    033
    034        /**
    035         * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
    036         * the end, it adds Fences...
    037         */
    038        public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox)
    039        {
    040            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 10, 7, 15, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    041            this.placeDoor(par1World, par2Random, par3StructureBoundingBox, EnumDoor.GRATES, 4, 1, 0);
    042            byte var4 = 6;
    043            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, var4, 1, 1, var4, 14, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    044            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 9, var4, 1, 9, var4, 14, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    045            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, var4, 1, 8, var4, 2, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    046            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, var4, 14, 8, var4, 14, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    047            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 2, 1, 4, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    048            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 8, 1, 1, 9, 1, 4, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    049            this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 1, 1, 3, Block.lavaMoving.blockID, Block.lavaMoving.blockID, false);
    050            this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 1, 1, 9, 1, 3, Block.lavaMoving.blockID, Block.lavaMoving.blockID, false);
    051            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 3, 1, 8, 7, 1, 12, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    052            this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 9, 6, 1, 11, Block.lavaMoving.blockID, Block.lavaMoving.blockID, false);
    053            int var5;
    054
    055            for (var5 = 3; var5 < 14; var5 += 2)
    056            {
    057                this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, var5, 0, 4, var5, Block.fenceIron.blockID, Block.fenceIron.blockID, false);
    058                this.fillWithBlocks(par1World, par3StructureBoundingBox, 10, 3, var5, 10, 4, var5, Block.fenceIron.blockID, Block.fenceIron.blockID, false);
    059            }
    060
    061            for (var5 = 2; var5 < 9; var5 += 2)
    062            {
    063                this.fillWithBlocks(par1World, par3StructureBoundingBox, var5, 3, 15, var5, 4, 15, Block.fenceIron.blockID, Block.fenceIron.blockID, false);
    064            }
    065
    066            var5 = this.getMetadataWithOffset(Block.stairsStoneBrickSmooth.blockID, 3);
    067            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 1, 5, 6, 1, 7, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    068            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 2, 6, 6, 2, 7, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    069            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 3, 7, 6, 3, 7, false, par2Random, StructureStrongholdPieces.getStrongholdStones());
    070
    071            for (int var6 = 4; var6 <= 6; ++var6)
    072            {
    073                this.placeBlockAtCurrentPosition(par1World, Block.stairsStoneBrickSmooth.blockID, var5, var6, 1, 4, par3StructureBoundingBox);
    074                this.placeBlockAtCurrentPosition(par1World, Block.stairsStoneBrickSmooth.blockID, var5, var6, 2, 5, par3StructureBoundingBox);
    075                this.placeBlockAtCurrentPosition(par1World, Block.stairsStoneBrickSmooth.blockID, var5, var6, 3, 6, par3StructureBoundingBox);
    076            }
    077
    078            byte var14 = 2;
    079            byte var7 = 0;
    080            byte var8 = 3;
    081            byte var9 = 1;
    082
    083            switch (this.coordBaseMode)
    084            {
    085                case 0:
    086                    var14 = 0;
    087                    var7 = 2;
    088                    break;
    089                case 1:
    090                    var14 = 1;
    091                    var7 = 3;
    092                    var8 = 0;
    093                    var9 = 2;
    094                case 2:
    095                default:
    096                    break;
    097                case 3:
    098                    var14 = 3;
    099                    var7 = 1;
    100                    var8 = 0;
    101                    var9 = 2;
    102            }
    103
    104            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var14 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 4, 3, 8, par3StructureBoundingBox);
    105            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var14 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 5, 3, 8, par3StructureBoundingBox);
    106            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var14 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 6, 3, 8, par3StructureBoundingBox);
    107            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var7 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 4, 3, 12, par3StructureBoundingBox);
    108            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var7 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 5, 3, 12, par3StructureBoundingBox);
    109            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var7 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 6, 3, 12, par3StructureBoundingBox);
    110            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var8 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 3, 3, 9, par3StructureBoundingBox);
    111            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var8 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 3, 3, 10, par3StructureBoundingBox);
    112            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var8 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 3, 3, 11, par3StructureBoundingBox);
    113            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var9 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 7, 3, 9, par3StructureBoundingBox);
    114            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var9 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 7, 3, 10, par3StructureBoundingBox);
    115            this.placeBlockAtCurrentPosition(par1World, Block.endPortalFrame.blockID, var9 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 7, 3, 11, par3StructureBoundingBox);
    116
    117            if (!this.hasSpawner)
    118            {
    119                int var13 = this.getYWithOffset(3);
    120                int var10 = this.getXWithOffset(5, 6);
    121                int var11 = this.getZWithOffset(5, 6);
    122
    123                if (par3StructureBoundingBox.isVecInside(var10, var13, var11))
    124                {
    125                    this.hasSpawner = true;
    126                    par1World.setBlockWithNotify(var10, var13, var11, Block.mobSpawner.blockID);
    127                    TileEntityMobSpawner var12 = (TileEntityMobSpawner)par1World.getBlockTileEntity(var10, var13, var11);
    128
    129                    if (var12 != null)
    130                    {
    131                        var12.setMobID("Silverfish");
    132                    }
    133                }
    134            }
    135
    136            return true;
    137        }
    138    }