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

Players that are forced to sneak in small areas receive damage when stepping on magma blocks

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.16.2, 1.16.3 Release Candidate 1, 1.16.3, 1.16.4 Pre-release 1, 1.16.4 Pre-release 2, 1.16.4 Release Candidate 1, 1.16.4, 20w45a, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 21w05a, 21w05b, 21w06a, 21w07a, 21w08a, 21w08b, 21w10a, 21w11a, 21w13a, 21w14a, 21w15a, 21w16a, 21w17a, 21w18a, 1.17, 1.17.1, 1.18, 1.18.1, 1.18.2, 1.19 Pre-release 3, 1.19 Pre-release 4, 1.19, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1, 1.21, 1.21.3, 1.21.4
    • Community Consensus
    • Player

      The Bug:

      Players that are forced to sneak in small areas receive damage when stepping on magma blocks.

      Steps to Reproduce:

      1. Build the setup as shown in the attachment below. setup.png
      2. While sneaking and holding the sneak key, stand on top of the magma block.
      3. Stop holding the sneak key.
      4. Take note as to whether or not players that are forced to sneak in small areas receive damage when stepping on magma blocks.

      Observed Behavior:

      Players that are forced to sneak in small areas receive damage when stepping on magma blocks.

      Expected Behavior:

      Players that are forced to sneak in small areas would not receive damage when stepping on magma blocks.

      Code Analysis:

      Code analysis by Avoma can be found below.

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

      net.minecraft.world.level.block.MagmaBlock.java
      public class MagmaBlock extends Block {
         ...
         public void stepOn(Level level, BlockPos blockPos, BlockState blockState, Entity entity) {
            if (!entity.isSteppingCarefully() && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity)entity)) {
               entity.hurt(DamageSource.HOT_FLOOR, 1.0F);
            }
            super.stepOn(level, blockPos, blockState, entity);
         }
         ...

      If we look at the above class, we can see that in order for the player to receive damage from stepping on magma blocks, the isSteppingCarefully() boolean must return false. This boolean returns true if the shift key is held down or is toggled and returns false if the shift key isn't held down or isn't toggled. The game doesn't check if the player is being forced to sneak in small areas before allowing them to receive damage from stepping on magma blocks, therefore resulting in this problem occurring.

      Fix:

      Simply altering the existing "if" statement within this piece of code to check if the player is being forced to sneak in small areas before allowing them to receive damage from stepping on magma blocks will resolve this problem. We can achieve this through the use of the isCrouching() boolean.

      Current "if" statement:
      if (!entity.isSteppingCarefully() && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity)entity))
      Fixed "if" statement:
      if (!entity.isCrouching() && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity)entity))

        1. MC-199483.mp4
          5.73 MB
        2. MC-199483.png
          MC-199483.png
          1.02 MB
        3. MC-199483 - Current Code.png
          MC-199483 - Current Code.png
          26 kB
        4. MC-199483 - Fixed Code.png
          MC-199483 - Fixed Code.png
          26 kB
        5. setup.png
          setup.png
          663 kB

            Unassigned Unassigned
            Avoma [Mod] Avoma
            Votes:
            14 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              CHK: