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