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