dougbot/bridge/lib/mineflayer/lib/bedrockPlugins/rain.mts
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

22 lines
737 B
TypeScript

import type { BedrockBot } from '../../index.js';
export default function inject(bot: BedrockBot) {
bot.isRaining = false;
bot.thunderState = 0;
bot.rainState = 0;
bot._client.on('level_event', (packet) => {
if (packet.event === 'start_rain') {
bot.isRaining = true;
bot.emit('rain');
} else if (packet.event === 'stop_rain') {
bot.isRaining = false;
bot.emit('rain');
} else if (packet.event === 'start_thunder') {
bot.thunderState = 1; // this value requires checking against java
bot.emit('weatherUpdate');
} else if (packet.event === 'stop_thunder') {
bot.thunderState = 0; // this value requires checking against java
bot.emit('weatherUpdate');
}
});
}