    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005
    006    public class BlockFence extends Block
    007    {
    008        public BlockFence(int par1, int par2)
    009        {
    010            super(par1, par2, Material.wood);
    011            this.setCreativeTab(CreativeTabs.tabDecorations);
    012        }
    013
    014        public BlockFence(int par1, int par2, Material par3Material)
    015        {
    016            super(par1, par2, par3Material);
    017            this.setCreativeTab(CreativeTabs.tabDecorations);
    018        }
    019
    020        /**
    021         * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
    022         * cleared to be reused)
    023         */
    024        public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    025        {
    026            boolean var5 = this.canConnectFenceTo(par1World, par2, par3, par4 - 1);
    027            boolean var6 = this.canConnectFenceTo(par1World, par2, par3, par4 + 1);
    028            boolean var7 = this.canConnectFenceTo(par1World, par2 - 1, par3, par4);
    029            boolean var8 = this.canConnectFenceTo(par1World, par2 + 1, par3, par4);
    030            float var9 = 0.375F;
    031            float var10 = 0.625F;
    032            float var11 = 0.375F;
    033            float var12 = 0.625F;
    034
    035            if (var5)
    036            {
    037                var11 = 0.0F;
    038            }
    039
    040            if (var6)
    041            {
    042                var12 = 1.0F;
    043            }
    044
    045            if (var7)
    046            {
    047                var9 = 0.0F;
    048            }
    049
    050            if (var8)
    051            {
    052                var10 = 1.0F;
    053            }
    054
    055            return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)((float)par2 + var9), (double)par3, (double)((float)par4 + var11), (double)((float)par2 + var10), (double)((float)par3 + 1.5F), (double)((float)par4 + var12));
    056        }
    057
    058        /**
    059         * Updates the blocks bounds based on its current state. Args: world, x, y, z
    060         */
    061        public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
    062        {
    063            boolean var5 = this.canConnectFenceTo(par1IBlockAccess, par2, par3, par4 - 1);
    064            boolean var6 = this.canConnectFenceTo(par1IBlockAccess, par2, par3, par4 + 1);
    065            boolean var7 = this.canConnectFenceTo(par1IBlockAccess, par2 - 1, par3, par4);
    066            boolean var8 = this.canConnectFenceTo(par1IBlockAccess, par2 + 1, par3, par4);
    067            float var9 = 0.375F;
    068            float var10 = 0.625F;
    069            float var11 = 0.375F;
    070            float var12 = 0.625F;
    071
    072            if (var5)
    073            {
    074                var11 = 0.0F;
    075            }
    076
    077            if (var6)
    078            {
    079                var12 = 1.0F;
    080            }
    081
    082            if (var7)
    083            {
    084                var9 = 0.0F;
    085            }
    086
    087            if (var8)
    088            {
    089                var10 = 1.0F;
    090            }
    091
    092            this.setBlockBounds(var9, 0.0F, var11, var10, 1.0F, var12);
    093        }
    094
    095        /**
    096         * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
    097         * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
    098         */
    099        public boolean isOpaqueCube()
    100        {
    101            return false;
    102        }
    103
    104        /**
    105         * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
    106         */
    107        public boolean renderAsNormalBlock()
    108        {
    109            return false;
    110        }
    111
    112        public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
    113        {
    114            return false;
    115        }
    116
    117        /**
    118         * The type of render function that is called for this block
    119         */
    120        public int getRenderType()
    121        {
    122            return 11;
    123        }
    124
    125        /**
    126         * Returns true if the specified block can be connected by a fence
    127         */
    128        public boolean canConnectFenceTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
    129        {
    130            int var5 = par1IBlockAccess.getBlockId(par2, par3, par4);
    131
    132            if (var5 != this.blockID && var5 != Block.fenceGate.blockID)
    133            {
    134                Block var6 = Block.blocksList[var5];
    135                return var6 != null && var6.blockMaterial.isOpaque() && var6.renderAsNormalBlock() ? var6.blockMaterial != Material.pumpkin : false;
    136            }
    137            else
    138            {
    139                return true;
    140            }
    141        }
    142
    143        public static boolean isIdAFence(int par0)
    144        {
    145            return par0 == Block.fence.blockID || par0 == Block.netherFence.blockID;
    146        }
    147
    148        @SideOnly(Side.CLIENT)
    149
    150        /**
    151         * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
    152         * coordinates.  Args: blockAccess, x, y, z, side
    153         */
    154        public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    155        {
    156            return par5 != 1 && par5 != 0 ? true : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
    157        }
    158    }