- 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>
64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
import type { BedrockBot } from '../../index.js';
|
|
import { createRequire } from 'module';
|
|
const require = createRequire(import.meta.url);
|
|
|
|
export default function inject(bot: BedrockBot) {
|
|
const ScoreBoard = require('../scoreboard')(bot);
|
|
const scoreboards: Record<string, any> = {};
|
|
|
|
bot._client.on('set_display_objective', (packet) => {
|
|
//console.log(packet)
|
|
// const { name, position } = packet
|
|
// const scoreboard = scoreboards[name]
|
|
//
|
|
// if (scoreboard !== undefined) {
|
|
// bot.emit('scoreboardPosition', position, scoreboard, ScoreBoard.positions[position])
|
|
// ScoreBoard.positions[position] = scoreboard
|
|
// }
|
|
//
|
|
// if (packet.action === 0) {
|
|
// const { name } = packet
|
|
// const scoreboard = new ScoreBoard(packet)
|
|
// scoreboards[name] = scoreboard
|
|
//
|
|
// bot.emit('scoreboardCreated', scoreboard)
|
|
// }
|
|
//
|
|
// if (packet.action === 2) {
|
|
// scoreboards[packet.name].setTitle(packet.displayText)
|
|
// bot.emit('scoreboardTitleChanged', scoreboards[packet.name])
|
|
// }
|
|
});
|
|
|
|
bot._client.on('remove_objective', (packet) => {
|
|
//console.log(packet)
|
|
// bot.emit('scoreboardDeleted', scoreboards[packet.name])
|
|
// delete scoreboards[packet.name]
|
|
});
|
|
|
|
bot._client.on('set_score', (packet) => {
|
|
//console.log(packet)
|
|
// const scoreboard = scoreboards[packet.scoreName]
|
|
// if (scoreboard !== undefined && packet.action === 0) {
|
|
// const updated = scoreboard.add(packet.itemName, packet.value)
|
|
// bot.emit('scoreUpdated', scoreboard, updated)
|
|
// }
|
|
//
|
|
// if (packet.action === 1) {
|
|
// if (scoreboard !== undefined) {
|
|
// const removed = scoreboard.remove(packet.itemName)
|
|
// return bot.emit('scoreRemoved', scoreboard, removed)
|
|
// }
|
|
//
|
|
// for (const sb of Object.values(scoreboards)) {
|
|
// if (packet.itemName in sb.itemsMap) {
|
|
// const removed = sb.remove(packet.itemName)
|
|
// return bot.emit('scoreRemoved', sb, removed)
|
|
// }
|
|
// }
|
|
// }
|
|
});
|
|
|
|
bot.scoreboards = scoreboards;
|
|
bot.scoreboard = ScoreBoard.positions;
|
|
}
|