Source:
<code>public static boolean onPickBlock(RayTraceResult target, EntityPlayer player, World world) { ItemStack result; boolean isCreative = player.capabilities.isCreativeMode; TileEntity te = null; if (target.typeOfHit == RayTraceResult.Type.BLOCK) { IBlockState state = world.getBlockState(target.getBlockPos()); if (state.getBlock().isAir(state, world, target.getBlockPos())) { return false; } if (isCreative && GuiScreen.isCtrlKeyDown() && state.getBlock().hasTileEntity(state)) te = world.getTileEntity(target.getBlockPos()); result = state.getBlock().getPickBlock(state, target, world, target.getBlockPos(), player); } else { if (target.typeOfHit != RayTraceResult.Type.ENTITY || target.entityHit == null || !isCreative) { return false; } result = target.entityHit.getPickedResult(target); } PlayerInteractEvent.Pick pickEvent = new PlayerInteractEvent.Pick(player, target, result); MinecraftForge.EVENT_BUS.post(pickEvent); <START> if(pickEvent.isCanceled()) { <END> return false; } result = pickEvent.getCurrentResult(); if (result.isEmpty()) { return false; } if (te != null) { Minecraft.getMinecraft().storeTEInStack(result, te); } if (isCreative) { player.inventory.setPickedItemStack(result); Minecraft.getMinecraft().playerController.sendSlotPacket(player.getHeldItem(EnumHand.MAIN_HAND), 36 + player.inventory.currentItem); return true; } int slot = player.inventory.getSlotFor(result); if (slot != -1) { if (InventoryPlayer.isHotbar(slot)) player.inventory.currentItem = slot; else Minecraft.getMinecraft().playerController.pickItem(slot); return true; } return false; }</code><technical_language>Forge code style, this java if (pickEvent.isCanceled()) {</technical_language>

Target:
public static boolean onPickBlock(RayTraceResult target, EntityPlayer player, World world) { ItemStack result; boolean isCreative = player.capabilities.isCreativeMode; TileEntity te = null; if (target.typeOfHit == RayTraceResult.Type.BLOCK) { IBlockState state = world.getBlockState(target.getBlockPos()); if (state.getBlock().isAir(state, world, target.getBlockPos())) { return false; } if (isCreative && GuiScreen.isCtrlKeyDown() && state.getBlock().hasTileEntity(state)) te = world.getTileEntity(target.getBlockPos()); result = state.getBlock().getPickBlock(state, target, world, target.getBlockPos(), player); } else { if (target.typeOfHit != RayTraceResult.Type.ENTITY || target.entityHit == null || !isCreative) { return false; } result = target.entityHit.getPickedResult(target); } PlayerInteractEvent.Pick pickEvent = new PlayerInteractEvent.Pick(player, target, result); MinecraftForge.EVENT_BUS.post(pickEvent); result = pickEvent.isCanceled() ? ItemStack.EMPTY : pickEvent.getResultStack(); if (result.isEmpty()) { return false; } if (te != null) { Minecraft.getMinecraft().storeTEInStack(result, te); } if (isCreative) { player.inventory.setPickedItemStack(result); Minecraft.getMinecraft().playerController.sendSlotPacket(player.getHeldItem(EnumHand.MAIN_HAND), 36 + player.inventory.currentItem); return true; } int slot = player.inventory.getSlotFor(result); if (slot != -1) { if (InventoryPlayer.isHotbar(slot)) player.inventory.currentItem = slot; else Minecraft.getMinecraft().playerController.pickItem(slot); return true; } return false; }