@Override public void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer) { world.markBlockNeedsUpdate(i, j, k); TileEntityMissile titty = (TileEntityMissile) world.getBlockTileEntity(i, j, k); if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().getItem() instanceof ItemRangefinder) { titty.targetX = ItemRangefinder.ecks; titty.targetZ = ItemRangefinder.zee; } else { if ((int) Math.floor(entityplayer.posX) > i) { titty.targetX -= 5; } else if ((int) Math.floor(entityplayer.posX) < i) { titty.targetX += 5; } if ((int) Math.floor(entityplayer.posZ) > k) { titty.targetZ -= 5; } else if ((int) Math.floor(entityplayer.posZ) < k) { titty.targetZ += 5; } } String name; if (world.getBlockMetadata(i, j, k) == 12 || world.getBlockMetadata(i, j, k) == 0 || world.getBlockMetadata(i, j, k) == 15) { name = "Passenger rocket"; } else if (world.getBlockMetadata(i, j, k) == 8) { name = "Nuclear missile"; } else if (world.getBlockMetadata(i, j, k) == 4) { name = "Incendiary missile"; } else if (world.getBlockMetadata(i, j, k) == 13) { name = "Thermonuclear missile"; } else { name = "Missile"; } ModLoader.getMinecraftInstance() .ingameGUI .addChatMessage( name + " targeted at (" + titty.targetX + ", " + titty.targetZ + ") relative to current position."); }
@Override public boolean onBlockActivated( World world, int i, int j, int k, EntityPlayer entityplayer, int something1, float something2, float something3, float something4) { if (world.isRemote) { return true; } TileEntityCamoFull entity = (TileEntityCamoFull) world.getBlockTileEntity(i, j, k); System.out.println("ACTIVATED: " + entity.getCopyID()); int l = world.getBlockMetadata(i, j, k); int i1 = l & 7; int j1 = 8 - (l & 8); world.setBlockMetadataWithNotify(i, j, k, i1 + j1); world.markBlocksDirty(i, j, k, i, j, k); world.playSoundEffect( (double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, j1 <= 0 ? 0.5F : 0.6F); world.notifyBlocksOfNeighborChange(i, j, k, blockID); world.markBlockNeedsUpdate(i, j, k); if (i1 == 1) { world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID); } else if (i1 == 2) { world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID); } else if (i1 == 3) { world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID); } else if (i1 == 4) { world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID); } else { world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID); } return true; }
@Override public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int X, int Y, int Z, int side) { TileEntity te = world.getBlockTileEntity(X, Y, Z); if (te != null && te instanceof TileEntityIronChest) { TileEntityIronChest ironchest = (TileEntityIronChest) te; TileEntityIronChest newchest = ironchest.applyUpgradeItem(this); if (newchest == null) { return false; } world.setBlockTileEntity(X, Y, Z, newchest); world.setBlockMetadataWithNotify(X, Y, Z, newchest.getType().ordinal()); world.notifyBlocksOfNeighborChange(X, Y, Z, world.getBlockId(X, Y, Z)); world.markBlockNeedsUpdate(X, Y, Z); stack.stackSize = 0; return true; } else { return false; } }
@Override public boolean onBlockActivated( World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { // Drop through if the player is sneaking if (entityplayer.isSneaking()) return false; Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null; if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, i, j, k)) { int meta = world.getBlockMetadata(i, j, k); switch (ForgeDirection.values()[meta]) { case WEST: world.setBlockMetadata(i, j, k, ForgeDirection.SOUTH.ordinal()); break; case EAST: world.setBlockMetadata(i, j, k, ForgeDirection.NORTH.ordinal()); break; case NORTH: world.setBlockMetadata(i, j, k, ForgeDirection.WEST.ordinal()); break; case SOUTH: default: world.setBlockMetadata(i, j, k, ForgeDirection.EAST.ordinal()); break; } ((IToolWrench) equipped).wrenchUsed(entityplayer, i, j, k); world.markBlockNeedsUpdate(i, j, k); return true; } else { LiquidStack liquid = LiquidManager.getLiquidForFilledItem(entityplayer.getCurrentEquippedItem()); if (liquid != null) { int qty = ((TileRefinery) world.getBlockTileEntity(i, j, k)) .fill(ForgeDirection.UNKNOWN, liquid, true); if (qty != 0 && !BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) { entityplayer.inventory.setInventorySlotContents( entityplayer.inventory.currentItem, Utils.consumeItem(entityplayer.inventory.getCurrentItem())); } return true; } } if (!CoreProxy.proxy.isRenderWorld(world)) entityplayer.openGui(BuildCraftFactory.instance, GuiIds.REFINERY, world, i, j, k); return true; }
protected void setMetadata(World world, int x, int y, int z, int metadata) { if (doBlockNotify) world.setBlockMetadataWithNotify(x, y, z, metadata); else if (world.blockExists(x, y, z) && world.getChunkFromBlockCoords(x, z).field_50025_o) { if (world.setBlockMetadata(x, y, z, metadata)) world.markBlockNeedsUpdate(x, y, z); } else world.setBlockMetadata(x, y, z, metadata); }