001package net.minecraft.world.gen.structure;
002
003import java.util.List;
004import java.util.Random;
005import net.minecraft.block.Block;
006import net.minecraft.item.Item;
007import net.minecraft.util.WeightedRandomChestContent;
008import net.minecraft.world.World;
009
010import net.minecraftforge.common.ChestGenHooks;
011import static net.minecraftforge.common.ChestGenHooks.*;
012
013public class ComponentStrongholdChestCorridor extends ComponentStronghold
014{
015    /** List of items that Stronghold chests can contain. */
016    public static final WeightedRandomChestContent[] strongholdChestContents = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Item.enderPearl.itemID, 0, 1, 1, 10), new WeightedRandomChestContent(Item.diamond.itemID, 0, 1, 3, 3), new WeightedRandomChestContent(Item.ingotIron.itemID, 0, 1, 5, 10), new WeightedRandomChestContent(Item.ingotGold.itemID, 0, 1, 3, 5), new WeightedRandomChestContent(Item.redstone.itemID, 0, 4, 9, 5), new WeightedRandomChestContent(Item.bread.itemID, 0, 1, 3, 15), new WeightedRandomChestContent(Item.appleRed.itemID, 0, 1, 3, 15), new WeightedRandomChestContent(Item.pickaxeSteel.itemID, 0, 1, 1, 5), new WeightedRandomChestContent(Item.swordSteel.itemID, 0, 1, 1, 5), new WeightedRandomChestContent(Item.plateSteel.itemID, 0, 1, 1, 5), new WeightedRandomChestContent(Item.helmetSteel.itemID, 0, 1, 1, 5), new WeightedRandomChestContent(Item.legsSteel.itemID, 0, 1, 1, 5), new WeightedRandomChestContent(Item.bootsSteel.itemID, 0, 1, 1, 5), new WeightedRandomChestContent(Item.appleGold.itemID, 0, 1, 1, 1)};
017    private final EnumDoor doorType;
018    private boolean hasMadeChest;
019
020    public ComponentStrongholdChestCorridor(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4)
021    {
022        super(par1);
023        this.coordBaseMode = par4;
024        this.doorType = this.getRandomDoor(par2Random);
025        this.boundingBox = par3StructureBoundingBox;
026    }
027
028    /**
029     * Initiates construction of the Structure Component picked, at the current Location of StructGen
030     */
031    public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random)
032    {
033        this.getNextComponentNormal((ComponentStrongholdStairs2)par1StructureComponent, par2List, par3Random, 1, 1);
034    }
035
036    public static ComponentStrongholdChestCorridor findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6)
037    {
038        StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -1, 0, 5, 5, 7, par5);
039        return canStrongholdGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new ComponentStrongholdChestCorridor(par6, par1Random, structureboundingbox, par5) : null;
040    }
041
042    /**
043     * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
044     * the end, it adds Fences...
045     */
046    public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox)
047    {
048        if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox))
049        {
050            return false;
051        }
052        else
053        {
054            this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 4, 6, true, par2Random, StructureStrongholdPieces.getStrongholdStones());
055            this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.doorType, 1, 1, 0);
056            this.placeDoor(par1World, par2Random, par3StructureBoundingBox, EnumDoor.OPENING, 1, 1, 6);
057            this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, 2, 3, 1, 4, Block.stoneBrick.blockID, Block.stoneBrick.blockID, false);
058            this.placeBlockAtCurrentPosition(par1World, Block.stoneSingleSlab.blockID, 5, 3, 1, 1, par3StructureBoundingBox);
059            this.placeBlockAtCurrentPosition(par1World, Block.stoneSingleSlab.blockID, 5, 3, 1, 5, par3StructureBoundingBox);
060            this.placeBlockAtCurrentPosition(par1World, Block.stoneSingleSlab.blockID, 5, 3, 2, 2, par3StructureBoundingBox);
061            this.placeBlockAtCurrentPosition(par1World, Block.stoneSingleSlab.blockID, 5, 3, 2, 4, par3StructureBoundingBox);
062            int i;
063
064            for (i = 2; i <= 4; ++i)
065            {
066                this.placeBlockAtCurrentPosition(par1World, Block.stoneSingleSlab.blockID, 5, 2, 1, i, par3StructureBoundingBox);
067            }
068
069            if (!this.hasMadeChest)
070            {
071                i = this.getYWithOffset(2);
072                int j = this.getXWithOffset(3, 3);
073                int k = this.getZWithOffset(3, 3);
074
075                if (par3StructureBoundingBox.isVecInside(j, i, k))
076                {
077                    this.hasMadeChest = true;
078                    this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 2, 3, ChestGenHooks.getItems(STRONGHOLD_CORRIDOR, par2Random), ChestGenHooks.getCount(STRONGHOLD_CORRIDOR, par2Random));
079                }
080            }
081
082            return true;
083        }
084    }
085}