mcNows
Nows Loader 0.11.0 / Minecraft 26.2

Data Packs, Commands And Generated Data

Register data pack sources, command collectors and generated JSON output through the Minecraft adapter.

Some APIs may still change or behave unevenly because they do not have enough real-world use cases and test coverage yet.

Data Packs, Commands And Generated Data

Datapack and resource-pack sources are exposed through the version adapter:

DataPacks packs = MinecraftApi.dataPacks(context);
Path modPackDir = packs.modPackDirectory("my_mod");
Path dataDir = packs.modDataDirectory("my_mod");
Path assetsDir = packs.modAssetsDirectory("my_mod");
List<Object> serverSources = packs.sources(PackTarget.SERVER_DATA);

Commands and generated JSON data are collected through the adapter as well:

MinecraftApi.commands(context).register(CommandSpec.literal("my_mod")
        .executes(MyCommands::run)
        .result(1)
        .build());

DataGen dataGen = MinecraftApi.dataGen(context);
dataGen.writeJson(dataGen.recipePath("my_mod:widget"), Map.class, Map.of(
        "type", "minecraft:crafting_shapeless",
        "ingredients", List.of(Map.of("item", "minecraft:stone")),
        "result", Map.of("id", "my_mod:widget", "count", 1)
));

Pack Sources

DataPacks.modPackDirectory(modId) gives a stable per-mod directory under the active game directory. modDataDirectory(modId) and modAssetsDirectory(modId) give the normal namespaced data/<modId> and assets/<modId> folders for generated or user-editable resources.

Use PackTarget.SERVER_DATA for data packs and PackTarget.CLIENT_RESOURCES for assets. registerSource(PackTarget, Object) still forwards to Minecraft’s real repository source internally, so complex pack behavior can keep using the target version’s native source object behind the stable target enum.

Commands

MinecraftApi.commands(context).register(CommandSpec) builds a Brigadier literal with optional CommandArgumentSpec arguments (string, word, greedy string, integer, decimal, boolean, player and block position), an optional permission level, and a callback that receives the parsed values, the source name and a reply function. Player arguments are passed as the player name, and an optional argument that was not typed is absent from the context. The lower-level dispatcher callback is still available when a command needs version-specific source details.

Register commands during normal mod initialization. Avoid capturing temporary world/server objects in the registration lambda; use the command source passed at execution time.

Generated Data

DataGen writes JSON through the adapter, with helpers such as recipePath("my_mod:widget") for common output paths. The current API is intentionally small: it writes generated JSON, but it does not replace a full Gradle data-generation pipeline.

Generated JSON follows the selected Minecraft version. Recipes use the item stack objects of 1.20.5 and the plain id ingredients of 1.21.2 where those versions require them, and recipes and tags are written to the folder names that version reads (recipes and tags/items up to 1.20.6, recipe and tags/item from 1.21).

Good uses include simple generated recipes, tags, language fragments or small model/data files that are easier to derive from Java constants. Large asset pipelines should still live in normal build tooling.