mojira.dev
MC-210281

Sculk sensors are not activated upon pufferfish changing their puff state

The Bug:

Sculk sensors are not activated upon pufferfish changing their puff state.

Steps to Reproduce:

  1. Build the setup as shown in the attachment below.

[media]
  1. Summon a pufferfish in the water and switch into survival mode.

  2. Slowly approach the pufferfish to make it puff, and watch the sculk sensor closely as you do this.

  3. Take note as to whether or not sculk sensors are activated upon pufferfish changing their puff state.

Observed Behavior:

Sculk sensors aren't activated.

Expected Behavior:

Sculk sensors would be activated.

Code Analysis:

Code analysis by @unknown can be found below.

The following is based on a decompiled version of Minecraft 1.18.2 using MCP-Reborn.

net.minecraft.world.entity.animal.Pufferfish.java

public class Pufferfish extends AbstractFish {
   ...
   public void tick() {
      if (!this.level.isClientSide && this.isAlive() && this.isEffectiveAi()) {
         if (this.inflateCounter > 0) {
            if (this.getPuffState() == 0) {
               this.playSound(SoundEvents.PUFFER_FISH_BLOW_UP, this.getSoundVolume(), this.getVoicePitch());
               this.setPuffState(1);
            } else if (this.inflateCounter > 40 && this.getPuffState() == 1) {
               this.playSound(SoundEvents.PUFFER_FISH_BLOW_UP, this.getSoundVolume(), this.getVoicePitch());
               this.setPuffState(2);
            }

            ++this.inflateCounter;
         } else if (this.getPuffState() != 0) {
            if (this.deflateTimer > 60 && this.getPuffState() == 2) {
               this.playSound(SoundEvents.PUFFER_FISH_BLOW_OUT, this.getSoundVolume(), this.getVoicePitch());
               this.setPuffState(1);
            } else if (this.deflateTimer > 100 && this.getPuffState() == 1) {
               this.playSound(SoundEvents.PUFFER_FISH_BLOW_OUT, this.getSoundVolume(), this.getVoicePitch());
               this.setPuffState(0);
            }

            ++this.deflateTimer;
         }
      }

      super.tick();
   }
   ...

If we look at the above class, we can see that pufferfish changing their puff states isn't registered as a game event as the gameEvent() method is never called, thus not detecting this action as a vibration.

Potential Fix:

Simply calling the gameEvent() method where appropriate within this piece of code should resolve this problem. I feel as if a new game event tag would be expected to be used here as none of the currently existing ones seem to fit this action accordingly.

Linked issues

Attachments

Comments 1

Avoma

(Unassigned)

Confirmed

Gameplay

Low

Game Events

pufferfish, sculk_sensor

20w51a, 21w03a, 21w05a, 21w05b, 21w06a, ..., 1.21, 1.21.3, 1.21.4, 1.21.5, 1.21.7

Retrieved