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