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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.19 Pre-release 3
    • 20w51a, 21w03a, 21w05a, 21w05b, 21w06a, 21w07a, 21w08b, 21w10a, 21w14a, 21w15a, 21w17a, 21w19a, 21w20a, 1.17 Pre-release 1, 1.17 Release Candidate 1, 1.17 Release Candidate 2, 1.17, 1.17.1 Pre-release 1, 1.17.1, 1.18, 1.18.1, 1.18.2, 22w11a, 22w14a, 22w17a, 1.19 Pre-release 1
    • Confirmed
    • Game Events
    • Normal

      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 Avoma 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.

        1. MC-209932.mp4
          6.46 MB
          [Mod] Avoma
        2. MC-209932.png
          608 kB
          [Mod] Avoma

            kingbdogz [Mojang] Brandon Pearce
            Avoma [Mod] Avoma
            Votes:
            11 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: