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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mcfn.ts

v1.0.5

Published

This is a TypeScript library for building Minecraft function files, datapack, and resourcepack programmatically.

Readme

mcfn.ts

This is a TypeScript library for building Minecraft function files, datapack, and resourcepack programmatically.

Usage

Here is a simple example of how to use the library to create a Minecraft function file:

import { effect, execute, minecraft, objective, sel } from "mcfn.ts";

let kill_count = objective('minecraft.killed:minecraft.zombie')
let death_count = objective('deathCount')
let rage_level = objective('dummy')

minecraft.tick(() => {
    execute.as(sel('@a')).at(sel('@s')).run(() => {
        let self = sel('@s')
        let player_kill_count = kill_count.get(self)
        let player_death_count = death_count.get(self)
        let player_rage_level = rage_level.get(self)
        execute.if(player_death_count.ge(1)).run(() => {
            player_death_count.reset()
            player_rage_level.reset()
        })
        execute.if(player_kill_count.ge(1)).run(() => {
            player_kill_count.reset()
            execute.if(player_rage_level.lt(200)).run(() => {
                player_rage_level.addby(1)
            }, true)
        })
        for (let i = 1; i <= 200; i++) {
            execute.if(player_rage_level.eq(i)).run(() => {
                effect.give(self, 'strength', 1, i - 1)
            }, true)
        }
        
    })
})

This code is "Minecraft, but killing zombies makes you stronger, until you die". The generated datapack contains five function files for /execute forking, and 200 more lines in the function that gives player strength effect based on rage levels. All of these are generated from this single TypeScript file, which performs better organization and maintainability.

you can see more examples here: mcfn-ts

Installation

You can install the library via npm:

npm i mcfn.ts

Configuration

Before using the library, you need to configure the datapack and resourcepack settings in the mcfn.json file:

{
    "namespace": "example",
    "datapack": {
        "mcmeta": {
            "pack": {
                "description": "Example Datapack",
                "pack_format": 88
            }
        },
        "outdir": "out/datapack",
        "icon": "pack.png"
    },
    "resourcepack": {
        "mcmeta": {
            "pack": {
                "description": "Example Resource Pack",
                "pack_format": 69
            }
        },
        "outdir": "out/resourcepack",
        "icon": "pack.png"
    }
}
  • namespace: The namespace for your datapack functions.
  • datapack: Configuration for the datapack, including mcmeta, outdir, and icon.
  • resourcepack: Configuration for the resourcepack, including mcmeta, outdir, and icon.
  • mcmeta: Metadata for the pack, including description and pack format.
  • outdir: The output directory for the generated pack.
  • icon: Optional, the icon file for the pack.

Building the Packs

You can use ts-node to build the datapack and resourcepack:

npx ts-node ./main.ts

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

If you want to contribute the codebase, before pushing your changes, make sure to run the build script:

yarn build