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

SuccessCount in command blocks is updated wrong

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Resolution: Unresolved
    • Minecraft 1.14 Pre-Release 5, 1.15.2, 20w20b
    • None
    • None
    • Confirmed
    • Commands

    Description

      The bug

      When running a command in a command block, it is supposed to store the SuccessCount in it, which it seems to do well. But if you let a command block check for its own SuccessCount, it seems to be resetting the count before it runs the command. This means that checking itself for a SuccessCount of 1 will always result in 0 and checking for a SuccessCount of 0 will always result in one.

      To reproduce place down a command block and attach a comparator to it (for easy visualisation of the result). Add this command to the command block:

      execute if block ~ ~ ~ minecraft:command_block{SuccessCount:0}
      

      Expected Result

      The comparator toggles on and off with each pulse it gets

      Actual Result

      The comparator stays on.

      You can also see the opposite happening if you change the command to say

      execute if block ~ ~ ~ minecraft:command_block{SuccessCount:1}

      instead and manually set the SuccessCount to 1 before powering it, it will turn off instead of staying on.

      Code analysis

      In 1.14 pre-5 with Fabric, `net.minecraft.world.CommandBlockExecutor.execute()` will set `this.successCount` to 0 first before executing the command. This means that the if the command block is saved to NBT during command execution, `SuccessCount` will be 0 and thus the command succeeds again. In prior versions, `this.successCount` is not changed until after the command is executed.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Plagiatus Plagiatus
            Votes:
            4 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              CHK: