Repository navigation
Conversation
lib/core/health.js holds health and respawn handling as a plain step(state, event) -> outputs state machine with no IO. lib/plugins/health.js becomes a thin adapter that feeds it packets and API calls and keeps bot.health, bot.food, bot.foodSaturation, bot.isAlive, bot.respawn() and the spawn/health/death/respawn events as before. Adds test/healthCoreTest.js (server-free, per tested version) and lib/core/README.md describing the pattern for converting more plugins.
u9g
force-pushed
the
health-sans-io-core
branch
from
October 5, 2026 17:37
dadd1d1 to
8980372
Compare
lib/core/healthCodec.js now holds every version difference in packet names and fields: it decodes update_health and respawn into core events and encodes the core's clientLoaded and requestRespawn outputs into packets. The core becomes step(config, state, event) with no version data, and config (auto-respawn) is kept apart from the changing state. Core tests run once instead of per version. Codec tests write each packet with the version's real schema via minecraft-protocol and parse it back, so a wrong field name fails against the protocol rather than against a value derived from the same feature flag.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the health plugin's logic into a sans-io core, in two layers:
lib/core/health.js:step(config, state, event) -> outputs, with no IO and no packet or version knowledge.lib/core/healthCodec.js: per version, decodesupdate_healthandrespawninto core events and encodes the core's outputs intoplayer_loaded/client_command.lib/plugins/health.jsbecomes a thin adapter (vialib/core/driver.js) and keepsbot.health,bot.food,bot.foodSaturation,bot.isAlive,bot.respawn()and the spawn/health/death/respawn events as before.test/healthCoreTest.jsneeds no server: the core's tests run once, and the codec's tests run per tested version, writing each packet with that version's real schema (minecraft-protocol's serializer) and parsing it back, so a wrong field name fails against the protocol.lib/core/README.mddescribes the pattern for converting more plugins.