/** * Sets the block's orientation based upon the direction the player is looking when the block is * placed. */ @Override @SuppressWarnings("unchecked") public void onBlockPlacedBy( World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { TileEntity te = world.getTileEntity(x, y, z); if (te != null && te instanceof TileEntityAgricraft) { TileEntityAgricraft tile = (TileEntityAgricraft) world.getTileEntity(x, y, z); if (tile.isRotatable()) { int direction = MathHelper.floor_double(entity.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; switch (direction) { case 0: tile.setOrientation(ForgeDirection.NORTH); break; case 1: tile.setOrientation(ForgeDirection.EAST); break; case 2: tile.setOrientation(ForgeDirection.SOUTH); break; case 3: tile.setOrientation(ForgeDirection.WEST); break; } } if (this.isMultiBlock() && !world.isRemote) { IMultiBlockComponent component = (IMultiBlockComponent) world.getTileEntity(x, y, z); component.getMultiBlockManager().onBlockPlaced(world, x, y, z, component); } } }
@Override @SuppressWarnings("unchecked") public void breakBlock(World world, int x, int y, int z, Block b, int meta) { if (this.isMultiBlock() && !world.isRemote) { IMultiBlockComponent component = (IMultiBlockComponent) world.getTileEntity(x, y, z); if (component != null) { component.getMultiBlockManager().onBlockBroken(world, x, y, z, component); } } super.breakBlock(world, x, y, z, b, meta); world.removeTileEntity(x, y, z); }