#
#
Background
#
What is a data pack?
"A data pack is a collection of data used to configure a number of features of Minecraft. A data pack is either a folder or a .zip file containing a pack.mcmeta file. Data packs are used to define among others advancements, dimensions, enchantments, loot tables, recipes, structures, and biomes" — Minecraft.wiki
#
Aim of this library
The aim of this library is to provide a simple yet powerful set of API's used to build high-quality Minecraft data packs in pure JavaScript or TypeScript. It is modular by design, meaning that any third-party tools can easily plug into it and there are a number of offical modules aimed at easing certain aspects of development. For that check out Modules.
#
Install
npm install @datapackjs/core
Additionally, you may install any optional addon modules you wish to use, see modules.
#
Example
You can find more documentation and examples on datapack.js.org.
import { Datapack, MCFunction, Effect } from '@datapackjs/core';
import { effect } from '@datapackjs/commands'; // Commands module (optional)
// Specify pack format, name & description
const datapack = new Datapack(88, 'datapackjs', 'Generated by Datapack.js');
// You may extract your functions out into individual files and export them, very handy!
const giveJumpBoost = MCFunction.define('give_jump_boost', [
effect.give('@s', Effect.JUMP_BOOST, 30, 2, true), // Same as, effect give @s minecraft:jump_boost 30 2 true
'say Using the commands module is optional, I can also simply use plain strings!',
]);
// Remember to register each one of your functions!
datapack.registerFunction(giveJumpBoost);
// Build your datapack and specify and output for your .zip
datapack.build({ output: join(import.meta.dirname, './datapack.zip') });
Built by Jacob Wennebro.