@Override public boolean onWanded(EntityPlayer player, ItemStack wand) { if(player == null) return false; knownMana = mana; SoundEvent evt = ForgeRegistries.SOUND_EVENTS.getValue(DING_SOUND_EVENT); if(evt != null) player.playSound(evt, 0.1F, 1F); return super.onWanded(player, wand); }
@Override public boolean onWanded(EntityPlayer player, ItemStack wand) { if(player == null) return false; if(!player.world.isRemote) sync(); knownMana = mana; SoundEvent evt = ForgeRegistries.SOUND_EVENTS.getValue(DING_SOUND_EVENT); if(evt != null) player.playSound(evt, 0.1F, 1F); 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 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 itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) { if(ConfigHandler.enderPickpocketEnabled && entity instanceof EntityPlayer && ManaItemHandler.requestManaExact(stack, player, COST_OTHER, false)) { if(!player.world.isRemote) player.displayGUIChest(((EntityPlayer) entity).getInventoryEnderChest()); ManaItemHandler.requestManaExact(stack, player, COST_OTHER, true); player.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1F, 1F); return true; } return false; }
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if(ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) { if(!player.world.isRemote) player.displayGUIChest(player.getInventoryEnderChest()); ManaItemHandler.requestManaExact(stack, player, COST_SELF, true); player.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 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) { 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); } }
player.playSound(ModSounds.ding, 0.11F, 1F);
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) { player.playSound(Sounds.BAG_OPEN, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); Random rand = new Random(); ItemStack book = new ItemStack(Items.BOOK); book = EnchantmentHelper.addRandomEnchantment(rand, book, 5 + rand.nextInt(15), true); return new ActionResult<>(EnumActionResult.SUCCESS, book); } }
@Override public void process(EntityPlayer player, Side side) { // Since this packet is handled differently, we need to check side if (side.isClient()) { // Plays a sound only the client can hear player.playSound(sound, volume, pitch); } else { // Plays a sound that everyone nearby can hear player.worldObj.playSoundEffect(x, y, z, sound, volume, pitch); } } }
@Override public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase living) { if (living instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) living; if (!player.capabilities.isCreativeMode) { stack.shrink(1); } player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); if (!world.isRemote) { player.addExperienceLevel(10); } } else { stack.shrink(1); } return stack; }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) { final ItemStack stack = player.getHeldItem(handIn); player.playSound(Sounds.BAG_OPEN, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); if (!player.capabilities.isCreativeMode) { stack.shrink(1); } if (!world.isRemote) { LootHelper.dropLootAtPlayersPos(world, player, GaiaLootTableList.BOXES_IRON); } return new ActionResult<>(EnumActionResult.SUCCESS, stack); } }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) { final ItemStack stack = player.getHeldItem(handIn); player.playSound(Sounds.BAG_OPEN, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); if (!player.capabilities.isCreativeMode) { stack.shrink(1); } if (!world.isRemote) { LootHelper.dropLootAtPlayersPos(world, player, GaiaLootTableList.BOXES_DIAMOND); } return new ActionResult<>(EnumActionResult.SUCCESS, stack); } }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) { final ItemStack stack = player.getHeldItem(handIn); player.playSound(Sounds.BAG_OPEN, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); if (!player.capabilities.isCreativeMode) { stack.shrink(1); } if (!world.isRemote) { LootHelper.dropLootAtPlayersPos(world, player, GaiaLootTableList.BOXES_GOLD); } return new ActionResult<>(EnumActionResult.SUCCESS, stack); } }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) { final ItemStack stack = player.getHeldItem(handIn); player.playSound(Sounds.BAG_OPEN, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); if (!player.capabilities.isCreativeMode) { stack.shrink(1); } if (!world.isRemote) { LootHelper.dropLootAtPlayersPos(world, player, GaiaLootTableList.BAG_ARROW); } return new ActionResult<>(EnumActionResult.SUCCESS, stack); } }
@Override public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand) { if (!player.capabilities.isCreativeMode) { --itemStack.stackSize; } player.playSound(throwSound, 0.5F, 0.4F / (RandomHelper.random.nextFloat() * 0.4F + 0.8F)); if (!world.isRemote) { EntityThrowable entity = getNewThrownEntity(world, player); entity.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, throwSpeed, 1.0F); world.spawnEntityInWorld(entity); } return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack); }
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { playerIn.playSound(SoundEvents.BLOCK_WOOD_PLACE, 1.0F, 1.0F); return worldIn.setBlockState(pos, replacementBlock.getDefaultState().withProperty(FACING, state.getValue(FACING))); }
@Override protected void actionPerformed(GuiButton button) throws IOException { if (button.id == 1) { VampirismMod.dispatcher.sendToServer(new InputEventPacket(InputEventPacket.TRAINERLEVELUP, "")); EntityPlayer player = Minecraft.getMinecraft().player; UtilLib.spawnParticles(player.getEntityWorld(), EnumParticleTypes.ENCHANTMENT_TABLE, player.posX, player.posY, player.posZ, 1, 1, 1, 100, 1); player.playSound(SoundEvents.BLOCK_NOTE_HARP, 4.0F, (1.0F + (player.getRNG().nextFloat() - player.getRNG().nextFloat()) * 0.2F) * 0.7F); } else { super.actionPerformed(button); } }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (player.isSneaking()) { if (stack.getTagCompound() != null) { player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.5F, 0.3F); } stack.setTagCompound(null); } player.swingArm(hand); return new ActionResult<>(EnumActionResult.SUCCESS, stack); }
public static void tryDrinkWaterInWorld(final EntityPlayer player, final boolean isClient) { final TargetWater targetWater = getRightClickedWater(player); if (null != targetWater) { if (isClient) { // send server packet PacketHandler.instance.sendToServer(new MessageDrinkWaterInWorld()); // play drink sound player.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.5f, 1.0f); // swing hand player.swingArm(EnumHand.MAIN_HAND); } else { // do thirst applyDrinkFromWaterType(player, targetWater.type); if (targetWater.type == WaterType.PURIFIED) { player.world.setBlockToAir(targetWater.pos); } } } }