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 boolean var5 = this.canConnectWallTo(par1World, par2, par3, par4 - 1);
117 boolean var6 = this.canConnectWallTo(par1World, par2, par3, par4 + 1);
118 boolean var7 = this.canConnectWallTo(par1World, par2 - 1, par3, par4);
119 boolean var8 = this.canConnectWallTo(par1World, par2 + 1, par3, par4);
120 float var9 = 0.375F;
121 float var10 = 0.625F;
122 float var11 = 0.375F;
123 float var12 = 0.625F;
124
125 if (var5)
126 {
127 var11 = 0.0F;
128 }
129
130 if (var6)
131 {
132 var12 = 1.0F;
133 }
134
135 if (var7)
136 {
137 var9 = 0.0F;
138 }
139
140 if (var8)
141 {
142 var10 = 1.0F;
143 }
144
145 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));
146 }
147
148 /**
149 * Return whether an adjacent block can connect to a wall.
150 */
151 public boolean canConnectWallTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
152 {
153 int var5 = par1IBlockAccess.getBlockId(par2, par3, par4);
154
155 if (var5 != this.blockID && var5 != Block.fenceGate.blockID)
156 {
157 Block var6 = Block.blocksList[var5];
158 return var6 != null && var6.blockMaterial.isOpaque() && var6.renderAsNormalBlock() ? var6.blockMaterial != Material.pumpkin : false;
159 }
160 else
161 {
162 return true;
163 }
164 }
165
166 @SideOnly(Side.CLIENT)
167
168 /**
169 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
170 */
171 public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
172 {
173 par3List.add(new ItemStack(par1, 1, 0));
174 par3List.add(new ItemStack(par1, 1, 1));
175 }
176
177 /**
178 * Determines the damage on the item the block drops. Used in cloth and wood.
179 */
180 public int damageDropped(int par1)
181 {
182 return par1;
183 }
184
185 @SideOnly(Side.CLIENT)
186
187 /**
188 * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
189 * coordinates. Args: blockAccess, x, y, z, side
190 */
191 public boolean shouldSideBeRendered(IBlockAccess var1, int var2, int var3, int var4, int var5)
192 {
193 return var5 == 0 ? super.shouldSideBeRendered(var1, var2, var3, var4, var5) : true;
194 }
195 }