mojira.dev
MC-148801

Command blocks always treat their own SuccessCount as 0 while running a command

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.

Comments 0

No comments.

Plagiatus

(Unassigned)

Confirmed

Commands

Minecraft 1.14 Pre-Release 5, 1.15.2, 20w20b, 1.18.2, 23w41a

Retrieved