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.Random; 006 import net.minecraftforge.common.ForgeDirection; 007 import static net.minecraftforge.common.ForgeDirection.*; 008 009 public class BlockLadder extends Block 010 { 011 protected BlockLadder(int par1, int par2) 012 { 013 super(par1, par2, Material.circuits); 014 this.setCreativeTab(CreativeTabs.tabDecorations); 015 } 016 017 /** 018 * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been 019 * cleared to be reused) 020 */ 021 public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) 022 { 023 int var5 = par1World.getBlockMetadata(par2, par3, par4); 024 float var6 = 0.125F; 025 026 if (var5 == 2) 027 { 028 this.setBlockBounds(0.0F, 0.0F, 1.0F - var6, 1.0F, 1.0F, 1.0F); 029 } 030 031 if (var5 == 3) 032 { 033 this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var6); 034 } 035 036 if (var5 == 4) 037 { 038 this.setBlockBounds(1.0F - var6, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); 039 } 040 041 if (var5 == 5) 042 { 043 this.setBlockBounds(0.0F, 0.0F, 0.0F, var6, 1.0F, 1.0F); 044 } 045 046 return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4); 047 } 048 049 @SideOnly(Side.CLIENT) 050 051 /** 052 * Returns the bounding box of the wired rectangular prism to render. 053 */ 054 public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4) 055 { 056 int var5 = par1World.getBlockMetadata(par2, par3, par4); 057 float var6 = 0.125F; 058 059 if (var5 == 2) 060 { 061 this.setBlockBounds(0.0F, 0.0F, 1.0F - var6, 1.0F, 1.0F, 1.0F); 062 } 063 064 if (var5 == 3) 065 { 066 this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var6); 067 } 068 069 if (var5 == 4) 070 { 071 this.setBlockBounds(1.0F - var6, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); 072 } 073 074 if (var5 == 5) 075 { 076 this.setBlockBounds(0.0F, 0.0F, 0.0F, var6, 1.0F, 1.0F); 077 } 078 079 return super.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4); 080 } 081 082 /** 083 * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two 084 * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. 085 */ 086 public boolean isOpaqueCube() 087 { 088 return false; 089 } 090 091 /** 092 * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) 093 */ 094 public boolean renderAsNormalBlock() 095 { 096 return false; 097 } 098 099 /** 100 * The type of render function that is called for this block 101 */ 102 public int getRenderType() 103 { 104 return 8; 105 } 106 107 /** 108 * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z 109 */ 110 public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) 111 { 112 return par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST ) || 113 par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST ) || 114 par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH) || 115 par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH); 116 } 117 118 /** 119 * called before onBlockPlacedBy by ItemBlock and ItemReed 120 */ 121 public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8) 122 { 123 int var9 = par1World.getBlockMetadata(par2, par3, par4); 124 125 if ((var9 == 0 || par5 == 2) && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH)) 126 { 127 var9 = 2; 128 } 129 130 if ((var9 == 0 || par5 == 3) && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)) 131 { 132 var9 = 3; 133 } 134 135 if ((var9 == 0 || par5 == 4) && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST)) 136 { 137 var9 = 4; 138 } 139 140 if ((var9 == 0 || par5 == 5) && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST)) 141 { 142 var9 = 5; 143 } 144 145 par1World.setBlockMetadataWithNotify(par2, par3, par4, var9); 146 } 147 148 /** 149 * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are 150 * their own) Args: x, y, z, neighbor blockID 151 */ 152 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) 153 { 154 int var6 = par1World.getBlockMetadata(par2, par3, par4); 155 boolean var7 = false; 156 157 if (var6 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH)) 158 { 159 var7 = true; 160 } 161 162 if (var6 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)) 163 { 164 var7 = true; 165 } 166 167 if (var6 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST)) 168 { 169 var7 = true; 170 } 171 172 if (var6 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST)) 173 { 174 var7 = true; 175 } 176 177 if (!var7) 178 { 179 this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0); 180 par1World.setBlockWithNotify(par2, par3, par4, 0); 181 } 182 183 super.onNeighborBlockChange(par1World, par2, par3, par4, par5); 184 } 185 186 /** 187 * Returns the quantity of items to drop on block destruction. 188 */ 189 public int quantityDropped(Random par1Random) 190 { 191 return 1; 192 } 193 194 @Override 195 public boolean isLadder(World world, int x, int y, int z) 196 { 197 return true; 198 } 199 }