
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A modern JavaScript-based generator for Minecraft datapack functions. Write Minecraft functions using template literals and JavaScript logic, and output them as .mcfunction files for your datapack. Perfect for automating repetitive tasks, generating dynamic content, and keeping your Minecraft projects DRY and maintainable.
You can quickly scaffold a new project using npx:
npx mcjspacker <directory> [namespace]
cd <directory>
npm install
<directory>: The directory to create (relative or absolute path). If it exists and is not empty, the command will abort.[namespace] (optional): The namespace to use for the datapack. If omitted, the directory name is used (normalized).[!NOTE]
This will create a new directory<directory>with example files and all dependencies installed.
[!TIP] It's recommended to pick
<directory>as a directory in your world's datapacks directory. for example:%APPDATA%/.minecraft/saves/TestingWorld/datapacks/mypack
To generate your datapack files, use the following commands:
npm run build
This will run your main script (default to src/index.js) and generate the Minecraft function files in the appropriate output directory (e.g., data/<namespace>/function).
npm run watch
This will watch your src/ directory for changes and automatically rebuild your datapack whenever you save a file. This is useful for rapid development and iteration.
After running either command, you should see generated files in the data/ directory, ready to be used as a Minecraft datapack.
createMCF({ outputDir, functionCallPrefix })Initializes the generator.
outputDir (string): Output directory for generated files.functionCallPrefix (string): Prefix for function calls (e.g., 'mydatapack:').[!WARNING]
Calling this function will delete the directoryoutputDirand all its contents.
[!WARNING] Do not call this function twice with related
outputDiras it will override eachother.
mcf.functionName`...` {outputDir}/function_name.mcfunction.mcf.folder.functionName`...` {outputDir}/folder/function_name.mcfunction.mcf`...` {outputDir}/anonymous/anonymous_{i}.mcfunctionmcf.folder.anonymous`...` {outputDir}/folder/anonymous/anonymous_{i}.mcfunctionmcf[dynamicName]`...` Use dynamic names for functions or folders.
`${mcf.funcName}` or '' + mcf.funcName'function {functionCallPrefix}func_name'.[!TIP] mcjspacker will insert
:or/afterfunctionCallPrefixif needed
// ===== mcf.js =====
import { createMCF } from 'mcjspacker';
// if you want to have all functions generated
export const mcf = createMCF({
outputDir: 'data/mynamespace/function',
functionCallPrefix: 'mynamespace'
});
// if you want to have the generated functions in a folder
// ⚠️ do NOT call createMCF() with related folders as they will override eachother
export const mcfInAFolder = createMCF({
outputDir: 'data/mynamespace/function/generated',
functionCallPrefix: 'mynamespace:generated'
});
// ===== playerKit.js =====
import mcf from "./mcf.js";
const directory = mcf.playerKit;
// declare public functions
export const { giveStarterKit , giveAdvancedKit } = directory;
// declare private functions
const { equipArmor, anonymous: a } = directory;
/*
* declaring the functions help you refer to them in other functions
* and being free to order them as you want.
*
* It also automatically names the functions because:
* export const {foo, bar} = mcf.dir;
* is equvalent to:
* export const foo = mcf.dir.foo;
* export const bar = mcf.dir.bar;
*
*/
giveStarterKit`
${equipArmor}
give @s wooden_sword
`;
const xpForGoldApple = 100;
giveAdvancedKit`
${equipArmor}
give @s iron_sword
execute if score @s experience matches ${xpForGoldApple}.. run ${a`
give @s golden_apple
`}
`;
equipArmor`
item replace entity @s armor.chest with leather_chestplate
item replace entity @s armor.legs with leather_leggings
item replace entity @s armor.feet with leather_boots
item replace entity @s armor.head with leather_helmet
`;
// if you prefer, you can also define something like
const equip = (slot, item) => `item replace entity @s armor.${slot} with ${item}`;
a`
${equip('chest', 'leather_chestplate')}
${equip('legs', 'leather_leggings')}
${equip('feet', 'leather_boots')}
${equip('head', 'leather_helmet')}
`;
const players = ['Steve', 'Alex'];
for (const player of players) {
mcf[`greet_${player.toLowerCase()}`]`
say Hello, ${player}!
`;
}
const {rec} = mcf.folder;
rec`
scoreboard players add @s example 1
say hello
execute if score @s example matches ..10 run ${rec}
`;
const items = [
{ name: 'platform', model: 'redstone_block' },
{ name: 'slime_block', model: 'slime_block' }
];
// for each item define 'give @s ...'
const functions = items.map(({ name, model }) => mcf[`give_${name}`]`
give @s item_frame{item_name:'${name}',model:'${model}'}
`);
// call all of the functions
mcf.giveAll`
${functions.join('\n')}
`;
Contributions are welcome! Please open issues or pull requests for bugs, features, or questions.
MIT
FAQs
A library to build Minecraft datapacks in JavaScript.
The npm package mcjspacker receives a total of 0 weekly downloads. As such, mcjspacker popularity was classified as not popular.
We found that mcjspacker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.