mojira.dev
MC-116388

Chain command blocks can clone themselves to create an infinite loop which freezes the server

If a chain command block is set to clone itself into the block it's pointing at, it creates an infinite loop that freezes the server.

To Reproduce:
  1. Place an impulse command block. Do not enter a command.

  2. Place a chain command block in front of it, facing horizontally.

  3. Enter one of these commands:

    /clone ~ ~ ~ ~ ~ ~ ~ ~ ~-1 (If block is facing north)
    /clone ~ ~ ~ ~ ~ ~ ~ ~ ~1  (If block is facing south)
    /clone ~ ~ ~ ~ ~ ~ ~1 ~ ~  (If block is facing east)
    /clone ~ ~ ~ ~ ~ ~ ~-1 ~ ~ (If block is facing west)

    into the chain block.

  4. Activate the impulse block.

  5. Notice that you cannot interact with entities, chunks don't load, attempting to close the game crashes it, etc.

Reason:

In 17w16a, Minecraft started using a new way of executing command blocks. Instead of registering every chain block to be ticked ahead of time, only impulse and repeating blocks are registered and execution follows the chain blocks.

This means that if chain blocks are added during the tick they will be executed like normal, so by cloning themselves they can ensure that the chain never ends.

Comments 5

Instead of infinite, this will now only work for a certain amount of times before the chain stops executing

So does that mean that there's now a maximum chain length? If so, what is it?

I am curious as well, if there's a limit it's important to know what it is.

The limit is controlled by the maxCommandChainLength gamerule, which defaults to 65536. It essentially states the total number of Chain command blocks that can be run per chain.

Okay, great solution. That seems like a very large default and I don't see a use for creating a chain block loop unless some crazy arithmetic has to be done in one tick. Even then, it can be changed.

And if something goes south, you can temporarily change the chain limit to a small number.

Thanks!

AjaxGb

michael

Confirmed

chain_command_block, crash, server

Minecraft 17w16a

Minecraft 17w16b

Retrieved