    001package net.minecraft.world.gen.structure;
    002
    003import java.util.Iterator;
    004import java.util.List;
    005import java.util.Random;
    006import net.minecraft.block.Block;
    007import net.minecraft.block.BlockDirectional;
    008import net.minecraft.item.ItemDoor;
    009import net.minecraft.tileentity.TileEntityChest;
    010import net.minecraft.tileentity.TileEntityDispenser;
    011import net.minecraft.util.Direction;
    012import net.minecraft.util.Facing;
    013import net.minecraft.util.WeightedRandomChestContent;
    014import net.minecraft.world.ChunkPosition;
    015import net.minecraft.world.World;
    016
    017public abstract class StructureComponent
    018{
    019    protected StructureBoundingBox boundingBox;
    020
    021    /** switches the Coordinate System base off the Bounding Box */
    022    protected int coordBaseMode;
    023
    024    /** The type ID of this component. */
    025    protected int componentType;
    026
    027    protected StructureComponent(int par1)
    028    {
    029        this.componentType = par1;
    030        this.coordBaseMode = -1;
    031    }
    032
    033    /**
    034     * Initiates construction of the Structure Component picked, at the current Location of StructGen
    035     */
    036    public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) {}
    037
    038    /**
    039     * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
    040     * the end, it adds Fences...
    041     */
    042    public abstract boolean addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox);
    043
    044    public StructureBoundingBox getBoundingBox()
    045    {
    046        return this.boundingBox;
    047    }
    048
    049    /**
    050     * Returns the component type ID of this component.
    051     */
    052    public int getComponentType()
    053    {
    054        return this.componentType;
    055    }
    056
    057    /**
    058     * Discover if bounding box can fit within the current bounding box object.
    059     */
    060    public static StructureComponent findIntersecting(List par0List, StructureBoundingBox par1StructureBoundingBox)
    061    {
    062        Iterator iterator = par0List.iterator();
    063        StructureComponent structurecomponent;
    064
    065        do
    066        {
    067            if (!iterator.hasNext())
    068            {
    069                return null;
    070            }
    071
    072            structurecomponent = (StructureComponent)iterator.next();
    073        }
    074        while (structurecomponent.getBoundingBox() == null || !structurecomponent.getBoundingBox().intersectsWith(par1StructureBoundingBox));
    075
    076        return structurecomponent;
    077    }
    078
    079    public ChunkPosition getCenter()
    080    {
    081        return new ChunkPosition(this.boundingBox.getCenterX(), this.boundingBox.getCenterY(), this.boundingBox.getCenterZ());
    082    }
    083
    084    /**
    085     * checks the entire StructureBoundingBox for Liquids
    086     */
    087    protected boolean isLiquidInStructureBoundingBox(World par1World, StructureBoundingBox par2StructureBoundingBox)
    088    {
    089        int i = Math.max(this.boundingBox.minX - 1, par2StructureBoundingBox.minX);
    090        int j = Math.max(this.boundingBox.minY - 1, par2StructureBoundingBox.minY);
    091        int k = Math.max(this.boundingBox.minZ - 1, par2StructureBoundingBox.minZ);
    092        int l = Math.min(this.boundingBox.maxX + 1, par2StructureBoundingBox.maxX);
    093        int i1 = Math.min(this.boundingBox.maxY + 1, par2StructureBoundingBox.maxY);
    094        int j1 = Math.min(this.boundingBox.maxZ + 1, par2StructureBoundingBox.maxZ);
    095        int k1;
    096        int l1;
    097        int i2;
    098
    099        for (k1 = i; k1 <= l; ++k1)
    100        {
    101            for (l1 = k; l1 <= j1; ++l1)
    102            {
    103                i2 = par1World.getBlockId(k1, j, l1);
    104
    105                if (i2 > 0 && Block.blocksList[i2].blockMaterial.isLiquid())
    106                {
    107                    return true;
    108                }
    109
    110                i2 = par1World.getBlockId(k1, i1, l1);
    111
    112                if (i2 > 0 && Block.blocksList[i2].blockMaterial.isLiquid())
    113                {
    114                    return true;
    115                }
    116            }
    117        }
    118
    119        for (k1 = i; k1 <= l; ++k1)
    120        {
    121            for (l1 = j; l1 <= i1; ++l1)
    122            {
    123                i2 = par1World.getBlockId(k1, l1, k);
    124
    125                if (i2 > 0 && Block.blocksList[i2].blockMaterial.isLiquid())
    126                {
    127                    return true;
    128                }
    129
    130                i2 = par1World.getBlockId(k1, l1, j1);
    131
    132                if (i2 > 0 && Block.blocksList[i2].blockMaterial.isLiquid())
    133                {
    134                    return true;
    135                }
    136            }
    137        }
    138
    139        for (k1 = k; k1 <= j1; ++k1)
    140        {
    141            for (l1 = j; l1 <= i1; ++l1)
    142            {
    143                i2 = par1World.getBlockId(i, l1, k1);
    144
    145                if (i2 > 0 && Block.blocksList[i2].blockMaterial.isLiquid())
    146                {
    147                    return true;
    148                }
    149
    150                i2 = par1World.getBlockId(l, l1, k1);
    151
    152                if (i2 > 0 && Block.blocksList[i2].blockMaterial.isLiquid())
    153                {
    154                    return true;
    155                }
    156            }
    157        }
    158
    159        return false;
    160    }
    161
    162    protected int getXWithOffset(int par1, int par2)
    163    {
    164        switch (this.coordBaseMode)
    165        {
    166            case 0:
    167            case 2:
    168                return this.boundingBox.minX + par1;
    169            case 1:
    170                return this.boundingBox.maxX - par2;
    171            case 3:
    172                return this.boundingBox.minX + par2;
    173            default:
    174                return par1;
    175        }
    176    }
    177
    178    protected int getYWithOffset(int par1)
    179    {
    180        return this.coordBaseMode == -1 ? par1 : par1 + this.boundingBox.minY;
    181    }
    182
    183    protected int getZWithOffset(int par1, int par2)
    184    {
    185        switch (this.coordBaseMode)
    186        {
    187            case 0:
    188                return this.boundingBox.minZ + par2;
    189            case 1:
    190            case 3:
    191                return this.boundingBox.minZ + par1;
    192            case 2:
    193                return this.boundingBox.maxZ - par2;
    194            default:
    195                return par2;
    196        }
    197    }
    198
    199    /**
    200     * Returns the direction-shifted metadata for blocks that require orientation, e.g. doors, stairs, ladders.
    201     * Parameters: block ID, original metadata
    202     */
    203    protected int getMetadataWithOffset(int par1, int par2)
    204    {
    205        if (par1 == Block.rail.blockID)
    206        {
    207            if (this.coordBaseMode == 1 || this.coordBaseMode == 3)
    208            {
    209                if (par2 == 1)
    210                {
    211                    return 0;
    212                }
    213
    214                return 1;
    215            }
    216        }
    217        else if (par1 != Block.doorWood.blockID && par1 != Block.doorSteel.blockID)
    218        {
    219            if (par1 != Block.stairCompactCobblestone.blockID && par1 != Block.stairCompactPlanks.blockID && par1 != Block.stairsNetherBrick.blockID && par1 != Block.stairsStoneBrickSmooth.blockID && par1 != Block.stairsSandStone.blockID)
    220            {
    221                if (par1 == Block.ladder.blockID)
    222                {
    223                    if (this.coordBaseMode == 0)
    224                    {
    225                        if (par2 == 2)
    226                        {
    227                            return 3;
    228                        }
    229
    230                        if (par2 == 3)
    231                        {
    232                            return 2;
    233                        }
    234                    }
    235                    else if (this.coordBaseMode == 1)
    236                    {
    237                        if (par2 == 2)
    238                        {
    239                            return 4;
    240                        }
    241
    242                        if (par2 == 3)
    243                        {
    244                            return 5;
    245                        }
    246
    247                        if (par2 == 4)
    248                        {
    249                            return 2;
    250                        }
    251
    252                        if (par2 == 5)
    253                        {
    254                            return 3;
    255                        }
    256                    }
    257                    else if (this.coordBaseMode == 3)
    258                    {
    259                        if (par2 == 2)
    260                        {
    261                            return 5;
    262                        }
    263
    264                        if (par2 == 3)
    265                        {
    266                            return 4;
    267                        }
    268
    269                        if (par2 == 4)
    270                        {
    271                            return 2;
    272                        }
    273
    274                        if (par2 == 5)
    275                        {
    276                            return 3;
    277                        }
    278                    }
    279                }
    280                else if (par1 == Block.stoneButton.blockID)
    281                {
    282                    if (this.coordBaseMode == 0)
    283                    {
    284                        if (par2 == 3)
    285                        {
    286                            return 4;
    287                        }
    288
    289                        if (par2 == 4)
    290                        {
    291                            return 3;
    292                        }
    293                    }
    294                    else if (this.coordBaseMode == 1)
    295                    {
    296                        if (par2 == 3)
    297                        {
    298                            return 1;
    299                        }
    300
    301                        if (par2 == 4)
    302                        {
    303                            return 2;
    304                        }
    305
    306                        if (par2 == 2)
    307                        {
    308                            return 3;
    309                        }
    310
    311                        if (par2 == 1)
    312                        {
    313                            return 4;
    314                        }
    315                    }
    316                    else if (this.coordBaseMode == 3)
    317                    {
    318                        if (par2 == 3)
    319                        {
    320                            return 2;
    321                        }
    322
    323                        if (par2 == 4)
    324                        {
    325                            return 1;
    326                        }
    327
    328                        if (par2 == 2)
    329                        {
    330                            return 3;
    331                        }
    332
    333                        if (par2 == 1)
    334                        {
    335                            return 4;
    336                        }
    337                    }
    338                }
    339                else if (par1 != Block.tripWireSource.blockID && (Block.blocksList[par1] == null || !(Block.blocksList[par1] instanceof BlockDirectional)))
    340                {
    341                    if (par1 == Block.pistonBase.blockID || par1 == Block.pistonStickyBase.blockID || par1 == Block.lever.blockID || par1 == Block.dispenser.blockID)
    342                    {
    343                        if (this.coordBaseMode == 0)
    344                        {
    345                            if (par2 == 2 || par2 == 3)
    346                            {
    347                                return Facing.faceToSide[par2];
    348                            }
    349                        }
    350                        else if (this.coordBaseMode == 1)
    351                        {
    352                            if (par2 == 2)
    353                            {
    354                                return 4;
    355                            }
    356
    357                            if (par2 == 3)
    358                            {
    359                                return 5;
    360                            }
    361
    362                            if (par2 == 4)
    363                            {
    364                                return 2;
    365                            }
    366
    367                            if (par2 == 5)
    368                            {
    369                                return 3;
    370                            }
    371                        }
    372                        else if (this.coordBaseMode == 3)
    373                        {
    374                            if (par2 == 2)
    375                            {
    376                                return 5;
    377                            }
    378
    379                            if (par2 == 3)
    380                            {
    381                                return 4;
    382                            }
    383
    384                            if (par2 == 4)
    385                            {
    386                                return 2;
    387                            }
    388
    389                            if (par2 == 5)
    390                            {
    391                                return 3;
    392                            }
    393                        }
    394                    }
    395                }
    396                else if (this.coordBaseMode == 0)
    397                {
    398                    if (par2 == 0 || par2 == 2)
    399                    {
    400                        return Direction.footInvisibleFaceRemap[par2];
    401                    }
    402                }
    403                else if (this.coordBaseMode == 1)
    404                {
    405                    if (par2 == 2)
    406                    {
    407                        return 1;
    408                    }
    409
    410                    if (par2 == 0)
    411                    {
    412                        return 3;
    413                    }
    414
    415                    if (par2 == 1)
    416                    {
    417                        return 2;
    418                    }
    419
    420                    if (par2 == 3)
    421                    {
    422                        return 0;
    423                    }
    424                }
    425                else if (this.coordBaseMode == 3)
    426                {
    427                    if (par2 == 2)
    428                    {
    429                        return 3;
    430                    }
    431
    432                    if (par2 == 0)
    433                    {
    434                        return 1;
    435                    }
    436
    437                    if (par2 == 1)
    438                    {
    439                        return 2;
    440                    }
    441
    442                    if (par2 == 3)
    443                    {
    444                        return 0;
    445                    }
    446                }
    447            }
    448            else if (this.coordBaseMode == 0)
    449            {
    450                if (par2 == 2)
    451                {
    452                    return 3;
    453                }
    454
    455                if (par2 == 3)
    456                {
    457                    return 2;
    458                }
    459            }
    460            else if (this.coordBaseMode == 1)
    461            {
    462                if (par2 == 0)
    463                {
    464                    return 2;
    465                }
    466
    467                if (par2 == 1)
    468                {
    469                    return 3;
    470                }
    471
    472                if (par2 == 2)
    473                {
    474                    return 0;
    475                }
    476
    477                if (par2 == 3)
    478                {
    479                    return 1;
    480                }
    481            }
    482            else if (this.coordBaseMode == 3)
    483            {
    484                if (par2 == 0)
    485                {
    486                    return 2;
    487                }
    488
    489                if (par2 == 1)
    490                {
    491                    return 3;
    492                }
    493
    494                if (par2 == 2)
    495                {
    496                    return 1;
    497                }
    498
    499                if (par2 == 3)
    500                {
    501                    return 0;
    502                }
    503            }
    504        }
    505        else if (this.coordBaseMode == 0)
    506        {
    507            if (par2 == 0)
    508            {
    509                return 2;
    510            }
    511
    512            if (par2 == 2)
    513            {
    514                return 0;
    515            }
    516        }
    517        else
    518        {
    519            if (this.coordBaseMode == 1)
    520            {
    521                return par2 + 1 & 3;
    522            }
    523
    524            if (this.coordBaseMode == 3)
    525            {
    526                return par2 + 3 & 3;
    527            }
    528        }
    529
    530        return par2;
    531    }
    532
    533    /**
    534     * current Position depends on currently set Coordinates mode, is computed here
    535     */
    536    protected void placeBlockAtCurrentPosition(World par1World, int par2, int par3, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox)
    537    {
    538        int j1 = this.getXWithOffset(par4, par6);
    539        int k1 = this.getYWithOffset(par5);
    540        int l1 = this.getZWithOffset(par4, par6);
    541
    542        if (par7StructureBoundingBox.isVecInside(j1, k1, l1))
    543        {
    544            par1World.setBlockAndMetadataWithNotify(j1, k1, l1, par2, par3, 2);
    545        }
    546    }
    547
    548    protected int getBlockIdAtCurrentPosition(World par1World, int par2, int par3, int par4, StructureBoundingBox par5StructureBoundingBox)
    549    {
    550        int l = this.getXWithOffset(par2, par4);
    551        int i1 = this.getYWithOffset(par3);
    552        int j1 = this.getZWithOffset(par2, par4);
    553        return !par5StructureBoundingBox.isVecInside(l, i1, j1) ? 0 : par1World.getBlockId(l, i1, j1);
    554    }
    555
    556    /**
    557     * arguments: (World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int
    558     * maxZ)
    559     */
    560    protected void fillWithAir(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8)
    561    {
    562        for (int k1 = par4; k1 <= par7; ++k1)
    563        {
    564            for (int l1 = par3; l1 <= par6; ++l1)
    565            {
    566                for (int i2 = par5; i2 <= par8; ++i2)
    567                {
    568                    this.placeBlockAtCurrentPosition(par1World, 0, 0, l1, k1, i2, par2StructureBoundingBox);
    569                }
    570            }
    571        }
    572    }
    573
    574    /**
    575     * arguments: (World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int
    576     * maxZ, int placeBlockId, int replaceBlockId, boolean alwaysreplace)
    577     */
    578    protected void fillWithBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8, int par9, int par10, boolean par11)
    579    {
    580        for (int i2 = par4; i2 <= par7; ++i2)
    581        {
    582            for (int j2 = par3; j2 <= par6; ++j2)
    583            {
    584                for (int k2 = par5; k2 <= par8; ++k2)
    585                {
    586                    if (!par11 || this.getBlockIdAtCurrentPosition(par1World, j2, i2, k2, par2StructureBoundingBox) != 0)
    587                    {
    588                        if (i2 != par4 && i2 != par7 && j2 != par3 && j2 != par6 && k2 != par5 && k2 != par8)
    589                        {
    590                            this.placeBlockAtCurrentPosition(par1World, par10, 0, j2, i2, k2, par2StructureBoundingBox);
    591                        }
    592                        else
    593                        {
    594                            this.placeBlockAtCurrentPosition(par1World, par9, 0, j2, i2, k2, par2StructureBoundingBox);
    595                        }
    596                    }
    597                }
    598            }
    599        }
    600    }
    601
    602    /**
    603     * arguments: (World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int
    604     * maxZ, int placeBlockId, int placeBlockMetadata, int replaceBlockId, int replaceBlockMetadata, boolean
    605     * alwaysreplace)
    606     */
    607    protected void fillWithMetadataBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8, int par9, int par10, int par11, int par12, boolean par13)
    608    {
    609        for (int k2 = par4; k2 <= par7; ++k2)
    610        {
    611            for (int l2 = par3; l2 <= par6; ++l2)
    612            {
    613                for (int i3 = par5; i3 <= par8; ++i3)
    614                {
    615                    if (!par13 || this.getBlockIdAtCurrentPosition(par1World, l2, k2, i3, par2StructureBoundingBox) != 0)
    616                    {
    617                        if (k2 != par4 && k2 != par7 && l2 != par3 && l2 != par6 && i3 != par5 && i3 != par8)
    618                        {
    619                            this.placeBlockAtCurrentPosition(par1World, par11, par12, l2, k2, i3, par2StructureBoundingBox);
    620                        }
    621                        else
    622                        {
    623                            this.placeBlockAtCurrentPosition(par1World, par9, par10, l2, k2, i3, par2StructureBoundingBox);
    624                        }
    625                    }
    626                }
    627            }
    628        }
    629    }
    630
    631    /**
    632     * arguments: World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int
    633     * maxZ, boolean alwaysreplace, Random rand, StructurePieceBlockSelector blockselector
    634     */
    635    protected void fillWithRandomizedBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8, boolean par9, Random par10Random, StructurePieceBlockSelector par11StructurePieceBlockSelector)
    636    {
    637        for (int k1 = par4; k1 <= par7; ++k1)
    638        {
    639            for (int l1 = par3; l1 <= par6; ++l1)
    640            {
    641                for (int i2 = par5; i2 <= par8; ++i2)
    642                {
    643                    if (!par9 || this.getBlockIdAtCurrentPosition(par1World, l1, k1, i2, par2StructureBoundingBox) != 0)
    644                    {
    645                        par11StructurePieceBlockSelector.selectBlocks(par10Random, l1, k1, i2, k1 == par4 || k1 == par7 || l1 == par3 || l1 == par6 || i2 == par5 || i2 == par8);
    646                        this.placeBlockAtCurrentPosition(par1World, par11StructurePieceBlockSelector.getSelectedBlockId(), par11StructurePieceBlockSelector.getSelectedBlockMetaData(), l1, k1, i2, par2StructureBoundingBox);
    647                    }
    648                }
    649            }
    650        }
    651    }
    652
    653    /**
    654     * arguments: World worldObj, StructureBoundingBox structBB, Random rand, float randLimit, int minX, int minY, int
    655     * minZ, int maxX, int maxY, int maxZ, int olaceBlockId, int replaceBlockId, boolean alwaysreplace
    656     */
    657    protected void randomlyFillWithBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, float par4, int par5, int par6, int par7, int par8, int par9, int par10, int par11, int par12, boolean par13)
    658    {
    659        for (int i2 = par6; i2 <= par9; ++i2)
    660        {
    661            for (int j2 = par5; j2 <= par8; ++j2)
    662            {
    663                for (int k2 = par7; k2 <= par10; ++k2)
    664                {
    665                    if (par3Random.nextFloat() <= par4 && (!par13 || this.getBlockIdAtCurrentPosition(par1World, j2, i2, k2, par2StructureBoundingBox) != 0))
    666                    {
    667                        if (i2 != par6 && i2 != par9 && j2 != par5 && j2 != par8 && k2 != par7 && k2 != par10)
    668                        {
    669                            this.placeBlockAtCurrentPosition(par1World, par12, 0, j2, i2, k2, par2StructureBoundingBox);
    670                        }
    671                        else
    672                        {
    673                            this.placeBlockAtCurrentPosition(par1World, par11, 0, j2, i2, k2, par2StructureBoundingBox);
    674                        }
    675                    }
    676                }
    677            }
    678        }
    679    }
    680
    681    /**
    682     * Randomly decides if placing or not. Used for Decoration such as Torches and Spiderwebs
    683     */
    684    protected void randomlyPlaceBlock(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, float par4, int par5, int par6, int par7, int par8, int par9)
    685    {
    686        if (par3Random.nextFloat() < par4)
    687        {
    688            this.placeBlockAtCurrentPosition(par1World, par8, par9, par5, par6, par7, par2StructureBoundingBox);
    689        }
    690    }
    691
    692    /**
    693     * arguments: World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int
    694     * maxZ, int placeBlockId, boolean alwaysreplace
    695     */
    696    protected void randomlyRareFillWithBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8, int par9, boolean par10)
    697    {
    698        float f = (float)(par6 - par3 + 1);
    699        float f1 = (float)(par7 - par4 + 1);
    700        float f2 = (float)(par8 - par5 + 1);
    701        float f3 = (float)par3 + f / 2.0F;
    702        float f4 = (float)par5 + f2 / 2.0F;
    703
    704        for (int l1 = par4; l1 <= par7; ++l1)
    705        {
    706            float f5 = (float)(l1 - par4) / f1;
    707
    708            for (int i2 = par3; i2 <= par6; ++i2)
    709            {
    710                float f6 = ((float)i2 - f3) / (f * 0.5F);
    711
    712                for (int j2 = par5; j2 <= par8; ++j2)
    713                {
    714                    float f7 = ((float)j2 - f4) / (f2 * 0.5F);
    715
    716                    if (!par10 || this.getBlockIdAtCurrentPosition(par1World, i2, l1, j2, par2StructureBoundingBox) != 0)
    717                    {
    718                        float f8 = f6 * f6 + f5 * f5 + f7 * f7;
    719
    720                        if (f8 <= 1.05F)
    721                        {
    722                            this.placeBlockAtCurrentPosition(par1World, par9, 0, i2, l1, j2, par2StructureBoundingBox);
    723                        }
    724                    }
    725                }
    726            }
    727        }
    728    }
    729
    730    /**
    731     * Deletes all continuous blocks from selected position upwards. Stops at hitting air.
    732     */
    733    protected void clearCurrentPositionBlocksUpwards(World par1World, int par2, int par3, int par4, StructureBoundingBox par5StructureBoundingBox)
    734    {
    735        int l = this.getXWithOffset(par2, par4);
    736        int i1 = this.getYWithOffset(par3);
    737        int j1 = this.getZWithOffset(par2, par4);
    738
    739        if (par5StructureBoundingBox.isVecInside(l, i1, j1))
    740        {
    741            while (!par1World.isAirBlock(l, i1, j1) && i1 < 255)
    742            {
    743                par1World.setBlockAndMetadataWithNotify(l, i1, j1, 0, 0, 2);
    744                ++i1;
    745            }
    746        }
    747    }
    748
    749    /**
    750     * Overwrites air and liquids from selected position downwards, stops at hitting anything else.
    751     */
    752    protected void fillCurrentPositionBlocksDownwards(World par1World, int par2, int par3, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox)
    753    {
    754        int j1 = this.getXWithOffset(par4, par6);
    755        int k1 = this.getYWithOffset(par5);
    756        int l1 = this.getZWithOffset(par4, par6);
    757
    758        if (par7StructureBoundingBox.isVecInside(j1, k1, l1))
    759        {
    760            while ((par1World.isAirBlock(j1, k1, l1) || par1World.getBlockMaterial(j1, k1, l1).isLiquid()) && k1 > 1)
    761            {
    762                par1World.setBlockAndMetadataWithNotify(j1, k1, l1, par2, par3, 2);
    763                --k1;
    764            }
    765        }
    766    }
    767
    768    /**
    769     * Used to generate chests with items in it. ex: Temple Chests, Village Blacksmith Chests, Mineshaft Chests.
    770     */
    771    protected boolean generateStructureChestContents(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, int par4, int par5, int par6, WeightedRandomChestContent[] par7ArrayOfWeightedRandomChestContent, int par8)
    772    {
    773        int i1 = this.getXWithOffset(par4, par6);
    774        int j1 = this.getYWithOffset(par5);
    775        int k1 = this.getZWithOffset(par4, par6);
    776
    777        if (par2StructureBoundingBox.isVecInside(i1, j1, k1) && par1World.getBlockId(i1, j1, k1) != Block.chest.blockID)
    778        {
    779            par1World.setBlockAndMetadataWithNotify(i1, j1, k1, Block.chest.blockID, 0, 2);
    780            TileEntityChest tileentitychest = (TileEntityChest)par1World.getBlockTileEntity(i1, j1, k1);
    781
    782            if (tileentitychest != null)
    783            {
    784                WeightedRandomChestContent.generateChestContents(par3Random, par7ArrayOfWeightedRandomChestContent, tileentitychest, par8);
    785            }
    786
    787            return true;
    788        }
    789        else
    790        {
    791            return false;
    792        }
    793    }
    794
    795    /**
    796     * Used to generate dispenser contents for structures. ex: Jungle Temples.
    797     */
    798    protected boolean generateStructureDispenserContents(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, int par4, int par5, int par6, int par7, WeightedRandomChestContent[] par8ArrayOfWeightedRandomChestContent, int par9)
    799    {
    800        int j1 = this.getXWithOffset(par4, par6);
    801        int k1 = this.getYWithOffset(par5);
    802        int l1 = this.getZWithOffset(par4, par6);
    803
    804        if (par2StructureBoundingBox.isVecInside(j1, k1, l1) && par1World.getBlockId(j1, k1, l1) != Block.dispenser.blockID)
    805        {
    806            par1World.setBlockAndMetadataWithNotify(j1, k1, l1, Block.dispenser.blockID, this.getMetadataWithOffset(Block.dispenser.blockID, par7), 2);
    807            TileEntityDispenser tileentitydispenser = (TileEntityDispenser)par1World.getBlockTileEntity(j1, k1, l1);
    808
    809            if (tileentitydispenser != null)
    810            {
    811                WeightedRandomChestContent.generateDispenserContents(par3Random, par8ArrayOfWeightedRandomChestContent, tileentitydispenser, par9);
    812            }
    813
    814            return true;
    815        }
    816        else
    817        {
    818            return false;
    819        }
    820    }
    821
    822    protected void placeDoorAtCurrentPosition(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, int par4, int par5, int par6, int par7)
    823    {
    824        int i1 = this.getXWithOffset(par4, par6);
    825        int j1 = this.getYWithOffset(par5);
    826        int k1 = this.getZWithOffset(par4, par6);
    827
    828        if (par2StructureBoundingBox.isVecInside(i1, j1, k1))
    829        {
    830            ItemDoor.placeDoorBlock(par1World, i1, j1, k1, par7, Block.doorWood);
    831        }
    832    }
    833}