-
Bug
-
Resolution: Fixed
-
1.15.2, 1.16 Pre-release 1, 1.16 Pre-release 2, 1.16 Pre-release 3, 1.16 Pre-release 4, 1.16 Pre-release 5, 1.16 Pre-release 6, 1.16 Pre-release 7, 1.16 Pre-release 8, 1.16 Release Candidate 1, 1.16, 1.16.1, 20w27a, 20w28a, 20w29a, 20w30a, 1.16.2 Pre-release 1, 1.16.2 Pre-release 2, 1.16.2 Pre-release 3, 1.16.2 Release Candidate 1, 1.16.2 Release Candidate 2, 1.16.2, 1.16.3 Release Candidate 1, 1.16.3, 1.16.4 Pre-release 1, 1.16.4 Pre-release 2, 1.16.4 Release Candidate 1, 1.16.4, 20w45a, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5 Release Candidate 1, 1.16.5, 21w05a, 21w05b, 21w06a, 21w07a, 21w08a, 21w08b, 21w10a, 21w11a, 21w13a, 21w14a, 21w15a, 21w16a, 21w17a, 21w18a, 21w19a, 21w20a, 1.17 Pre-release 1, 1.17 Pre-release 4, 1.17 Release Candidate 1, 1.17 Release Candidate 2, 1.17, 1.17.1 Pre-release 1, 1.17.1, 21w39a, 21w41a, 21w42a, 1.18.1, 1.19, 1.19.2
-
Community Consensus
-
Commands, Data Packs
-
Important
The bug
When enabling or reloading a data pack that has functions for both #tick and #load, the former function tag runs before the latter, which causes problems in some cases such as initializing scoreboard values before increasing them per tick. The bug occurs since 1.13.
#load should run before #tick to make it intuitive for other players.
How to reproduce
- Install the data pack below in a world for better reproduction.
- Ensure the gametime scoreboard objective does not exist before enabling the data pack.
- Use either of the following commands to enable the data pack:
/reload /datapack enable <name>
- Observe the value of $game in the sidebar after a few seconds.
→ The value starts from -2147483648 and then increases per tick. - Use the following commands quickly to reset the $game value:
/reload /scoreboard players reset $game gametime
→ The value starts from 1 instead of the minimum integer value.
Log
Log snippet by m124367 can be found in this comment and below:
[22:18:18] [Render thread/INFO]: [CHAT] Reloading! [22:18:18] [Server thread/INFO]: Loaded 0 recipes [22:18:18] [Server thread/INFO]: Loaded 0 advancements [22:18:18] [Server thread/INFO]: [Server] onTick [22:18:18] [Server thread/INFO]: [Server] onLoad [22:18:18] [Server thread/INFO]: [Server] onTick [22:18:18] [Server thread/INFO]: [Server] onTick [22:18:18] [Server thread/INFO]: [Server] onTick [22:18:18] [Server thread/INFO]: [Server] onTick [22:18:18] [Server thread/INFO]: [Server] onTick [22:18:18] [Server thread/INFO]: [Server] onTick [22:18:18] [Server thread/INFO]: [Server] onTick
From there, the #load function tag of a data pack sends an "onLoad" message in chat, and the #tick function tag sends an "onTick" message.
After enabling or reloading the data pack, it shows the "onTick" message once before showing the "onLoad" message. The data pack then continues sending "onTick" messages for each tick.
Code analysis
Code analysis by tryashtar can be found in this comment.