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

unborn-mcproto

v0.13.0

Published

A small Minecraft protocol implementation designed for proxies. Forked from mcproto.

Downloads

154

Readme

Unborn Minecraft Protocol

npm downloads license

unborn-mcproto builds on mcproto, a small and lightweight implementation of the Minecraft protocol. It is designed for Hypixel 1.8.9 proxies and features PrismarineJS tools and functional niceties for deserializing and serializing packets in a proxy context with tight integration.

If you're looking for a Hypixel proxy, I highly recommend Lilith.

Features

  • Prismarine NBT
  • Tools for reading rest buffers, optional properties, simple arrays, and arrays of objects in a functional way

Examples

Server list ping

const { Client, PacketWriter, State } = require("unborn-mcproto")

const host = "play.hivemc.com", port = 25565

const client = await Client.connect(host, port)

client.send(new PacketWriter(0x0).writeVarInt(404)
    .writeString(host).writeUInt16(port)
    .writeVarInt(State.Status))

client.send(new PacketWriter(0x0))

const response = await client.nextPacket(0x0)
console.log(response.readJSON())

client.end()

Client

const { Client, PacketWriter, State } = require("unborn-mcproto")

const host = "localhost", port = 25565, username = "Notch"

const client = await Client.connect(host, port)

client.send(new PacketWriter(0x0).writeVarInt(340)
    .writeString(host).writeUInt16(port).writeVarInt(State.Login))

// Send login start
client.send(new PacketWriter(0x0).writeString(username))

const listener = client.onPacket(0x0, packet => {
    console.log(packet.readJSON())
})

// The server can request encryption and compression which will be handled
// in the background, so just wait until login success.
await client.nextPacket(0x2, false)
listener.dispose()

client.on("packet", packet => {
    if (packet.id == 0xf) console.log(packet.readJSON())
})

// Send chat message
client.send(new PacketWriter(0x2).writeString("Hello"))

For online servers, you must specify an accessToken and profile ID:

Client.connect("localhost", 25565, {
    profile: "<id>", accessToken: "<token>"
})

More examples can be found in the repository's examples folder.

Events and errors

mcproto uses it's own tiny event emitter class and provides different methods to handle packet, socket and error events.

Since a lot of the API is promise based, errors that happen during the lifetime a promise will result in the promise being rejected.

Errors that happen outside of async method calls should be handled with a error event handler on the connection instance.

const listener = client.on("error", console.error)

// listeners can be removed with:
listener.dispose()
// or
client.off("error", console.error)

The server class does allow to return a Promise in the client handler and it will forward errors to the server's event emitter.

const server = new Server(async client => {
    // errors thrown inside here won't cause a crash but might
    // show warnings if not handled.
    throw "error"
})
server.on("error", console.error)
server.listen()
client.on("packet", packet => {
    // make sure to catch errors inside event handlers
})

For details about packets and general information about the protocol, https://wiki.vg/Protocol is a great reference.

Other Projects

  • Lilith. An easy to use Hypixel proxy for the general public that will soon use unborn-mcproto

  • prismarine-proxy. A higher level, generalized alternative library. Provides Protodef for much easier packet parsing.

  • minecraft-proxy-handler. An alternative to prismarine-proxy with less documentation.

  • prismarine-chat. A parser for a minecraft chat message

  • prismarine-nbt. Converts chat components into raw / ansi formatted text.