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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simplified-mojang-api

v0.0.37

Published

About Public repository to simplify the event logic of Mojang's Script API, for informal or professional use

Readme

🛠️ Simplified Mojang API

[!WARNING] ⚠️ WORK IN PROGRESS! ⚠️ This repository is constantly evolving and undergoing active updates, so some features or simplified methods may be missing or not yet implemented. Please keep this in mind when using it!

A simple tool that makes it easier to use the Mojang scripting API for Minecraft Bedrock, by providing pre-built and simplified classes.

What is this?

It's an informal or professional repository designed to simplify the logic of the native @minecraft/server module by integrating various pre-built classes and methods to save time and reduce code, as well as tools I've customized myself for use in any add-on.

Install:

Just run this in your terminal:

npm install simplified-mojang-api@latest (In case of errors, use --force)

(Make sure you also have the base @minecraft/server stuff installed!)

Build Setup:

If you are new to TypeScript and Minecraft Add-on development, don't panic! Minecraft only reads .js files, so we need to "compile" or "bundle" our .ts files into a single JavaScript file. We use esbuild for this because it's incredibly fast.

Here is the step-by-step guide to setting up your compiler:

1. Install the Bundler

First, you need to install esbuild as a development dependency in your project. Run this in your terminal:

npm install --save-dev esbuild

2. Prepare your Folder Structure

Make sure your behavior pack looks something like this:

📦 behaviors/YOUR_ADDON/
 ┣ 📂 scripts/      (This will be auto-generated by the compiler)
 ┣ 📂 src/
 ┃ ┗ 📜 main.ts     (You write your TypeScript code here)
 ┗ 📜 manifest.json

3. Update your package.json

Open your package.json file and replace or add the "scripts" section with these commands. You will need to replace YOUR_ADDON with the actual folder name of your behavior pack:

  "scripts": {
    "copy:api-assets": "node -e \"const fs = require('fs'); const src = 'node_modules/simplified-mojang-api/structures'; if (fs.existsSync(src)) fs.cpSync(src, 'behaviors/YOUR_ADDON/structures', { recursive: true, force: false });\"",
    "compile": "npm run copy:api-assets && esbuild behaviors/YOUR_ADDON/src/main.ts --bundle --format=esm --outfile=behaviors/YOUR_ADDON/scripts/main.js --target=es2020 --external:@minecraft/server --external:@minecraft/server-ui --external:@minecraft/server-gametest --external:@minecraft/server-graphics --external:@minecraft/server-net --external:@minecraft/debug-utilities --external:@minecraft/gameplay-utilities --sourcemap",
    "watch": "npm run compile -- --watch"
  }

4. Run

Now you are ready to compile! Open your terminal and use one of these commands:

  • To compile once: (Do this before publishing your add-on)
npm run compile
  • To auto-compile (Recommended): (Run this while you are coding. It will stay open and automatically re-compile every time you save a file!)
npm run watch

Available Modules

The API is split up into several handy modules to fit whatever your development workflow needs. Here is what's currently available out of the box:

[!NOTE] The wrapped @minecraft/... modules might not have every single vanilla event fully mapped out just yet. I'll be adding the rest and keeping things updated to make your dev experience as smooth as possible.

import { 
    afterEventsSimplified, 
    beforeEventsSimplified, 
    customEventsManager, 
    debugToolsSimplified, 
    fakePlysSimplified, 
    worldToolsSimplified 
} from "simplified-mojang-api";

Each module comes packed with different methods for your daily coding routine. Here's a quick rundown of what they do:

  • afterEventsSimplified: Wraps the main world.afterEvents methods. These fire off right after an action has already happened. Perfect for reading data or triggering logic after the fact.
  • beforeEventsSimplified: Wraps the main world.beforeEvents methods. These trigger right before the actual event takes place in the game. Super handy if you need to cancel an event entirely or tweak things before they go through.
  • customEventsManager: Packed with custom-built tools designed to streamline your workflow, cut down on boilerplate code, and give you robust tools to handle pretty much any scenario.
  • debugToolsSimplified: Custom and simplified wrappers for the debug-utilities module to make visual debugging a lot easier for developers.
  • fakePlysSimplified: Clever wrappers for the server-gametest module to make spawning and managing simulated entities/players a breeze. Mostly focused on helping you test multiplayer features solo with fake players.
  • worldToolsSimplified: Your go-to toolbox for server.world and server.system. It brings cleaner shortcuts and universal tools for everyday tasks, making your coding loop way faster and straightforward.

API Examples:

Fast Offhand Items

Make items jump to the offhand with a single click.

import { customEventsManager } from "simplified-mojang-api";

// Any item with these words in its ID becomes a fast-equip item
customEventsManager.fastItemsSystem(["totem", "shield", "arrow"]);

Visual Debugging (Hitboxes)

Easily show visual hitboxes for all nearby entities using the debug module. Great for testing custom mob sizes or attack ranges!

import { debugToolsSimplified } from "simplified-mojang-api";

// Shows hitboxes to the specific player within a 50 block radius
debugToolsSimplified.showHitboxes(player, 50);

// Turn them off when you're done testing
// debugToolsSimplified.stopHitboxes();

Fake Player Spawner

Instantly spawn a simulated player into the world using the gametest API. Perfect for testing multiplayer mechanics solo.

import * as mc from "@minecraft/server";
import { fakePlysSimplified } from "simplified-mojang-api";

// Spawns a fake player named "Dummy" in Survival mode
fakePlysSimplified.createFakePly("Dummy", mc.GameMode.Survival);

Real-Time Timer

Creates a timer that's saved directly on the player and runs in real-time, no need to mess with scoreboard ticks! Set an initial value and you're good to go—super easy and fast to use.

import { customEventsManager } from "simplified-mojang-api";

const paramsTimer: CustomTimerParam = {
    sourcePly: player, // The player who gets the timer
    timerId: "ha:timer_unique", // Unique ID for the timer, just in case you run more than one
    initialMns: 2, // Starting minutes for the timer, or the minutes to display
    forceRestart: true, // (Optional) Need to update the time? E.g., new minutes or seconds? Set this to true to restart the timer.

    // (Optional) Events triggered every time a second goes by.
    onSecondPass: (ply, timer) => {
        console.log(`A second has passed! The timer now is ${timer}`);
    },
};

// Starts the timer for the player. HEADS UP: this is an under-the-hood timer so it's invisible by default. To show it on a UI, use events like onSecondPass.
customEventsManager.startTimerLocal(paramsTimer);

Contributing

Found a bug or want to wrap a new Mojang method? PRs are super welcome!

Author: HaJuegos License: MIT