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

Bees, ghasts, phantoms, and allays can destroy turtle eggs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.18.1, 22w03a, 22w05a, 22w06a, 1.18.2 Pre-release 1, 1.18.2, 22w11a, 22w13a, 22w15a, 22w17a, 1.19, 1.19.1, 1.19.2, 1.19.3, 23w04a, 1.19.4, 1.20.1
    • Confirmed
    • Block states, Entities
    • Normal
    • Gameplay

      The Bug:

      Bees, ghasts, phantoms, and allays can destroy turtle eggs.

      Steps to Reproduce:

      1. Place down some turtle eggs.
      2. Use a spawn egg to summon a bee, ghast, phantom, or an allay on top of them.
      3. Take note as to whether or not bees, ghasts, phantoms, and allays can destroy turtle eggs.

      Observed Behavior:

      Bees, ghasts, phantoms, and allays can destroy turtle eggs.

      Expected Behavior:

      Bees, ghasts, phantoms, and allays would not be able to destroy turtle eggs.

      Code Analysis:

      Code analysis by Avoma can be found below.

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

      net.minecraft.world.level.block.TurtleEggBlock.java
      public class TurtleEggBlock extends Block {
         ...
         private boolean canDestroyEgg(Level $l, Entity $e) {
            if (!($e instanceof Turtle) && !($e instanceof Bat)) {
               if (!($e instanceof LivingEntity)) {
                  return false;
               } else {
                  return $e instanceof Player || $l.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
               }
            } else {
               return false;
            }
         }
         ...

      If we look at the above class, we can see that the only entities that are not able to break turtle eggs are turtles and bats. This is evident through the following line of code:

      if (!($e instanceof Turtle) && !($e instanceof Bat))

      Since no checks are carried out to prevent bees, ghasts, or phantoms from breaking turtle eggs, this results in these entities being able to destroy these blocks.

      Potential Fix:

      Simply altering the appropriate "if" statement to prevent bees, ghasts, and phantoms from being able to break turtle eggs, should resolve this problem. The following line of code could be used in order to fix this:

      if (!($e instanceof Turtle) && !($e instanceof Bat) && !($e instanceof Bee) && !($e instanceof Ghast) && !($e instanceof Phantom))

        1. 2022-08-15 19-24-10.mp4
          2.53 MB
          PlumParrot
        2. MC-248332.png
          1.09 MB
          [Mod] Avoma

            Unassigned Unassigned
            Avoma [Mod] Avoma
            Votes:
            15 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              CHK: