mojira.dev
MC-87798

Command blocks running before a joining player is fully loaded

The bug

When a player joins a world or server, repeating command blocks begin to run before they are fully loaded into the game.

What I expected to happen was...

I expected for the repeating commands blocks to only execute when a player is fully loaded, so that they doesn't falsely execute a successful testfor command.

What actually happened was...

A repeating command block checking for a player will fail momentarily, even though the player has joined.

How to reproduce

  1. On singleplayer, enter the following command in a repeating command block:

    execute unless entity @a run setblock ~ ~1 ~ stone
  2. Exit and rejoin the world
    → ❌  A block of stone has been placed above the command block

Original steps to Reproduce

1. Create a new world of any type in creative mode.

2. Place a repeating, no-redstone, non-conditional command block with the command testfor @a.
3. In front of that, place a redstone comparator, a solid block, and a redstone torch (on the block).
4. Adjacent to the redstone torch, place a repeating, redstone-reliant, non-conditional command block with a say command (e.g. say eggplant).
5. Nothing should happen; this means that the first command block's testfor @a command is successful, preventing the second command block's command from executing.
6. Exit and rejoin the world. [@] eggplant will be in chat twice, meaning that the command blocks executed for about two ticks before realizing the player existed.

This is a problem if you have a message that shows up when nobody is on a certain team, or if you want something to run when there are no players online (in a server).

Linked issues

Attachments

Comments 5

The problem seems to be that command blocks get activated too early in singleplayer.

Confirmed for

  • 15w35e

Launcher log

[22:20:52] [Server thread/INFO]: Starting integrated minecraft server version 15w35e
[22:20:52] [Server thread/INFO]: Generating keypair
[22:20:52] [Server thread/INFO]: Preparing start region for level 0
[22:20:53] [Server thread/INFO]: Preparing spawn area: 55%
[22:20:53] [Server thread/INFO]: [@] Test will follow
[22:20:53] [Server thread/INFO]: Changing view distance to 12, from 10
[22:20:53] [Server thread/INFO]: [@] Test will follow
[22:20:53] [Server thread/INFO]: [@] Test will follow
[22:20:54] [Server thread/INFO]: [@] Test will follow
[22:20:54] [Server thread/INFO]: Marcono1234[local:E:08f8a399] logged in with entity id 21641 at (1448.28369051646, 57.0, 432.1428522543623)
[22:20:54] [Server thread/INFO]: Marcono1234 joined the game
[22:20:54] [Server thread/INFO]: [@] Test will follow
[22:20:54] [Server thread/INFO]: [@] Marcono1234
[22:20:54] [Server thread/INFO]: [@] Found a player
[22:20:54] [Server thread/INFO]: Saving and pausing game...
[22:20:54] [Server thread/INFO]: Saving chunks for level 'Test World New'/Overworld
[22:20:54] [Server thread/INFO]: Saving chunks for level 'Test World New'/Nether
[22:20:54] [Server thread/INFO]: Saving chunks for level 'Test World New'/The End
[22:20:54] [Client thread/INFO]: [CHAT] [@] Test will follow
[22:20:54] [Client thread/INFO]: [CHAT] [@] Marcono1234
[22:20:54] [Client thread/INFO]: [CHAT] [@] Found a player
[22:20:54] [Server thread/INFO]: [@] Test will follow
[22:20:54] [Server thread/INFO]: [@] Marcono1234
[22:20:54] [Server thread/INFO]: [@] Found a player
[22:20:54] [Client thread/INFO]: [CHAT] [@] Test will follow
[22:20:54] [Client thread/INFO]: [CHAT] [@] Marcono1234
[22:20:54] [Client thread/INFO]: [CHAT] [@] Found a player

Note: The first command did not even print something in the chat

Bug is still present in 15w38b.

Confirmed in pre-release 3

Sounds like error 404 not found
Try a similar command

Confirmed in 1.16 Release Candidate 1. Steps to reproduce in current version:

  1. On singleplayer, enter the following command in a repeating command block:

    execute unless entity @a run setblock ~ ~1 ~ stone
  2. Exit and rejoin the world
    → ❌ A block of stone has been placed above the command block

Poyo Gainz

(Unassigned)

Confirmed

(Unassigned)

command_block, loading, repeating_command_block

Minecraft 15w35e, Minecraft 15w36d, Minecraft 15w38b, Minecraft 15w50a, Minecraft 1.9 Pre-Release 3, ..., 1.15.2, 20w07a, 1.16 Release Candidate 1, 1.16, 1.16.2

Retrieved