@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (world.isRemote) return ActionResult.newResult(EnumActionResult.FAIL, stack); RayTraceResult position = this.rayTrace(world, player, false); if (position == null) { return super.onItemRightClick(world, player, EnumHand.MAIN_HAND); } else { if (position.typeOfHit == RayTraceResult.Type.BLOCK) { TileEntity tile = world.getTileEntity(position.getBlockPos()); if (!(tile instanceof IBloodAltar)) return super.onItemRightClick(world, player, EnumHand.MAIN_HAND); LPContainer.tryAndFillAltar((IBloodAltar) tile, stack, world, position.getBlockPos()); } } return ActionResult.newResult(EnumActionResult.FAIL, stack); }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (world.isRemote) return ActionResult.newResult(EnumActionResult.FAIL, stack); RayTraceResult rayTrace = this.rayTrace(world, player, false); if (rayTrace == null) { return super.onItemRightClick(world, player, EnumHand.MAIN_HAND); } else { if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) { TileEntity tile = world.getTileEntity(rayTrace.getBlockPos()); if (!(tile instanceof IBloodAltar)) return super.onItemRightClick(world, player, EnumHand.MAIN_HAND); LPContainer.tryAndFillAltar((IBloodAltar) tile, stack, world, rayTrace.getBlockPos()); } } return ActionResult.newResult(EnumActionResult.FAIL, stack); }
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { ItemStack itemStackIn = playerIn.getHeldItem(hand); ItemStack existingStack = playerIn.getItemStackFromSlot(armorType); if (existingStack.isEmpty()) { playerIn.setItemStackToSlot(armorType, itemStackIn.copy()); itemStackIn.shrink(1); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn); } return super.onItemRightClick(worldIn, playerIn, hand); } }
@Override @Nonnull public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { // Check if the entity we've just hit has a stack in the first slot. If so, use that instead. ItemStack stack = player.getHeldItem(hand); RayTraceResult hit = PlayerHelpers.findHitGuess(player); Entity entity = hit.entityHit; if (hit.typeOfHit == RayTraceResult.Type.ENTITY && !(entity instanceof EntityPlayer) && entity instanceof EntityLivingBase) { if (((EntityLivingBase) entity).getItemStackFromSlot(NeuralHelpers.ARMOR_SLOT).isEmpty() && stack.getCount() == 1) { return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } if (LoadedCache.hasBaubles()) { IBaublesItemHandler handler = BaublesApi.getBaublesHandler(player); for (int slot : NeuralHelpers.getBaubleType().getValidSlots()) { if (handler.getStackInSlot(slot).isEmpty()) { if (!world.isRemote) { handler.setStackInSlot(slot, stack.copy()); if (!player.capabilities.isCreativeMode) stack.grow(-1); } return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } } return super.onItemRightClick(world, player, hand); }