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

High efficiency tools / fast mining destroys some blocks client-side only

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 17w50a
    • Minecraft 1.4.6, Minecraft 15w42a, Minecraft 15w47a, Minecraft 15w49b, Minecraft 15w50a, Minecraft 15w51b, Minecraft 16w03a, Minecraft 16w05b, Minecraft 1.9 Pre-Release 2, Minecraft 1.9 Pre-Release 4, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.2, Minecraft 16w15b, Minecraft 1.9.4, Minecraft 1.10, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 16w39b, Minecraft 16w39c, Minecraft 16w44a, Minecraft 1.11, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w18a, Minecraft 1.12 Pre-Release 6, Minecraft 1.12 Pre-Release 7, Minecraft 1.12, Minecraft 1.12.1, Minecraft 1.12.2 Pre-Release 1, Minecraft 1.12.2
    • Confirmed
    • Survival

      The bug

      Mining lots of blocks at once by holding your mouse while equipped with a tool capable of instamining blocks (efficiency 5 diamond shovel vs dirt, for example) will leave some blocks on the server, but the client thinks they're gone.

      This bug can occur on a server running 20 TPS constantly. It only occurs when the time to break a block is instant, e.g. with a diamond pickaxe on Nether rack or high-Efficiency diamond shovel on dirt. While the block in question disappears from the client's view (it is not rendered anymore and is removed from clientside collision), the server says it's still there and pushes the players' movement back when the client tries to move within the block's space. This can be a quite tricky and dangerous situation, especially when taking down a pillar below you: You fall into the ghost block again and again (many times a second) and cannot move. Client and server arrive at no consensus over whether the block is still there or not. Reloading the chunks on the client by pressing F3+A does not resolve this. It can be resolved by trying to place a new block in the old location. This of course fails server-side, the new block is not placed, but the old one reappears client-side. It can also be resolved by rejoining the server.

      How to reproduce (with provided structure)

      Partwise by francois137

      1. Download the attached structure bug_instamining.nbt and place it in the structures folder of your world folder
      2. Stand on the command block, and switch your gamemode to Survival
        /gamemode survival
        
      3. Press the button
      4. Hold down the block breaking key (default: left click) and move forward without rotating
        → The red sandstone block became a ghost-block

      How to reproduce

      See Ghost-block reproduction (1.12).mp4 for the video version

      1. Build a two block wide sandstone tower
      2. Give yourself an efficiency pickaxe
        /give @p diamond_pickaxe 1 0 {ench:[{id:32s,lvl:5s}]}
        
      3. Move to the top of the tower and stand in the middle of the two blocks
      4. Switch to Survival mode
        /gamemode survival
        
      5. Look at one block
      6. Hold down the block breaking key (default: left click) and move towards the block you are looking at
        → While falling you get stuck in a ghost block

      Code analysis

      Based on 1.12 decompiled using MCP 9.40 PRE 1

      It looks like this bug is caused by the server thinking that the player is not on ground and therefore cannot instamine a block while the client thinks it can. This can be seen when setting a breakpoint in net.minecraft.server.management.PlayerInteractionManager.onBlockClicked(BlockPos, EnumFacing) for the specific block position where a ghost block will be (see "How to reproduce (with provided structure)") and then following the method calls to EntityPlayer.getDigSpeed(IBlockState).

      For lagging servers or clients this another cause could likely be the method net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(CPacketPlayerDigging) which is not sending a SPacketBlockChange packet to resync the block if the block position is too far away from the player.


      Suggested fix by gnembon can be found in fix_miningGhostBlocks.PNG; explanation can be found in this comment

        1. 2016-08-21_07.16.26.png
          2016-08-21_07.16.26.png
          642 kB
        2. 2017-02-01_23.46.07.png
          2017-02-01_23.46.07.png
          500 kB
        3. 2017-06-25_22.30.43.png
          2017-06-25_22.30.43.png
          645 kB
        4. bug_instamining.nbt
          2 kB
        5. fix_miningGhostBlocks.PNG
          fix_miningGhostBlocks.PNG
          119 kB
        6. Ghost-block reproduction (1.12).mp4
          6.57 MB

            grum [Mojang] Grum (Erik Broes)
            cubetrace Martin Bittermann
            Votes:
            165 Vote for this issue
            Watchers:
            74 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: