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

Slimes with Size 0 despawn with Peaceful difficulty



    • Bug
    • Status: Open
    • Resolution: Unresolved
    • Minecraft 1.9.4, Minecraft 1.10.2, Minecraft 1.11, Minecraft 16w50a, Minecraft 1.13.1, Minecraft 1.13.2-pre2, Minecraft 1.13.2, Minecraft 19w08b, Minecraft 19w09a, 1.15.2, 20w08a, 1.16.4, 20w48a, 20w51a, 21w03a, 21w05b, 21w06a, 21w07a, 21w14a, 21w15a, 1.17, 1.17.1 Pre-release 1, 1.17.1, 1.18.2, 22w19a
    • None
    • Confirmed
    • (Unassigned)


      The bug

      Based on the code slimes with a Size value of 0 are probably not supposed to despawn. This makes sense because they cannot damage the player.

      Note that this does not apply to magma cubes since they can always damage the player, even when their Size is 0.

      Reproduction steps

      1. Summon a small slime
        /summon minecraft:slime ~ ~ ~ {Size:0}
      2. Change the difficult to Peaceful
        The slime despawns

      Code analysis

      The following is based on a decompiled version of Minecraft 1.17.1-pre1 with Mojang names

      The reason for this is that the method net.minecraft.world.entity.monster.Slime.readAdditionalSaveData(CompoundTag) adds 1 to the read Size value before storing its value as net.minecraft.world.entity.monster.Slime.ID_SIZE (and the value is clamped between 1 and 127, both inclusive).

      However the method net.minecraft.world.entity.monster.Slime.shouldDespawnInPeaceful() tests if the value is greater than 0, which is therefore always the case.

      Instead that method should possibly call isDealsDamage() to determine whether the slime should despawn (though this would allow NoAI slimes to remain in the world even if they would normally, with AI, would damage players).




            Unassigned Unassigned
            marcono1234 [Mod] Marcono1234
            11 Vote for this issue
            6 Start watching this issue