├── data ├── load │ ├── tags │ │ └── function │ │ │ ├── load.json │ │ │ ├── post_load.json │ │ │ ├── pre_load.json │ │ │ └── _private │ │ │ ├── init.json │ │ │ └── load.json │ └── function │ │ └── _private │ │ └── init.mcfunction └── minecraft │ └── tags │ └── function │ └── load.json ├── LICENSE └── README.adoc /data/load/tags/function/load.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [] 3 | } 4 | -------------------------------------------------------------------------------- /data/load/tags/function/post_load.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [] 3 | } 4 | -------------------------------------------------------------------------------- /data/load/tags/function/pre_load.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [] 3 | } 4 | -------------------------------------------------------------------------------- /data/load/tags/function/_private/init.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "load:_private/init" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /data/minecraft/tags/function/load.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "#load:_private/load" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /data/load/function/_private/init.mcfunction: -------------------------------------------------------------------------------- 1 | # Reset scoreboards so packs can set values accurate for current load. 2 | scoreboard objectives add load.status dummy 3 | scoreboard players reset * load.status 4 | -------------------------------------------------------------------------------- /data/load/tags/function/_private/load.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "#load:_private/init", 4 | {"id": "#load:pre_load", "required": false}, 5 | {"id": "#load:load", "required": false}, 6 | {"id": "#load:post_load", "required": false} 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020-2021 Lue 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted. 5 | 6 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 7 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 8 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 9 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 10 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 11 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 12 | OF THIS SOFTWARE. 13 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = Lantern Load 2 | :aestd: https://github.com/Aeldrion/AESTD[AESTD] 3 | :gm4: https://github.com/Gamemode4Dev/GM4_Datapacks[Gamemode 4] 4 | :playerdb: https://github.com/rx-modules/PlayerDB[PlayerDB] 5 | :120-version: https://github.com/LanternMC/load/tree/1.20[an older 1.20 version] 6 | :116-version: https://github.com/LanternMC/load/tree/1.16[an older 1.16 version] 7 | :0bsd-license: link:LICENSE[BSD 0-Clause License] 8 | 9 | Lantern Load provides a simple implementation of version resolution intended to allow data packs and their dependencies to load in a controllable order. 10 | Projects that depend on this library include {aestd}, {gm4}, and {playerdb}. 11 | 12 | This project is released under the {0bsd-license}, which in short means you can do whatever you want with these files, with nothing expected in return. You do not even have to credit us. 13 | 14 | WARNING: *This pack is for Minecraft 1.21 or higher.* 15 | This version of Lantern Load will not work correctly in 1.20.6 or older. 16 | If you must release a pack for versions prior to 1.21, please use {120-version} or {116-version} of Lantern Load. 17 | 18 | == Usage 19 | 20 | 1. Copy the `load` and `minecraft` directories from `load/data/` into your pack's `data` folder. The copied in `load.json` should now call `#load:_private/load`. 21 | 22 | 2. Add load functions in the desired load order to `data/load/tags/function/load.json` or the other tags `pre_load.json` and `post_load.json`. For most cases you should prefer `load.json`. 23 | 24 | .Example `load.json` contents: 25 | [source,json] 26 | ---- 27 | { 28 | "values": [ 29 | "pack1:load", 30 | "your_pack:load" 31 | ] 32 | } 33 | ---- 34 | 35 | === Pack Versioning Specification 36 | 37 | The recommended (but not mandatory) use of the `load.status` scoreboard: 38 | 39 | ____ 40 | Each pack *should* define at least one fake player whose name includes the name of the pack. 41 | At least one of these fake players *should* have a value that *should not* be decreased in future updates to the pack. 42 | This score value *may* be defined to remain constant, or increment in future updates to the pack with or without a semantic meaning. 43 | ____ 44 | 45 | This specification is intentionally open-ended as it is not this project's goal to force a specific versioning scheme on every data pack. 46 | Following the specification simply implies that one can detect when your pack is loaded by checking your `load.status` score. 47 | 48 | === Avoiding the `#minecraft:tick` tag 49 | 50 | The `#minecraft:tick` tag has several problems, the worst of which is that it runs _before_ `#minecraft:load`, meaning that your pack may be ticked without first being initialized. 51 | Lantern Load is meant to allow every pack to initialize itself in a predictable order within the same tick, including on reload, and `#minecraft:tick` interferes with this design goal. 52 | The recommended solution is to instead invoke `schedule` from a function defined in `#load:load`. 53 | 54 | .Example contents of load and tick functions: 55 | [source,mcfunction] 56 | ---- 57 | # your_pack:load 58 | scoreboard players set your_pack load.status 1 59 | schedule function your_pack:tick 1t 60 | 61 | # your_pack:tick 62 | say this is a tick! 63 | schedule function your_pack:tick 1t 64 | ---- 65 | 66 | === Checking for dependencies 67 | 68 | In your load function, you may wish to check the value of another pack's score in `load.status` before initializing scoreboards or scheduling your tick function. 69 | Doing so is a useful way to handle missing dependencies and reduce the risk of your data pack causing errors. 70 | 71 | .Example of checking the value of another pack's load status: 72 | [source,mcfunction] 73 | ---- 74 | # your_pack:load 75 | schedule clear your_pack:tick 76 | execute if score other_pack load.status matches 1 run scoreboard players set your_pack load.status 1 77 | execute if score your_pack load.status matches 1 run function your_pack:init 78 | 79 | # your_pack:init 80 | scoreboard objectives add your_objective dummy 81 | schedule function your_pack:tick 1t 82 | 83 | # your_pack:tick 84 | scoreboard players add your_score your_objective 1 85 | schedule function your_pack:tick 1t 86 | ---- 87 | 88 | == License 89 | 90 | Lantern Load is made freely available under the terms of the {0bsd-license}. 91 | Third-party contributions shall be licensed under the same terms unless explicitly stated otherwise. 92 | --------------------------------------------------------------------------------