@Override public boolean itemInteractionForEntity( ItemStack is, final EntityPlayer player, final EntityLivingBase target, final EnumHand hand ) { if( target instanceof EntityPlayer && !player.isSneaking() ) { if( player.capabilities.isCreativeMode ) { is = player.getHeldItem( hand ); } this.encode( is, (EntityPlayer) target ); player.swingArm( hand ); return true; } return false; }
@Override public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer p, final EnumHand hand ) { if( Platform.isServer() ) { Platform.openGUI( p, null, AEPartLocation.INTERNAL, GuiBridge.GUI_QUARTZ_KNIFE ); } p.swingArm( hand ); return new ActionResult<>( EnumActionResult.SUCCESS, p.getHeldItem( hand ) ); }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer p, @Nonnull EnumHand hand) { ItemStack stack = p.getHeldItem(hand); if(ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) { if(world.isRemote) { int range = IManaProficiencyArmor.Helper.hasProficiency(p, stack) ? 20 : 15; long seedxor = world.rand.nextLong(); doHighlight(world, new BlockPos(p), range, seedxor); p.swingArm(hand); } else world.playSound(null, p.posX, p.posY, p.posZ, ModSounds.divinationRod, SoundCategory.PLAYERS, 1F, 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) { ItemStack stack = player.getHeldItem(hand); if(stack.getItemDamage() == 15) { if(!player.capabilities.isCreativeMode) stack.shrink(1); world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if(!world.isRemote) { EntityEnderAirBottle b = new EntityEnderAirBottle(world, player); b.shoot(player, player.rotationPitch, player.rotationYaw, 0F, 1.5F, 1F); world.spawnEntity(b); } else player.swingArm(hand); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } return ActionResult.newResult(EnumActionResult.PASS, stack); }
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if(player.isSneaking()) { if(world.isRemote) { player.swingArm(hand); for(int i = 0; i < 10; i++) { float x1 = (float) (pos.getX() + Math.random()); float y1 = pos.getY() + 1; float z1 = (float) (pos.getZ() + Math.random()); Botania.proxy.wispFX(x1, y1, z1, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, -0.05F + (float) Math.random() * 0.05F); } } else { ItemStack stack = player.getHeldItem(hand); ItemNBTHelper.setInt(stack, TAG_X, pos.getX()); ItemNBTHelper.setInt(stack, TAG_Y, pos.getY()); ItemNBTHelper.setInt(stack, TAG_Z, pos.getZ()); ItemNBTHelper.setInt(stack, TAG_DIMENSION, world.provider.getDimension()); world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1F, 5F); } return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }
@Override public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) { if(entity instanceof EntityLiving) { EntityLiving living = (EntityLiving) entity; SoundEvent sound = null; if(living instanceof EntityCreeper) sound = SoundEvents.ENTITY_CREEPER_PRIMED; else if(living instanceof EntitySlime) sound = ((EntitySlime) living).isSmallSlime() ? SoundEvents.ENTITY_SMALL_SLIME_SQUISH : SoundEvents.ENTITY_SLIME_SQUISH; else { try { sound = (SoundEvent) ReflectionHelper.findMethod(EntityLiving.class, LibObfuscation.GET_LIVING_SOUND[0], LibObfuscation.GET_LIVING_SOUND[1]).invoke(living); } catch (InvocationTargetException | IllegalAccessException ignored) { Botania.LOGGER.debug("Couldn't get living sound"); } } if(sound != null) { String s = EntityList.getEntityString(entity); if(s == null) s = "generic"; ItemNBTHelper.setString(stack, TAG_SOUND, sound.getRegistryName().toString()); ItemNBTHelper.setString(stack, TAG_SOUND_NAME, "entity." + s + ".name"); player.setHeldItem(hand, stack); if(player.world.isRemote) player.swingArm(hand); 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 ) ); }
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.PLAYERS, 0.6F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); if(world.isRemote) player.swingArm(hand); ItemStack lens = getLens(stack); ItemsRemainingRenderHandler.set(lens, -2); UseItemSuccessTrigger.INSTANCE.trigger((EntityPlayerMP) player, stack, (WorldServer) world, player.posX, player.posY, player.posZ); } else { player.swingArm(hand); player.motionX -= burst.motionX * 0.1; player.motionY -= burst.motionY * 0.3;
public static void onInteract(EntityPlayer player, World world, BlockPos pos, EnumHand hand) { if(world.isRemote) return; List<TileRedStringInterceptor> remove = new ArrayList<>(); boolean did = false; for(TileRedStringInterceptor inter : interceptors) { if(!inter.saneState()) { remove.add(inter); continue; } if(inter.world == world) { BlockPos coords = inter.getBinding(); if(coords != null && coords.equals(pos)) { Block block = inter.getBlockType(); world.setBlockState(inter.getPos(), world.getBlockState(inter.getPos()).withProperty(BotaniaStateProps.POWERED, true), 1 | 2); world.scheduleUpdate(inter.getPos(), block, block.tickRate(world)); did = true; } } } interceptors.removeAll(remove); if(did) { player.swingArm(hand); world.playSound(null, pos, SoundEvents.BLOCK_DISPENSER_DISPENSE, SoundCategory.BLOCKS, 0.3F, 0.6F); } }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) { Vector3 playerVec = Vector3.fromEntityCenter(player); Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3); Vector3 placeVec = playerVec.add(lookVec); int x = MathHelper.floor(placeVec.x); int y = MathHelper.floor(placeVec.y) + 1; int z = MathHelper.floor(placeVec.z); int entities = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1)).size(); if(entities == 0) { ItemStack stackToPlace = new ItemStack(Blocks.DIRT); player.setHeldItem(hand, stackToPlace); stackToPlace.onItemUse(player, world, new BlockPos(x, y, z), hand, EnumFacing.DOWN, 0F, 0F, 0F); player.setHeldItem(hand, stack); if(stackToPlace.isEmpty()) { ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true); for(int i = 0; i < 6; i++) Botania.proxy.sparkleFX(x + Math.random(), y + Math.random(), z + Math.random(), 0.35F, 0.2F, 0.05F, 1F, 5); } } } if(world.isRemote) player.swingArm(hand); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); }
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = playerIn.getHeldItem(hand); IBlockState state = worldIn.getBlockState(pos); Block block = state.getBlock(); int meta = block.getMetaFromState(state); if(playerIn.isSneaking()) { if(setBlock(stack, block, meta)) { displayRemainderCounter(playerIn, stack); return EnumActionResult.SUCCESS; } } else { boolean did = placeAllBlocks(stack, playerIn); if(did) { displayRemainderCounter(playerIn, stack); if(!worldIn.isRemote) playerIn.swingArm(hand); } return did ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; } return EnumActionResult.PASS; }
@Override public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand ) { final Block b = world.getBlockState( pos ).getBlock(); if( b != null && !player.isSneaking() && Platform.hasPermissions( new DimensionalCoord( world, pos ), player ) ) { if( Platform.isClient() ) { // TODO 1.10-R - if we return FAIL on client, action will not be sent to server. Fix that in all // Block#onItemUseFirst overrides. return !world.isRemote ? EnumActionResult.SUCCESS : EnumActionResult.PASS; } if( b.rotateBlock( world, pos, side ) ) { player.swingArm( hand ); return !world.isRemote ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; } } return EnumActionResult.PASS; }
&& (!(block instanceof BlockCommandBlock) || player.canUseCommandBlock()) && block.rotateBlock(world, pos, side)) { player.swingArm(hand); return EnumActionResult.SUCCESS; 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);
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) { TileEntity tileAt = world.getTileEntity(pos); if(tileAt != null && (tileAt instanceof IManaPool || tileAt instanceof IManaCollector)) { boolean pool = tileAt instanceof IManaPool; Actuator act = pool ? Actuator.functionalActuator : Actuator.generatingActuator; int range = pool ? SubTileFunctional.LINK_RANGE : SubTileGenerating.LINK_RANGE; for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, range, range))) { if(pos_.distanceSq(pos) > range * range) continue; TileEntity tile = world.getTileEntity(pos_); if(tile instanceof ISubTileContainer) { SubTileEntity subtile = ((ISubTileContainer) tile).getSubTile(); if(act.actuate(subtile, tileAt)) { Vector3 orig = new Vector3(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5); Vector3 end = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); ItemTwigWand.doParticleBeam(world, orig, end); } } } if(player.world.isRemote) player.swingArm(hand); return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }
@SubscribeEvent public void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) { ItemStack stack = event.getItemStack(); boolean correctStack = !stack.isEmpty() && stack.getItem() == Items.GLASS_BOTTLE; boolean ender = event.getWorld().provider instanceof WorldProviderEnd; if(correctStack && ender) { if (event.getWorld().isRemote) { event.getEntityPlayer().swingArm(event.getHand()); } else { ItemStack stack1 = new ItemStack(this, 1, 15); ItemHandlerHelper.giveItemToPlayer(event.getEntityPlayer(), stack1); stack.shrink(1); event.getWorld().playSound(null, event.getPos(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.5F, 1F); } event.setCanceled(true); event.setCancellationResult(EnumActionResult.SUCCESS); } }
|| stack.getItem() == ModItems.phantomInk; if(valid) player.swingArm(hand); return valid;
setTargetBlock(stack, wstate.getBlock(), wstate.getBlock().getMetaFromState(wstate)); if(world.isRemote) player.swingArm(hand);
boolean valid = stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.dye || stack.getItem() == ModItems.phantomInk; if(valid) player.swingArm(hand); return valid;
if(ImmutableSet.of(Blocks.GRASS, Blocks.GRASS_PATH, Blocks.FARMLAND, Blocks.DIRT, ModBlocks.altGrass).contains(block)) { if(event.getWorld().isRemote) event.getEntityPlayer().swingArm(event.getHand()); else { event.getWorld().playSound(null, event.getPos(), block.getSoundType().getBreakSound(), SoundCategory.BLOCKS, block.getSoundType().getVolume() * 0.4F, block.getSoundType().getPitch() + (float) (Math.random() * 0.2 - 0.1));
p.swingArm( hand ); return !w.isRemote;