npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@throw-out-error/minecraft-datapack

v1.6.18

Published

A module for making minecraft datapacks with node to cut down on the repetition.

Downloads

8

Readme

What is it?

minecraft-datapack is a module for making minecraft datapcks with node to cut down on repitition
npm version

Examples

Simple datapack

const { Datapack, Namespace } = require('minecraft-datapack')
const myDatapack = new Datapack('My datapack', __dirname, {
  description: 'my cool datapack!',
})
// You can use addNamespace to add a precreated namespace
let namespace = new Namespace('namespace')
myDatapack.addNamespace(namespace)
// Or you can use createNamespace to create and add a namespace
myDatapack.createNamespace('namespace2')
// And you can delete them with deleteNamespace
myDatapack.deleteNamespace('namespace2')
// Use the compile method of the datapack class to output the files
myDatapack.compile()

Adding tags

const { Datapack } = require('minecraft-datapack')
const datapack = new Datapack('ree', __dirname, { description: 'REE!' })
// Creates a block tag called minecraft:beacon_base_blocks, with the values ["minecraft:dirt"]
datapack.minecraft.createTag('beacon_base_blocks', 'block', ['minecraft:dirt'])
datapack.compile()
// Now when you load this in your minecraft world you can have beacon pyramids made from dirt! :D

Adding smelting recipes

const {
  Datapack,
  recipes: { SmeltingRecipe },
} = require('minecraft-datapack')
const datapack = new Datapack('stone', __dirname, {
  description:
    'adds a recipe to convert diorite, granite, and andesite to stone',
})
let stone_conversion = datapack.createNamespace('stone_conversion')
stone_conversion.createTag('stone_variants', 'item', [
  'minecraft:diorite',
  'minecraft:andesite',
  'minecraft:granite',
])
// Add a recipe using the namespace class's addRecipe method
stone_conversion.addRecipe(
  new SmeltingRecipe('stone_conversion', {
    // The ingredient can be a tag or an item id eg. minecraft:dirt, if using a tag it must be pre-fixed with a #
    ingredient: '#stone_conversion:stone_variants',
    result: 'minecraft:stone',
    experience: 1,
    // Select which smelting block you want to use eg. a furnace, blast furnace, smoker, or camp fire
    type: 'minecraft:blasting',
  })
)
datapack.compile()
// When loaded in your minecraft world you can put granite, diorite, and andesite in a blast furnace to get stone :D

Adding crafting recipes

const {
  Datapack,
  recipes: { ShapedCraftingRecipe },
} = require('minecraft-datapack')
const datapack = new Datapack('Slab crafting', __dirname, {
  description: "Let's you make blocks from slabs",
})
let slabs = datapack.createNamespace('slabs')
slabs.addRecipe(
  new ShapedCraftingRecipe('oak_planks_from_slabs', {
    pattern: [
      //The pattern can be 1x1 2x2 or 3x3
      '#',
      '#',
      //The key tells minecraft what to replace each character in the strings with
    ],
    key: {
      '#': 'minecraft:oak_slab',
    },
    result: 'minecraft:oak_planks',
  })
)
datapack.compile()

Adding loot tables

const {
  Datapack,
  loot: { ItemEntry, LootFunction },
} = require('../module')
const randomCount = (min, max) =>
  new LootFunction({ function: 'minecraft:set_count', count: { min, max } })
const datapack = new Datapack('Dirt', __dirname, {
  description: 'adds a dirt loot table for dirt lovers!',
})
datapack
  .createNamespace('dirt')
  // create the loot table
  .createLootTable('dirt')
  // add a pool to the table
  .createPool({
    rolls: 1,
  })
  // add an item to the pool
  .addEntry(new ItemEntry({ name: 'minecraft:dirt' }))
  .addFunction(randomCount(1, 64))
datapack.compile()
// if you run /loot give @s dirt:dirt ingame you will get 1-64 dirt

Adding functions

Create a datapack containing a mcfunction called myfunction, which kills every entity except players.

const { Datapack } = require("@throw-out-error/minecraft-datapack");
const {
  McFunction,
  Selector,
  SelectorTarget,
  kill
} = require("@throw-out-error/minecraft-mcfunction");

const datapack = new Datapack("Functions", __dirname, {
  description:
    "A cool datapack that adds a really mind blowing function, /function crazy_function:1"
});

const ns = datapack.createNamespace("crazy_function");

ns.addFunction(
  new McFunction(function myfunction() {
    const notPlayer = new Selector(SelectorTarget.entity, {
      type: {
        player: false
      }
    });

    kill(notPlayer);
  })
);

datapack.compile(".");