dougbot/bridge/lib/prismarine-registry/README.md
roberts 8f616598fd Fix chat, brain stability, MariaDB reconnect, suppress warnings
- Listen on raw 'text' packet for Bedrock chat (pattern-based chat event
  doesn't fire reliably on Bedrock)
- Brain: add safety reset for stuck pending_status flag
- MariaDB: add retry-on-disconnect for all query methods
- Suppress harmless punycode deprecation warning from Node.js
- Add mineflayer-bedrock lib packages (mineflayer, prismarine-chunk,
  prismarine-registry) for movement support
- Exclude minecraft-data from git (278MB, installed via npm)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 12:33:17 -05:00

75 lines
No EOL
2.6 KiB
Markdown

# prismarine-registry
[![NPM version](https://img.shields.io/npm/v/prismarine-registry.svg)](http://npmjs.com/package/prismarine-registry)
[![Build Status](https://github.com/PrismarineJS/prismarine-registry/workflows/CI/badge.svg)](https://github.com/PrismarineJS/prismarine-registry/actions?query=workflow%3A%22CI%22)
[![Discord](https://img.shields.io/badge/chat-on%20discord-brightgreen.svg)](https://discord.gg/GsEFRM8)
[![Try it on gitpod](https://img.shields.io/badge/try-on%20gitpod-brightgreen.svg)](https://gitpod.io/#https://github.com/PrismarineJS/prismarine-registry)
Creates an dynamic instance of node-minecraft-data.
## Usage
```js
const registry = require('prismarine-registry')('1.18')
registry.blocksByName['stone'] // See information about stone
```
## API
[See minecraft-data API](https://github.com/PrismarineJS/node-minecraft-data/blob/master/doc/api.md)
### mcpc
#### loadDimensionCodec / writeDimensionCodec
* loads/writes data from dimension codec in login packet
#### .chatFormattingByName, .chatFormattingById (1.19+)
Contains mapping from chat type ID (numeric or string) to information about how the
chat type should be formatted and what the relevant parameters are.
```js
{
'minecraft:chat': { formatString: '<%s> %s', parameters: [ 'sender', 'content' ] },
'minecraft:say_command': { formatString: '[%s] %s', parameters: [ 'sender', 'content' ] },
'minecraft:msg_command': { formatString: '%s whispers to you: %s', parameters: [ 'sender', 'content' ] },
'minecraft:team_msg_command': { formatString: '%s <%s> %s', parameters: [ 'team_name', 'sender', 'content' ] },
'minecraft:emote_command': { formatString: '* %s %s', parameters: [ 'sender', 'content' ] }
}
```
#### .dimensionsById, dimensionsByName (1.19+)
Mapping to dimension data object containing dimension `name`, `minY` and `height`.
### mcpe
#### loadItemStates / writeItemStates
* loads/writes data from an item states array inside the bedrock start game packet.
```js
// In a client
const { createClient } = require('bedrock-protocol');
const registry = require('prismarine-registry')('bedrock_1.19.50');
const client = createClient({
'host': '127.0.0.1'
})
client.on('start_game', ({ itemstates, block_network_ids_are_hashes }) => {
registry.handleStartGame({ itemstates, block_network_ids_are_hashes});
})
client.on('item_registry', ({ itemstates }) => {
registry.handleStartGame({ itemstates });
})
// In a server
server.on('connect', (client) => {
const itemstates = registry.writeItemStates()
client.write('start_game', { ...startGamePacket, itemstates }) // version < 1.21.70
client.write('item_registry', { itemstates }) // version >= 1.21.70
})
```