001package net.minecraft.block;
002
003import cpw.mods.fml.relauncher.Side;
004import cpw.mods.fml.relauncher.SideOnly;
005import java.util.List;
006import net.minecraft.block.material.Material;
007import net.minecraft.creativetab.CreativeTabs;
008import net.minecraft.item.ItemStack;
009import net.minecraft.util.AxisAlignedBB;
010import net.minecraft.world.IBlockAccess;
011import net.minecraft.world.World;
012
013public class BlockWall extends Block
014{
015    /** The types of the wall. */
016    public static final String[] types = new String[] {"normal", "mossy"};
017
018    public BlockWall(int par1, Block par2Block)
019    {
020        super(par1, par2Block.blockIndexInTexture, par2Block.blockMaterial);
021        this.setHardness(par2Block.blockHardness);
022        this.setResistance(par2Block.blockResistance / 3.0F);
023        this.setStepSound(par2Block.stepSound);
024        this.setCreativeTab(CreativeTabs.tabBlock);
025    }
026
027    /**
028     * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
029     */
030    public int getBlockTextureFromSideAndMetadata(int par1, int par2)
031    {
032        return par2 == 1 ? Block.cobblestoneMossy.blockIndexInTexture : super.getBlockTextureFromSide(par1);
033    }
034
035    /**
036     * The type of render function that is called for this block
037     */
038    public int getRenderType()
039    {
040        return 32;
041    }
042
043    /**
044     * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
045     */
046    public boolean renderAsNormalBlock()
047    {
048        return false;
049    }
050
051    public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
052    {
053        return false;
054    }
055
056    /**
057     * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
058     * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
059     */
060    public boolean isOpaqueCube()
061    {
062        return false;
063    }
064
065    /**
066     * Updates the blocks bounds based on its current state. Args: world, x, y, z
067     */
068    public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
069    {
070        boolean var5 = this.canConnectWallTo(par1IBlockAccess, par2, par3, par4 - 1);
071        boolean var6 = this.canConnectWallTo(par1IBlockAccess, par2, par3, par4 + 1);
072        boolean var7 = this.canConnectWallTo(par1IBlockAccess, par2 - 1, par3, par4);
073        boolean var8 = this.canConnectWallTo(par1IBlockAccess, par2 + 1, par3, par4);
074        float var9 = 0.25F;
075        float var10 = 0.75F;
076        float var11 = 0.25F;
077        float var12 = 0.75F;
078        float var13 = 1.0F;
079
080        if (var5)
081        {
082            var11 = 0.0F;
083        }
084
085        if (var6)
086        {
087            var12 = 1.0F;
088        }
089
090        if (var7)
091        {
092            var9 = 0.0F;
093        }
094
095        if (var8)
096        {
097            var10 = 1.0F;
098        }
099
100        if (var5 && var6 && !var7 && !var8)
101        {
102            var13 = 0.8125F;
103            var9 = 0.3125F;
104            var10 = 0.6875F;
105        }
106        else if (!var5 && !var6 && var7 && var8)
107        {
108            var13 = 0.8125F;
109            var11 = 0.3125F;
110            var12 = 0.6875F;
111        }
112
113        this.setBlockBounds(var9, 0.0F, var11, var10, var13, var12);
114    }
115
116    /**
117     * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
118     * cleared to be reused)
119     */
120    public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
121    {
122        this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
123        this.maxY = 1.5D;
124        return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4);
125    }
126
127    /**
128     * Return whether an adjacent block can connect to a wall.
129     */
130    public boolean canConnectWallTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
131    {
132        int var5 = par1IBlockAccess.getBlockId(par2, par3, par4);
133
134        if (var5 != this.blockID && var5 != Block.fenceGate.blockID)
135        {
136            Block var6 = Block.blocksList[var5];
137            return var6 != null && var6.blockMaterial.isOpaque() && var6.renderAsNormalBlock() ? var6.blockMaterial != Material.pumpkin : false;
138        }
139        else
140        {
141            return true;
142        }
143    }
144
145    @SideOnly(Side.CLIENT)
146
147    /**
148     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
149     */
150    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
151    {
152        par3List.add(new ItemStack(par1, 1, 0));
153        par3List.add(new ItemStack(par1, 1, 1));
154    }
155
156    /**
157     * Determines the damage on the item the block drops. Used in cloth and wood.
158     */
159    public int damageDropped(int par1)
160    {
161        return par1;
162    }
163
164    @SideOnly(Side.CLIENT)
165
166    /**
167     * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
168     * coordinates.  Args: blockAccess, x, y, z, side
169     */
170    public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
171    {
172        return par5 == 0 ? super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5) : true;
173    }
174}