@SubscribeEvent public void onPlayerInteract0(PlayerInteractEvent event) { if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { World world = event.world; EntityPlayer player = event.entityPlayer; int x = event.x; int y = event.y; int z = event.z; if (world == null || world.isRemote) return; if (player.isSneaking()) return; if (EtFuturum.enableEnchants) { TileEntityEnchantmentTable tile = Utils.getTileEntity(world, x, y, z, TileEntityEnchantmentTable.class); if (tile != null && world.getBlock(x, y, z) == Blocks.enchanting_table) { player.openGui(EtFuturum.instance, GUIsID.ENCHANTING_TABLE, world, x, y, z); event.setCanceled(true); return; } } if (EtFuturum.enableAnvil) if (world.getBlock(x, y, z) == Blocks.anvil) { player.openGui(EtFuturum.instance, GUIsID.ANVIL, world, x, y, z); event.setCanceled(true); return; } } }
@SubscribeEvent(priority = EventPriority.LOW) public void playerInteract(PlayerInteractEvent event) { if (event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote) { if (placing.get() != null) return; // for mods that do dumb stuff and call this event like MFR placing.set(event); if (place(event.entityPlayer, event.entityPlayer.worldObj)) event.setCanceled(true); placing.set(null); } }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void buildWorktables(PlayerInteractEvent evt) { if (evt.action == Action.RIGHT_CLICK_BLOCK) { Block b = evt.world.getBlock(evt.x, evt.y, evt.z); if (b == Blocks.crafting_table || b instanceof BlockWorkbench || TinkerToolHandler.getInstance().isWorkbench(b)) { if (this.checkAndBuildWorktable(evt.world, evt.x, evt.y, evt.z)) evt.setCanceled(true); } } }
@SubscribeEvent public void onChocopediaRightClick(PlayerInteractEvent event) { if (event.action == Action.RIGHT_CLICK_AIR) { if (event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entity; ItemStack currentItem = player.getCurrentEquippedItem(); if (currentItem != null) { if (currentItem.getItem().equals(ChocoCraftItems.chocopediaItem)) { GuiStarter.startChocopediaGui(null); if (event.isCancelable()) { event.setCanceled(true); } } } } } }
@SubscribeEvent public void onBlockClick(PlayerInteractEvent e) { if (!e.world.isRemote) { if (e.action == Action.RIGHT_CLICK_BLOCK && CmdDumpBlockData.getWaitForBlockClick(e.entityPlayer.getUniqueID())) { StringBuilder sb = new StringBuilder(); Block blc = e.world.getBlock(e.x, e.y, e.z); if (blc == null) { return; } int meta = e.world.getBlockMetadata(e.x, e.y, e.z); sb.append( "BlockID: " + GameData.getBlockRegistry().getNameForObject(blc) + "(" + GameData.getBlockRegistry().getIDForObject(blc) + ")\n"); sb.append( "Block name: " + blc.getUnlocalizedName() + " = " + blc.getLocalizedName() + "\n"); sb.append("XYZ: " + e.x + " " + e.y + " " + e.z + "\n"); sb.append("Metadata: " + meta + "\n"); sb.append( "Lightlevel: " + "block: " + e.world.getSavedLightValue(EnumSkyBlock.Block, e.x, e.y, e.z) + ", sky: " + e.world.getSavedLightValue(EnumSkyBlock.Sky, e.x, e.y, e.z) + "\n"); if (blc.hasTileEntity(meta)) { TileEntity te = e.world.getTileEntity(e.x, e.y, e.z); if (te != null) { NBTTagCompound nbt = new NBTTagCompound(); te.writeToNBT(nbt); sb.append("NBT: {" + CmdDumpItemData.getNBTString(nbt, 1) + "}"); } } System.out.println("\n" + sb.toString()); e.setCanceled(true); } } }
@SubscribeEvent public void interactEvent(PlayerInteractEvent event) { IPokemob pokemob = proxy.getPokemob(event.entityPlayer); if (pokemob == null) return; EntityPlayer player = event.entityPlayer; if (event.entityPlayer.getHeldItem() != null && event.entityPlayer.isSneaking() && event.entityPlayer.getHeldItem().getItem() instanceof ItemPokedex) { pokemob.getPokemobInventory().func_110134_a((IInvBasic) pokemob); if (!event.world.isRemote) { event.setCanceled(true); event.entityPlayer.openGui( PokePlayer.INSTANCE, Proxy.POKEMOBGUI, event.entityPlayer.worldObj, 0, 0, 0); } } else if (event.action == Action.RIGHT_CLICK_AIR && event.entityPlayer.getHeldItem() != null) { ((Entity) pokemob).interactFirst(player); proxy.getMap().get(event.entityPlayer.getUniqueID()).save(player); } }
@SubscribeEvent public void handleCropRightClick(PlayerInteractEvent event) { int x = event.x, y = event.y, z = event.z; Block block = event.world.getBlock(x, y, z); int meta = event.world.getBlockMetadata(x, y, z); if (ConfigHandler.allowCropRC && event.action == Action.RIGHT_CLICK_BLOCK && (event.entityPlayer.getHeldItem() == null || !event.entityPlayer.isSneaking())) { for (PlantInfo info : plants) { if (info.blockInst == block && meta == info.meta) { if (event.world.isRemote) { event.entityPlayer.swingItem(); } else { currentPlant = info; block.dropBlockAsItem(event.world, x, y, z, meta, 0); currentPlant = null; event.world.setBlockMetadataWithNotify(x, y, z, info.resetMeta, 3); event.setCanceled(true); } break; } } } }