mojira.dev
MC-134316

Commands in functions are not being ran in consistent order.

Commands do not seem to be running in the order specified in the functions and are arbitrarily ran. 

 

Steps to reproduce:

  1. Download the Commands Out Of Order datapack

  2. Drag the zipped datapack into your datapacks folder of your world

  3. Set up a multiplayer game (tested in LAN)

  4. Have two people connect and then run the /reload command from chat

  5. Let each player kill the other for a while

  6. Be sure to have both players kill each other, not just one account killing the other.

You should be able to notice how the death/kill messages are mixed and not in the same order.

execute if score @s mg.deaths matches 1 run function mglib:entity/player/main/death 

execute if score @s mg.respawn matches 1.. run function mglib:entity/player/main/spawn_split_1

execute if score @s mg.mkills matches 1 run function mglib:entity/player/main/mob_kill

execute if score @s mg.pkills matches 1 run function mglib:entity/player/main/player_kill

This is the player tick function: the death message should appear before the kill message does.

Attachments

Comments 3

Can confirm. Whenever the players switch in who's killing and who's killed, the messages come in the wrong order for me.

I've created a bare-bones version of their Datapack, just to be sure it isn't cause by anything else. also, I've added the current gametick to the tellraw to show clearly that it's run in the same tick.

[media]

okay, I think I've located the issue here: The function that produces the messages is called upon every player. each player can either send the death or the kill message. the order in which the same function is executed upon the player is arbitrary, since not further specified (and mc, as far as I know, uses age as arbitrary, and since one of the players died, their age was reset and thus the sorting order is reverted, and thus the moment it gets reverted the previous order was still a thing and thus the commands come in the wrong order whenever you switch killer and killed).

So, the problem is probably not that commands aren't run in a consistent order, but instead that players are getting rearranged in the arbitrary list when killed?

Ryan Smith

(Unassigned)

Community Consensus

Minecraft 1.13

Retrieved