mojira.dev
MC-209932

Sculk sensors only detect the last turtle egg being broken when being stepped on

The Bug:

Sculk sensors only detect the last turtle egg being broken when being stepped on.

Steps to Reproduce:

  • Place down four turtle eggs on the same block.

  • Place down a sculk sensor nearby, stand on top of the turtle eggs, and wait for them to break.

  • Take note as to whether or not sculk sensors only detect the last turtle egg being broken when being stepped on.

Observed Behavior:

Sculk sensors aren't actiavted.

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.level.block.TurtleEggBlock.java

public class TurtleEggBlock extends Block {
   ...
   private void decreaseEggs(Level $l, BlockPos $bp, BlockState $bs) {
      $l.playSound((Player)null, $bp, SoundEvents.TURTLE_EGG_BREAK, SoundSource.BLOCKS, 0.7F, 0.9F + $l.random.nextFloat() * 0.2F);
      int i = $bs.getValue(EGGS);
      if (i <= 1) {
         $l.destroyBlock($bp, false);
      } else {
         $l.setBlock($bp, $bs.setValue(EGGS, Integer.valueOf(i - 1)), 2);
         $l.levelEvent(2001, $bp, Block.getId($bs));
      }

   }
   ...

If we look at the above class, we can see that when the last turtle egg is broken, the destroyBlock() method is called. The destroyBlock() method then calls the gameEvent() method resulting in a vibration being produced. The problem here is that when there is more than one turtle egg occupying the same space, and one of them was to be destroyed, 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. The "BLOCK_DESTROY" game event tag would be expected to be used here as the turtle eggs are destroyed.

Attachments

Comments 4

Can confirm, There are 4 eggs that can break 1 only but if the last egg breaks it will vibrate the sculk sensor. It should be fixed

Relates to MC-207679. Reckon you could add the sculk_sensor label to this ticket and any other tickets you've reported in this vein?

Can confirm in 1.17.1.

Avoma

kingbdogz

Confirmed

Normal

Game Events

sculk_sensor

20w51a, 21w03a, 21w05a, 21w05b, 21w06a, ..., 1.18.2, 22w11a, 22w14a, 22w17a, 1.19 Pre-release 1

1.19 Pre-release 3

Retrieved