@Override /** Cycle backwards through types. */ protected boolean onHammerRightClick(TEBase TE, EntityPlayer entityPlayer) { int temp = data.getType(TE); if (--temp < 0) { temp = type.length - 1; } data.setType(TE, temp); return true; }
@Override /** Cycle forwards through types. */ protected boolean onHammerLeftClick(TEBase TE, EntityPlayer entityPlayer) { int temp = data.getType(TE); if (++temp > type.length - 1) { temp = 0; } data.setType(TE, temp); return true; }
@Override public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { if (Arrays.asList(getRotationAxes()).contains(axis)) { TEBase TE = getTileEntity(world, x, y, z); if (TE != null && data.isFreestanding(TE)) { int side = data.getDirection(TE).ordinal() == data.DIR_ON_X ? data.DIR_ON_Z : data.DIR_ON_X; return data.setDirection(TE, ForgeDirection.getOrientation(side)); } } return super.rotateBlock(world, x, y, z, axis); }
@Override /** Called when the block is placed in the world. */ public void onBlockPlacedBy( World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) { super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack); if (!entityLiving.isSneaking()) { // Copy type and direction of adjacent ladder type for (int side = 0; side < 2; ++side) { TEBase TE = getTileEntity(world, x, y, z); ForgeDirection dir = ForgeDirection.getOrientation(side); if (world.getBlock(x, y - dir.offsetY, z).equals(this)) { TEBase TE_adj = (TEBase) world.getTileEntity(x, y - dir.offsetY, z); data.setType(TE, data.getType(TE_adj)); data.setDirection(TE, data.getDirection(TE_adj)); } } } }
@Override /** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed * (coordinates passed are their own) Args: x, y, z, neighbor blockID */ public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { if (!world.isRemote) { TEBase TE = getTileEntity(world, x, y, z); if (TE != null && !data.isFreestanding(TE)) { super.onNeighborBlockChange(world, x, y, z, block); } } }
@Override /** Updates the blocks bounds based on its current state. Args: world, x, y, z */ public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) { TEBase TE = getTileEntity(blockAccess, x, y, z); if (TE != null) { ForgeDirection dir = data.getDirection(TE); switch (dir) { case DOWN: // DIR_ON_X setBlockBounds(0.0F, 0.0F, 0.375F, 1.0F, 1.0F, 0.625F); break; case UP: // DIR_ON_Z setBlockBounds(0.375F, 0.0F, 0.0F, 0.625F, 1.0F, 1.0F); break; default: setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.1875F, dir); } } }