mojira.dev
MC-128565

Function tag ordering is inconsistent across reloads and does not respect datapack ordering

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:

  1. Datapack ordering is not respected; otherwise all invocations of foo functions should come before those of bar.

  2. Function order within the tag definition is not respected; otherwise foo:load1 should be invoked before foo:load2, which in turn should be invoked before foo: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

Attachments

Comments 48

Can confirm for 1.13-pre3

38 more comments

Thank you @boq for your fix!

Nice! 😃 This opens up a bunch of new possibilities for functions. Thanks!

Arcensoth

boq

Confirmed

(Unassigned)

Minecraft 18w15a, Minecraft 18w16a, Minecraft 18w21b, Minecraft 1.13-pre3, Minecraft 1.13-pre4, ..., Minecraft 1.14 Pre-Release 1, Minecraft 1.14 Pre-Release 2, Minecraft 1.14 Pre-Release 3, Minecraft 1.14 Pre-Release 5, Minecraft 1.14

Minecraft 1.14.1 Pre-Release 1

Retrieved