Load JavaScript packages from books in chests on a Minecraft server.
This will create a headless Minecraft client, join the configured server, and open a chest to look for signed books.
Huge shoutout to the authors of minecraft-protocol and Prismarine. Their work
lets this simply stitch together some packages and patch a resolution quirk. 💙
in-game: Login to an offline mode Minecraft server (any version supported by
minecraft-data)in-game: Write your code in a book and quill
Note The first line of the first page should be a semver string
Note >
imported packages will be loaded relative to the last on-disk modulee.g. if
example.mjsimportsminecraft:helloer, anyimportinhelloerwill be loaded as if you were inexample.mjs.This could look something like:
in-game: Sign your book and quill with the package name as the title
in-game: Place your book, with any others, in a chest
- This chest must be close enough to the configured player that it can open the chest without moving. This is 5 blocks away on an unmodified server. Keep in mind spawn protection prevents non OP-ed players from opening a chest (I forgot this and spent hours trying to fix the code 😅).
Configure your shell's environment with the correct variables following
.env.example.Put together a consuming script locally (see
example.mjs)// example.mjsimport*ashelloerfrom'minecraft:helloer';console.log(helloer);console.log(helloer.getWelcome('Cooper'));console.log(helloer.getDatedWelcome('Cooper'));
Run script with the
--loaderflag$ node --loader ./dist/loader.mjs example.mjs[Module: null prototype] {getDatedWelcome: [Function: getDatedWelcome],getWelcome: [Function: getWelcome]}Hi, CooperWelcome to 2023, Cooper!
- Enforce read and write policies with iron doors and a redstone lock!
- Signed books are immutable and traceable by default!
- Genuine team building built right into the release process!
- npm compatible registry so the consumer doesn't need any non-standard dependencies
- Support teleporting the player (issue server command) so spawn location isn't a big deal





