Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-267154

Using an Eye of Ender plays the minecraft:entity.ender_eye.launch sound event twice

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 24w18a
    • 1.20.3 Release Candidate 1, 1.20.4 Release Candidate 1, 1.20.4
    • None
    • Community Consensus
    • Sound
    • Normal
    • Platform

      Using an Eye of Ender plays the minecraft:entity.ender_eye.launch sound event twice, once from the logical server and once from the client.

      Steps to reproduce:

      • Apply the attached resource pack. It replaces the sound with the pig and wolf death sounds to be more audibly distinct.
      • Enter a world with strongholds enabled.
      • Give yourself an Eye of Ender.
      • Use the Eye of Ender.
      • Notice how two sounds play instead of one. Note: due to the randomness in pitch in one of the two invoked sound events, as well as the randomness of sound definitions, you may hear slightly different sounds every time you use the item.

      Code analysis:

      The net.minecraft.world.item.EnderEyeItem::use method contains the following:

      public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand interactionHand) {
      	// ...
      	if (/* ... */) {
      		// ...
      	} else {
      		// ...
      		if (level instanceof ServerLevel) {
      			// ...
      			if (blockPos != null) {
      				// ...
      				level.playSound((Player)null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENDER_EYE_LAUNCH, SoundSource.NEUTRAL, 0.5F, 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F));
      				level.levelEvent((Player)null, 1003, player.blockPosition(), 0);
      				// ...
      			}
      		}
      		// ...
      	}
      }
      

      The first instance is played directly from the item by the playSound method above. Note that it always does this on the logical server because of the instanceof check earlier in the method. The second instance is played on the client later in the LevelRenderer::levelEvent method:

      public void levelEvent(int i, BlockPos blockPos, int j) {
      	// ...
      	switch (i) {
      		// ...
      		case 1003:
      			this.level.playLocalSound(blockPos, SoundEvents.ENDER_EYE_LAUNCH, SoundSource.NEUTRAL, 1.0F, 1.2F, false);
      			break;
      		// ...
      	}
      }
      

            Fantastime [Mojang] Maxime Lebrot
            ErrorCraft ErrorCraft
            Votes:
            6 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: