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 import java.util.Random;
007
008 public class BlockPane extends Block
009 {
010 /**
011 * Holds the texture index of the side of the pane (the thin lateral side)
012 */
013 private int sideTextureIndex;
014
015 /**
016 * If this field is true, the pane block drops itself when destroyed (like the iron fences), otherwise, it's just
017 * destroyed (like glass panes)
018 */
019 private final boolean canDropItself;
020
021 protected BlockPane(int par1, int par2, int par3, Material par4Material, boolean par5)
022 {
023 super(par1, par2, par4Material);
024 this.sideTextureIndex = par3;
025 this.canDropItself = par5;
026 this.setCreativeTab(CreativeTabs.tabDecorations);
027 }
028
029 /**
030 * Returns the ID of the items to drop on destruction.
031 */
032 public int idDropped(int par1, Random par2Random, int par3)
033 {
034 return !this.canDropItself ? 0 : super.idDropped(par1, par2Random, par3);
035 }
036
037 /**
038 * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
039 * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
040 */
041 public boolean isOpaqueCube()
042 {
043 return false;
044 }
045
046 /**
047 * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
048 */
049 public boolean renderAsNormalBlock()
050 {
051 return false;
052 }
053
054 /**
055 * The type of render function that is called for this block
056 */
057 public int getRenderType()
058 {
059 return 18;
060 }
061
062 @SideOnly(Side.CLIENT)
063
064 /**
065 * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
066 * coordinates. Args: blockAccess, x, y, z, side
067 */
068 public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
069 {
070 int var6 = par1IBlockAccess.getBlockId(par2, par3, par4);
071 return var6 == this.blockID ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
072 }
073
074 /**
075 * if the specified block is in the given AABB, add its collision bounding box to the given list
076 */
077 public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
078 {
079 boolean var8 = this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 - 1));
080 boolean var9 = this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 + 1));
081 boolean var10 = this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 - 1, par3, par4));
082 boolean var11 = this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 + 1, par3, par4));
083
084 if ((!var10 || !var11) && (var10 || var11 || var8 || var9))
085 {
086 if (var10 && !var11)
087 {
088 this.setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
089 super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
090 }
091 else if (!var10 && var11)
092 {
093 this.setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
094 super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
095 }
096 }
097 else
098 {
099 this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
100 super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
101 }
102
103 if ((!var8 || !var9) && (var10 || var11 || var8 || var9))
104 {
105 if (var8 && !var9)
106 {
107 this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
108 super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
109 }
110 else if (!var8 && var9)
111 {
112 this.setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
113 super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
114 }
115 }
116 else
117 {
118 this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
119 super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
120 }
121 }
122
123 /**
124 * Sets the block's bounds for rendering it as an item
125 */
126 public void setBlockBoundsForItemRender()
127 {
128 this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
129 }
130
131 /**
132 * Updates the blocks bounds based on its current state. Args: world, x, y, z
133 */
134 public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
135 {
136 float var5 = 0.4375F;
137 float var6 = 0.5625F;
138 float var7 = 0.4375F;
139 float var8 = 0.5625F;
140 boolean var9 = this.canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2, par3, par4 - 1));
141 boolean var10 = this.canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2, par3, par4 + 1));
142 boolean var11 = this.canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2 - 1, par3, par4));
143 boolean var12 = this.canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2 + 1, par3, par4));
144
145 if ((!var11 || !var12) && (var11 || var12 || var9 || var10))
146 {
147 if (var11 && !var12)
148 {
149 var5 = 0.0F;
150 }
151 else if (!var11 && var12)
152 {
153 var6 = 1.0F;
154 }
155 }
156 else
157 {
158 var5 = 0.0F;
159 var6 = 1.0F;
160 }
161
162 if ((!var9 || !var10) && (var11 || var12 || var9 || var10))
163 {
164 if (var9 && !var10)
165 {
166 var7 = 0.0F;
167 }
168 else if (!var9 && var10)
169 {
170 var8 = 1.0F;
171 }
172 }
173 else
174 {
175 var7 = 0.0F;
176 var8 = 1.0F;
177 }
178
179 this.setBlockBounds(var5, 0.0F, var7, var6, 1.0F, var8);
180 }
181
182 @SideOnly(Side.CLIENT)
183
184 /**
185 * Returns the texture index of the thin side of the pane.
186 */
187 public int getSideTextureIndex()
188 {
189 return this.sideTextureIndex;
190 }
191
192 /**
193 * Gets passed in the blockID of the block adjacent and supposed to return true if its allowed to connect to the
194 * type of blockID passed in. Args: blockID
195 */
196 public final boolean canThisPaneConnectToThisBlockID(int par1)
197 {
198 return Block.opaqueCubeLookup[par1] || par1 == this.blockID || par1 == Block.glass.blockID;
199 }
200
201 /**
202 * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops.
203 */
204 protected boolean canSilkHarvest()
205 {
206 return true;
207 }
208
209 /**
210 * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
211 * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
212 */
213 protected ItemStack createStackedBlock(int par1)
214 {
215 return new ItemStack(this.blockID, 1, par1);
216 }
217 }