@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand) { ItemStack stack = playerIn.getHeldItem(hand); if(playerIn.isSneaking()) { int size = getSize(stack); int newSize = size == 11 ? 3 : size + 2; setSize(stack, newSize); ItemsRemainingRenderHandler.set(stack, newSize + "x" + newSize); worldIn.playSound(playerIn, playerIn.getPosition(), SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.5F, 1F); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } return ActionResult.newResult(EnumActionResult.PASS, stack); }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { player.openGui(Botania.instance, LibGuiIDs.BAUBLE_BOX, world, hand == EnumHand.OFF_HAND ? 1 : 0, 0, 0); return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand)); }
@Override public boolean canInteractWith(@Nonnull EntityPlayer player) { return player.getHeldItemMainhand() == baubleBoxInv.box || player.getHeldItemOffhand() == baubleBoxInv.box; }
@Override protected boolean processInteract(EntityPlayer player, EnumHand hand) { if(!player.isSneaking()) { player.startRiding(this); return true; } return false; }
@Override public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer p, final EnumHand hand ) { if( p.isSneaking() ) { this.encode( p.getHeldItem( hand ), p ); p.swingArm( hand ); return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) ); } return new ActionResult<>( EnumActionResult.PASS, p.getHeldItem( hand ) ); }
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) { ItemStack stack = player.getHeldItem(hand); Block block = world.getBlockState(pos).getBlock(); BlockPos boundPos = getBoundTile(stack); TileEntity boundTile = world.getTileEntity(boundPos); if(player.isSneaking()) { if(player.canPlayerEdit(pos, side, stack) && (!(block instanceof BlockCommandBlock) || player.canUseCommandBlock()) && block.rotateBlock(world, pos, side)) { player.swingArm(hand); return EnumActionResult.SUCCESS; if(getBindMode(stack) && bindable && player.isSneaking() && ((IWandBindable) tile).canSelect(player, stack, pos, side)) { if(boundPos.equals(pos)) setBoundTile(stack, UNBOUND_POS); player.swingArm(hand); player.playSound(ModSounds.ding, 0.11F, 1F); wanded = ((IWandable) block).onUsedByWand(player, stack, world, pos, side); if(wanded && world.isRemote) player.swingArm(hand); if(!world.isRemote && ((BlockPistonRelay) ModBlocks.pistonRelay).playerPositions.containsKey(player.getUniqueID())) { BlockPistonRelay.DimWithPos bindPos = ((BlockPistonRelay) ModBlocks.pistonRelay).playerPositions.get(player.getUniqueID()); BlockPistonRelay.DimWithPos currentPos = new BlockPistonRelay.DimWithPos(world.provider.getDimension(), pos);
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); String force = getForcedPage(stack); if(force != null && !force.isEmpty()) { LexiconEntry entry = getEntryFromForce(stack); if(entry != null) Botania.proxy.setEntryToOpen(entry); else player.sendMessage(new TextComponentTranslation("botaniamisc.cantOpen").setStyle(new Style().setColor(TextFormatting.RED))); setForcedPage(stack, ""); } openBook(player, stack, world, skipSound); skipSound = false; return ActionResult.newResult(EnumActionResult.SUCCESS, stack); }
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) { ItemStack stack = player.getHeldItem(hand); if(ManaItemHandler.requestManaExactForTool(stack, player, COST, false) && !world.provider.doesWaterVaporize()) { // Adapted from bucket code RayTraceResult mop = rayTrace(world, player, false); if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos hitPos = mop.getBlockPos(); if(!world.isBlockModifiable(player, hitPos)) return EnumActionResult.FAIL; BlockPos placePos = hitPos.offset(mop.sideHit); if(player.canPlayerEdit(placePos, mop.sideHit, stack)) { if (ManaItemHandler.requestManaExactForTool(stack, player, COST, true) && ((ItemBucket) Items.WATER_BUCKET).tryPlaceContainedLiquid(player, world, placePos)) { for(int i = 0; i < 6; i++) Botania.proxy.sparkleFX(pos.getX() + side.getXOffset() + Math.random(), pos.getY() + side.getYOffset() + Math.random(), pos.getZ() + side.getZOffset() + Math.random(), 0.2F, 0.2F, 1F, 1F, 5); return EnumActionResult.SUCCESS; } } } return EnumActionResult.FAIL; } return EnumActionResult.PASS; }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if(player.isSneaking()) { if(!world.isRemote) setBindMode(stack, !getBindMode(stack)); else player.playSound(ModSounds.ding, 0.1F, 1F); } return ActionResult.newResult(EnumActionResult.SUCCESS, stack); }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { player.setActiveHand(hand); return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand)); }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (!world.isRemote) { if (player.isSneaking()) { return new ActionResult<>(EnumActionResult.SUCCESS, new ItemStack(RSItems.FILTER)); } player.openGui(RS.INSTANCE, RSGui.FILTER, world, hand.ordinal(), 0, 0); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } return new ActionResult<>(EnumActionResult.PASS, stack); }
p.openGui( AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), p.inventory.currentItem, 0, 0 ); p.openGui( AppEng.instance(), type.ordinal() << 4 | ( 1 << 3 ), p.getEntityWorld(), x, y, z ); p.openGui( AppEng.instance(), type.ordinal() << 4 | ( side.ordinal() ), tile.getWorld(), x, y, z );
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if(hand == EnumHand.MAIN_HAND && playerIn.isSneaking() && playerIn.getHeldItem(hand).isEmpty()) { ((TileAnimatedTorch) worldIn.getTileEntity(pos)).handRotate(); return true; } return false; }
@Override public void onKeyPressed(ItemStack stack, EntityPlayer player, KeyBindings key, boolean showInChat) { if (stack == player.getHeldItemMainhand() && stack.getItem() instanceof ItemSigilHolding && key.equals(KeyBindings.OPEN_HOLDING)) { Utils.setUUID(stack); player.openGui(BloodMagic.instance, Constants.Gui.SIGIL_HOLDING_GUI, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ); } }
public void onWanded(EntityPlayer player, ItemStack wand) { if(player == null) return; if(player.isSneaking()) backwards = !backwards; else speed = speed == 6 ? 1 : speed + 1; VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); }
@Override protected boolean openGui(EntityPlayer player, World world, BlockPos pos) { player.openGui(TConstruct.instance, 0, world, pos.getX(), pos.getY(), pos.getZ()); return true; } }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { RayTraceResult rtr = rayTrace(world, player, true); ItemStack stack = player.getHeldItem(hand); if(rtr == null) return ActionResult.newResult(EnumActionResult.PASS, stack); else { if(rtr.typeOfHit == net.minecraft.util.math.RayTraceResult.Type.BLOCK) { BlockPos pos = rtr.getBlockPos(); if(!world.isBlockModifiable(player, pos)) return ActionResult.newResult(EnumActionResult.PASS, stack); if(!player.canPlayerEdit(pos, rtr.sideHit, stack)) return ActionResult.newResult(EnumActionResult.PASS, stack); IBlockState state = world.getBlockState(pos); Fluid fluid = FluidRegistry.lookupFluidForBlock(state.getBlock()); boolean isFull = state.getBlock() instanceof BlockLiquid && state.getValue(BlockLiquid.LEVEL) == 0 || state.getBlock() instanceof IFluidBlock && Math.abs(((IFluidBlock) state.getBlock()).getFilledPercentage(world, pos)) >= 1; if(fluid != null && isFull) { player.playSound(fluid.getFillSound(world, pos), 1.0f, 1.0f); world.setBlockToAir(pos); for(int x = 0; x < 5; x++) world.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } return ActionResult.newResult(EnumActionResult.PASS, stack); } }
@SubscribeEvent public void onHarvestDrops(HarvestDropsEvent event) { if(event.getHarvester() != null) { ItemStack stack = event.getHarvester().getHeldItemMainhand(); if(!stack.isEmpty() && (stack.getItem() == this || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) { event.getDrops().removeIf(s -> !s.isEmpty() && (isDisposable(s) || isSemiDisposable(s) && !event.getHarvester().isSneaking())); } } }
@Override public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) { final TileChest tg = this.getTileEntity( w, pos ); if( tg != null && !p.isSneaking() ) { if( Platform.isClient() ) { return true; } if( side != tg.getUp() ) { Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CHEST ); } else { if( !tg.openGui( p ) ) { p.sendMessage( PlayerMessages.ChestCannotReadStorageCell.get() ); } } return true; } return false; } }
private ItemStack getAmmo(EntityPlayer player) { if(isArrow(player.getHeldItem(EnumHand.OFF_HAND))) return player.getHeldItem(EnumHand.OFF_HAND); else if(isArrow(player.getHeldItem(EnumHand.MAIN_HAND))) return player.getHeldItem(EnumHand.MAIN_HAND); else for(int i = 0; i < player.inventory.getSizeInventory(); ++i) { ItemStack itemstack = player.inventory.getStackInSlot(i); if (isArrow(itemstack)) return itemstack; } return ItemStack.EMPTY; }