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