The order in which tagged functions are invoked is not consistent across reloads. The game respects neither the order in which datapacks are enabled nor the order of functions within the tag's definition.
Expected results
The expectation is that the invocation order remains consistent across reloads:
[Server] foo:load1
[Server] foo:load2
[Server] foo:load3
[Server] bar:load1
[Server] bar:load2
[Server] bar:load3
See also
[media], which is meant to serve as an alternate explanation of the expected behaviour and not an official piece of evidence.
Actual results
As evident in
[media], the tag order is shuffled arbitrarily each time datapacks are reloaded. One iteration yielded the following output:
[Server] foo:load3
[Server] bar:load3
[Server] foo:load1
[Server] foo:load2
[Server] bar:load1
[Server] bar:load2
Details
The following also produce inconsistent results across reloads:
/function #foo:load
/function #bar:load
/function #foo:tick
/function #bar:tick
Given that foo
and bar
are defined in two separate datapacks, we can deduce two problems:
Datapack ordering is not respected; otherwise all invocations of
foo
functions should come before those ofbar
.Function order within the tag definition is not respected; otherwise
foo:load1
should be invoked beforefoo:load2
, which in turn should be invoked beforefoo:load3
.
How to reproduce
This behaviour can be reproduced by placing both datapacks from the attached
[media] into a world's datapacks
folder and running /reload
repeatedly. (Datapacks are also available on GitHub.)
Code Analysis
Code analysis by @unknown can be found in this comment
Affects 18w21b