    001    package net.minecraft.world.gen.structure;
    002
    003    import java.util.Iterator;
    004    import java.util.List;
    005    import java.util.Random;
    006    import net.minecraft.block.Block;
    007    import net.minecraft.block.BlockDirectional;
    008    import net.minecraft.item.ItemDoor;
    009    import net.minecraft.tileentity.TileEntityChest;
    010    import net.minecraft.tileentity.TileEntityDispenser;
    011    import net.minecraft.util.Direction;
    012    import net.minecraft.util.Facing;
    013    import net.minecraft.util.WeightedRandomChestContent;
    014    import net.minecraft.world.ChunkPosition;
    015    import net.minecraft.world.World;
    016
    017    public 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 var1, Random var2, StructureBoundingBox var3);
    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 var2 = par0List.iterator();
    063            StructureComponent var3;
    064
    065            do
    066            {
    067                if (!var2.hasNext())
    068                {
    069                    return null;
    070                }
    071
    072                var3 = (StructureComponent)var2.next();
    073            }
    074            while (var3.getBoundingBox() == null || !var3.getBoundingBox().intersectsWith(par1StructureBoundingBox));
    075
    076            return var3;
    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 var3 = Math.max(this.boundingBox.minX - 1, par2StructureBoundingBox.minX);
    090            int var4 = Math.max(this.boundingBox.minY - 1, par2StructureBoundingBox.minY);
    091            int var5 = Math.max(this.boundingBox.minZ - 1, par2StructureBoundingBox.minZ);
    092            int var6 = Math.min(this.boundingBox.maxX + 1, par2StructureBoundingBox.maxX);
    093            int var7 = Math.min(this.boundingBox.maxY + 1, par2StructureBoundingBox.maxY);
    094            int var8 = Math.min(this.boundingBox.maxZ + 1, par2StructureBoundingBox.maxZ);
    095            int var9;
    096            int var10;
    097            int var11;
    098
    099            for (var9 = var3; var9 <= var6; ++var9)
    100            {
    101                for (var10 = var5; var10 <= var8; ++var10)
    102                {
    103                    var11 = par1World.getBlockId(var9, var4, var10);
    104
    105                    if (var11 > 0 && Block.blocksList[var11].blockMaterial.isLiquid())
    106                    {
    107                        return true;
    108                    }
    109
    110                    var11 = par1World.getBlockId(var9, var7, var10);
    111
    112                    if (var11 > 0 && Block.blocksList[var11].blockMaterial.isLiquid())
    113                    {
    114                        return true;
    115                    }
    116                }
    117            }
    118
    119            for (var9 = var3; var9 <= var6; ++var9)
    120            {
    121                for (var10 = var4; var10 <= var7; ++var10)
    122                {
    123                    var11 = par1World.getBlockId(var9, var10, var5);
    124
    125                    if (var11 > 0 && Block.blocksList[var11].blockMaterial.isLiquid())
    126                    {
    127                        return true;
    128                    }
    129
    130                    var11 = par1World.getBlockId(var9, var10, var8);
    131
    132                    if (var11 > 0 && Block.blocksList[var11].blockMaterial.isLiquid())
    133                    {
    134                        return true;
    135                    }
    136                }
    137            }
    138
    139            for (var9 = var5; var9 <= var8; ++var9)
    140            {
    141                for (var10 = var4; var10 <= var7; ++var10)
    142                {
    143                    var11 = par1World.getBlockId(var3, var10, var9);
    144
    145                    if (var11 > 0 && Block.blocksList[var11].blockMaterial.isLiquid())
    146                    {
    147                        return true;
    148                    }
    149
    150                    var11 = par1World.getBlockId(var6, var10, var9);
    151
    152                    if (var11 > 0 && Block.blocksList[var11].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 var8 = this.getXWithOffset(par4, par6);
    539            int var9 = this.getYWithOffset(par5);
    540            int var10 = this.getZWithOffset(par4, par6);
    541
    542            if (par7StructureBoundingBox.isVecInside(var8, var9, var10))
    543            {
    544                par1World.setBlockAndMetadata(var8, var9, var10, par2, par3);
    545            }
    546        }
    547
    548        protected int getBlockIdAtCurrentPosition(World par1World, int par2, int par3, int par4, StructureBoundingBox par5StructureBoundingBox)
    549        {
    550            int var6 = this.getXWithOffset(par2, par4);
    551            int var7 = this.getYWithOffset(par3);
    552            int var8 = this.getZWithOffset(par2, par4);
    553            return !par5StructureBoundingBox.isVecInside(var6, var7, var8) ? 0 : par1World.getBlockId(var6, var7, var8);
    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 var9 = par4; var9 <= par7; ++var9)
    563            {
    564                for (int var10 = par3; var10 <= par6; ++var10)
    565                {
    566                    for (int var11 = par5; var11 <= par8; ++var11)
    567                    {
    568                        this.placeBlockAtCurrentPosition(par1World, 0, 0, var10, var9, var11, 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 var12 = par4; var12 <= par7; ++var12)
    581            {
    582                for (int var13 = par3; var13 <= par6; ++var13)
    583                {
    584                    for (int var14 = par5; var14 <= par8; ++var14)
    585                    {
    586                        if (!par11 || this.getBlockIdAtCurrentPosition(par1World, var13, var12, var14, par2StructureBoundingBox) != 0)
    587                        {
    588                            if (var12 != par4 && var12 != par7 && var13 != par3 && var13 != par6 && var14 != par5 && var14 != par8)
    589                            {
    590                                this.placeBlockAtCurrentPosition(par1World, par10, 0, var13, var12, var14, par2StructureBoundingBox);
    591                            }
    592                            else
    593                            {
    594                                this.placeBlockAtCurrentPosition(par1World, par9, 0, var13, var12, var14, 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 var14 = par4; var14 <= par7; ++var14)
    610            {
    611                for (int var15 = par3; var15 <= par6; ++var15)
    612                {
    613                    for (int var16 = par5; var16 <= par8; ++var16)
    614                    {
    615                        if (!par13 || this.getBlockIdAtCurrentPosition(par1World, var15, var14, var16, par2StructureBoundingBox) != 0)
    616                        {
    617                            if (var14 != par4 && var14 != par7 && var15 != par3 && var15 != par6 && var16 != par5 && var16 != par8)
    618                            {
    619                                this.placeBlockAtCurrentPosition(par1World, par11, par12, var15, var14, var16, par2StructureBoundingBox);
    620                            }
    621                            else
    622                            {
    623                                this.placeBlockAtCurrentPosition(par1World, par9, par10, var15, var14, var16, 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 var12 = par4; var12 <= par7; ++var12)
    638            {
    639                for (int var13 = par3; var13 <= par6; ++var13)
    640                {
    641                    for (int var14 = par5; var14 <= par8; ++var14)
    642                    {
    643                        if (!par9 || this.getBlockIdAtCurrentPosition(par1World, var13, var12, var14, par2StructureBoundingBox) != 0)
    644                        {
    645                            par11StructurePieceBlockSelector.selectBlocks(par10Random, var13, var12, var14, var12 == par4 || var12 == par7 || var13 == par3 || var13 == par6 || var14 == par5 || var14 == par8);
    646                            this.placeBlockAtCurrentPosition(par1World, par11StructurePieceBlockSelector.getSelectedBlockId(), par11StructurePieceBlockSelector.getSelectedBlockMetaData(), var13, var12, var14, 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 var14 = par6; var14 <= par9; ++var14)
    660            {
    661                for (int var15 = par5; var15 <= par8; ++var15)
    662                {
    663                    for (int var16 = par7; var16 <= par10; ++var16)
    664                    {
    665                        if (par3Random.nextFloat() <= par4 && (!par13 || this.getBlockIdAtCurrentPosition(par1World, var15, var14, var16, par2StructureBoundingBox) != 0))
    666                        {
    667                            if (var14 != par6 && var14 != par9 && var15 != par5 && var15 != par8 && var16 != par7 && var16 != par10)
    668                            {
    669                                this.placeBlockAtCurrentPosition(par1World, par12, 0, var15, var14, var16, par2StructureBoundingBox);
    670                            }
    671                            else
    672                            {
    673                                this.placeBlockAtCurrentPosition(par1World, par11, 0, var15, var14, var16, 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 var11 = (float)(par6 - par3 + 1);
    699            float var12 = (float)(par7 - par4 + 1);
    700            float var13 = (float)(par8 - par5 + 1);
    701            float var14 = (float)par3 + var11 / 2.0F;
    702            float var15 = (float)par5 + var13 / 2.0F;
    703
    704            for (int var16 = par4; var16 <= par7; ++var16)
    705            {
    706                float var17 = (float)(var16 - par4) / var12;
    707
    708                for (int var18 = par3; var18 <= par6; ++var18)
    709                {
    710                    float var19 = ((float)var18 - var14) / (var11 * 0.5F);
    711
    712                    for (int var20 = par5; var20 <= par8; ++var20)
    713                    {
    714                        float var21 = ((float)var20 - var15) / (var13 * 0.5F);
    715
    716                        if (!par10 || this.getBlockIdAtCurrentPosition(par1World, var18, var16, var20, par2StructureBoundingBox) != 0)
    717                        {
    718                            float var22 = var19 * var19 + var17 * var17 + var21 * var21;
    719
    720                            if (var22 <= 1.05F)
    721                            {
    722                                this.placeBlockAtCurrentPosition(par1World, par9, 0, var18, var16, var20, 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 var6 = this.getXWithOffset(par2, par4);
    736            int var7 = this.getYWithOffset(par3);
    737            int var8 = this.getZWithOffset(par2, par4);
    738
    739            if (par5StructureBoundingBox.isVecInside(var6, var7, var8))
    740            {
    741                while (!par1World.isAirBlock(var6, var7, var8) && var7 < 255)
    742                {
    743                    par1World.setBlockAndMetadata(var6, var7, var8, 0, 0);
    744                    ++var7;
    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 var8 = this.getXWithOffset(par4, par6);
    755            int var9 = this.getYWithOffset(par5);
    756            int var10 = this.getZWithOffset(par4, par6);
    757
    758            if (par7StructureBoundingBox.isVecInside(var8, var9, var10))
    759            {
    760                while ((par1World.isAirBlock(var8, var9, var10) || par1World.getBlockMaterial(var8, var9, var10).isLiquid()) && var9 > 1)
    761                {
    762                    par1World.setBlockAndMetadata(var8, var9, var10, par2, par3);
    763                    --var9;
    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 var9 = this.getXWithOffset(par4, par6);
    774            int var10 = this.getYWithOffset(par5);
    775            int var11 = this.getZWithOffset(par4, par6);
    776
    777            if (par2StructureBoundingBox.isVecInside(var9, var10, var11) && par1World.getBlockId(var9, var10, var11) != Block.chest.blockID)
    778            {
    779                par1World.setBlockWithNotify(var9, var10, var11, Block.chest.blockID);
    780                TileEntityChest var12 = (TileEntityChest)par1World.getBlockTileEntity(var9, var10, var11);
    781
    782                if (var12 != null)
    783                {
    784                    WeightedRandomChestContent.generateChestContents(par3Random, par7ArrayOfWeightedRandomChestContent, var12, 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 var10 = this.getXWithOffset(par4, par6);
    801            int var11 = this.getYWithOffset(par5);
    802            int var12 = this.getZWithOffset(par4, par6);
    803
    804            if (par2StructureBoundingBox.isVecInside(var10, var11, var12) && par1World.getBlockId(var10, var11, var12) != Block.dispenser.blockID)
    805            {
    806                par1World.setBlockAndMetadataWithNotify(var10, var11, var12, Block.dispenser.blockID, this.getMetadataWithOffset(Block.dispenser.blockID, par7));
    807                TileEntityDispenser var13 = (TileEntityDispenser)par1World.getBlockTileEntity(var10, var11, var12);
    808
    809                if (var13 != null)
    810                {
    811                    WeightedRandomChestContent.generateDispenserContents(par3Random, par8ArrayOfWeightedRandomChestContent, var13, 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 var8 = this.getXWithOffset(par4, par6);
    825            int var9 = this.getYWithOffset(par5);
    826            int var10 = this.getZWithOffset(par4, par6);
    827
    828            if (par2StructureBoundingBox.isVecInside(var8, var9, var10))
    829            {
    830                ItemDoor.placeDoorBlock(par1World, var8, var9, var10, par7, Block.doorWood);
    831            }
    832        }
    833    }