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