@Override protected boolean processInteract(EntityPlayer player, EnumHand hand) { if(!player.isSneaking()) { player.startRiding(this); return true; } return false; }
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); }
/** * Rotates the render for a bauble correctly if the player is sneaking. * Use for renders under {@link RenderType#BODY}. */ public static void rotateIfSneaking(EntityPlayer player) { if(player.isSneaking()) applySneakingRotation(); }
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) { return player.isSneaking() ? super.onItemUse(player, world, pos, hand, side, sx, sy, sz) : EnumActionResult.PASS; }
@Override public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) { if(!world.isRemote) { TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(pos); cube.doRequest(player.isSneaking()); } }
public boolean onWanded(EntityPlayer player) { if(player != null) { if(camoState == null || player.isSneaking()) swapSelfAndPass(this, true); else swapSurroudings(this, false); return true; } return false; }
@Override public boolean onWanded(EntityPlayer player, ItemStack wand) { if(player == null) return false; if(player.isSneaking()) { filterType = filterType == 2 ? 0 : filterType + 1; sync(); return true; } else return super.onWanded(player, wand); }
@Override public ActionResult<ItemStack> onItemRightClick( World w, EntityPlayer player, EnumHand hand ) { if( player.isSneaking() ) { if( !w.isRemote ) { this.clearCard( player, w, hand ); } } return super.onItemRightClick( w, player, hand ); }
@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 TileGrinder tg = this.getTileEntity( w, pos ); if( tg != null && !p.isSneaking() ) { Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_GRINDER ); return true; } return false; } }
@Override public boolean onWanded(EntityPlayer player, ItemStack wand) { if(player == null) return false; if(player.isSneaking()) { if(!player.world.isRemote) { orientation = orientation.rotateY(); sync(); } return true; } else return super.onWanded(player, wand); }
@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 EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) { if(player.isSneaking() && !world.isRemote) { TileEntity tile = world.getTileEntity(pos); if(tile != null && tile instanceof IManaPool) { bindPool(player.getHeldItem(hand), tile); world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.ding, SoundCategory.PLAYERS, 1F, 1F); return EnumActionResult.SUCCESS; } } return EnumActionResult.PASS; }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if(getBlock(stack) != null && player.isSneaking()) { int dmg = stack.getItemDamage(); stack.setItemDamage(~dmg & 1); player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.3F, 0.1F); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } return ActionResult.newResult(EnumActionResult.PASS, stack); }
@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 boolean onBlockActivated( final World w, final BlockPos pos, final IBlockState state, final EntityPlayer p, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) { final TileMolecularAssembler tg = this.getTileEntity( w, pos ); if( tg != null && !p.isSneaking() ) { Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_MAC ); return true; } return super.onBlockActivated( w, pos, state, p, hand, side, hitX, hitY, hitZ ); } }
/** * Shifts the render for a bauble correctly to the head, including sneaking rotation. * Use for renders under {@link RenderType#HEAD}. */ public static void translateToHeadLevel(EntityPlayer player) { GlStateManager.translate(0, -player.getDefaultEyeHeight(), 0); if (player.isSneaking()) GlStateManager.translate(0.25F * MathHelper.sin(player.rotationPitch * (float) Math.PI / 180), 0.25F * MathHelper.cos(player.rotationPitch * (float) Math.PI / 180), 0F); }
@Override public boolean onBlockActivated( final World w, final BlockPos pos, final IBlockState state, final EntityPlayer player, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) { final TileWireless tg = this.getTileEntity( w, pos ); if( tg != null && !player.isSneaking() ) { if( Platform.isServer() ) { Platform.openGUI( player, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_WIRELESS ); } return true; } return super.onBlockActivated( w, pos, state, player, hand, side, hitX, hitY, hitZ ); }
@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 ) ); }
@Override public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, BlockPos pos, EnumFacing side) { if(player == null || world.isRemote) return false; if(!player.isSneaking()) { playerPositions.put(player.getUniqueID(), new DimWithPos(world.provider.getDimension(), pos)); world.playSound(null, pos, ModSounds.ding, SoundCategory.BLOCKS, 0.5F, 1F); } else { spawnAsEntity(world, pos, new ItemStack(this)); world.setBlockToAir(pos); world.playEvent(2001, pos, Block.getStateId(getDefaultState())); } return true; }
@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())); } } }