@Override public @Nonnull EnumActionResult onItemUse(@Nonnull EntityPlayer player, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull EnumHand hand, @Nonnull EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack itemstack = player.getHeldItem(hand); if (CapturedMob.containsSoul(itemstack)) { return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } else { player.sendStatusMessage(Lang.STATUS_SPAWNER_UNBOUND.toChatServer(), true); return EnumActionResult.FAIL; } } });
public void placeBlock(ItemStorageCellPhysical storagePhysical, ItemStack itemstack, World world, EntityPlayer player, BlockPos pos, EnumFacing side, EnumHand hand, float xOffset, float yOffset, float zOffset) { storagePhysical.extractAEPower(player.getHeldItem(hand), 20.0D, Actionable.MODULATE); ItemBlock itemblock = (ItemBlock) itemstack.getItem(); BlockPos position = pos.offset(side.getOpposite()); itemblock.onItemUseFirst(player, world, position, side, xOffset, yOffset, zOffset, hand); itemblock.onItemUse(player, world, position, hand, side, xOffset, yOffset, zOffset); }
@Override public @Nonnull EnumActionResult onItemUse(@Nonnull EntityPlayer playerIn, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = playerIn.getHeldItem(hand); if (!playerIn.canPlayerEdit(pos.offset(side), side, stack)) { return EnumActionResult.FAIL; } else { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() == this.singleSlab) { BlockSlab.EnumBlockHalf blockslab$enumblockhalf = iblockstate.getValue(BlockSlab.HALF); if ((side == EnumFacing.UP && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.TOP)) { tryPlace(stack, worldIn, pos); return EnumActionResult.SUCCESS; } } return this.tryPlace(stack, worldIn, pos.offset(side)) ? EnumActionResult.SUCCESS : super.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ); } }
@Override public void useMode(ItemStorageCellPhysical storagePhysical, ItemStack itemStack, IAEItemStack storageStack, IAEItemStack request, World world, BlockPos pos, EntityPlayer player, EnumFacing side, EnumHand hand, float hitX, float hitY, float hitZ) { super.useMode(storagePhysical, itemStack, storageStack, request, world, pos, player, side, hand, hitX, hitY, hitZ); request.setStackSize(1); ItemBlock itemblock = (ItemBlock) itemStack.getItem(); itemblock.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand); itemblock.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ); storagePhysical.extractAEPower(player.getHeldItem(hand), 20.0D, Actionable.MODULATE); } },
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); BlockPos actualPos = pos.down(); if (facing != EnumFacing.DOWN || !player.canPlayerEdit(actualPos, facing, stack)) { return EnumActionResult.FAIL; } IBlockState stateInPlaced = world.getBlockState(actualPos); if (stateInPlaced.getMaterial() != Material.AIR) { return EnumActionResult.FAIL; } // Technically, this immediately gets set back to air. However the post-place logic will replace it in the // correct position. See BlockPendulumTorch for more information. return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); } }
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float coordX, float coordY, float coordZ) { ItemStack itemStack = player.getHeldItem(hand); Block block = world.getBlockState(blockPos).getBlock(); if(player.isSneaking()) { boolean done = false; int attempts = 0; while(attempts < ExcrementPileConfig.effectiveness) { done = ItemDye.applyBonemeal(itemStack.copy(), world, blockPos, player, hand) | done; attempts++; } if(done) { itemStack.shrink(1); if (!world.isRemote) { world.playBroadcastSound(2005, blockPos, 0); } return EnumActionResult.SUCCESS; } } else { if (block == ExcrementPile.getInstance() && !itemStack.isEmpty()) { if(ExcrementPile.getInstance().canHeightenPileAt(world, blockPos)) { ExcrementPile.getInstance().heightenPileAt(world, blockPos); itemStack.shrink(1); return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; } } return super.onItemUse(player, world, blockPos, hand, side, coordX, coordY, coordZ); }
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (stack.getCount() != 0 && player.canPlayerEdit(pos.offset(facing), facing, stack)) { IBlockState state = world.getBlockState(pos); if (state.getBlock() == this.singleSlab) { AncientSlabBlock.EnumBlockHalf half = state.getValue(BlockSlab.HALF); if ((facing == EnumFacing.UP && half == BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && half == BlockSlab.EnumBlockHalf.TOP)) { AxisAlignedBB collisionBox = state.getSelectedBoundingBox(world, pos); IBlockState doubleSlabState = this.doubleSlab.getDefaultState(); if (collisionBox != Block.NULL_AABB && world.checkNoEntityCollision(collisionBox.offset(pos)) && world.setBlockState(pos, doubleSlabState, 11)) { SoundType sound = this.doubleSlab.getSoundType(); world.playSound(player, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume() + 1.0F) / 2.0F, sound.getPitch() * 0.8F); stack.shrink(1); } return EnumActionResult.SUCCESS; } } return this.tryPlace(player, stack, world, pos.offset(facing)) ? EnumActionResult.SUCCESS : super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); } else { return EnumActionResult.FAIL; } }