fix(examples): 修正 random_quests 示範的迴圈與跳躍節奏 - #70
Merged
Merged
Conversation
- v0.4.10 was tagged while pyproject.toml still declared 0.4.9, so uv build produced 0.4.9 artifacts and PyPI rejected them with "File already exists" - add a guard right after the on-main check so the mismatch is caught in seconds instead of after tests, build and a failed upload - read the version with tomllib rather than grep so the check does not depend on the field's formatting - deliberately not using skip-existing: it would have hidden this mismatch and silently published nothing
- the v0.4.10 tag already exists on origin and points at main HEAD, but the packaged version was never bumped
…-data skew
mineflayer 4.37.0 gates the 1.21.2+ nested velocity shape of
entity_velocity behind supportFeature('entityVelocityIsLpVec3'), a
feature the minecraft-data it installs against (<= 3.110.x) never
shipped. The legacy branch then reads packet.velocityX (undefined on
1.21.2+), fromNotchVelocity turns Vec3(undefined) into NaN on
entity.velocity, and the first hit the bot takes lets the physics tick
integrate NaN into bot.entity.position. JSPyBridge serializes NaN as
null, so every position read in Python becomes None and a student's
move_forward() dies with "float() ... not 'NoneType'" the moment a
player lands a punch.
- install a node-side entity_velocity listener via eval_js at
create_bot that re-parses the nested shape (packet.velocity / 8000
per axis); zero bridge traffic per packet, no-op on flat velocityX
packets and on healthy minecraft-data pairings
- unit-test the Python wiring: missing-client warn path, eval/install
handshake, create_bot call site
- add an integration test that runs the JS against a real node
EventEmitter (needs node only, no Minecraft server)
- document the repair and its removal condition in AGENTS.md
Upstream has since fixed the pairing (minecraft-data master carries the
feature, mineflayer master dropped the gate), so the repair becomes
removable once the bundled mineflayer pin moves past 4.37.x; it stays
harmless if left in. Verified live against the camp server: spawn,
get_pos and move_forward all work with the repair installed.
- README 的「進度跨重連累積」寫反了:基準是登入那一刻抓的,重跑程式=斷線重連 =基準重抓,做到一半的進度會歸零,所以一次執行就要做滿門檻 - 因此拿掉 t03/t04/t05/t06 的 while True,一次做完就結束 - t03/t13 補 bot.wait(0.5):bot.jump() 按完鍵就返回、不等落地,而跳躍鍵只在 站在地上時有作用,連續呼叫約有一半是在半空中按的,十次只跳得出約五下 - t09 轉向同理補 bot.wait(0.6) - t05/t08/t14/t15 的密文改成佔位字串,並補上解密迴圈與 print,讓學員自己判讀
Greptile SummaryThe PR adds the random bonus-quest examples and corrects their pacing and per-session instructions while also bringing
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code failure established. The velocity repair preserves legacy packets and repairs the current nested packet shape synchronously, while the quest timing and editable placeholders align with the documented instructional workflow.
|
| Filename | Overview |
|---|---|
| src/minethon/_bot_runtime.py | Adds a guarded Node-side nested-velocity packet repair during bot initialization; no actionable defect was established. |
| tests/integration/test_velocity_repair_js.py | Exercises nested, legacy, and unknown-entity packet cases using a fixed, non-shell subprocess invocation. |
| examples/quests/random_quests/README.md | Documents reconnect-reset behavior, required pacing, and intentional per-round ciphertext placeholders. |
| examples/quests/random_quests/t03_jump/main.py | Spaces jump commands so each requested jump can occur after landing. |
| examples/quests/random_quests/t09_spin/main.py | Spaces quarter-turn commands to make server-observed rotation progression reliable. |
| examples/quests/random_quests/t13_nest/main.py | Adds landing time between jumps in the nested jump-and-turn sequence. |
| .github/workflows/publish.yml | Prevents publishing when the release tag and project version disagree. |
| pyproject.toml | Advances package metadata from version 0.4.9 to 0.4.11. |
Sequence Diagram
sequenceDiagram
participant Server as Minecraft server
participant Client as Mineflayer client
participant Repair as Velocity repair listener
participant Physics as Mineflayer physics
participant Python as Minethon script
Server->>Client: entity_velocity packet
Client->>Client: Existing handler parses packet
Client->>Repair: Same synchronous EventEmitter dispatch
Repair->>Client: Restore velocity from nested x/y/z
Physics->>Client: Integrate repaired velocity
Python->>Client: Read valid position
Reviews (1): Last reviewed commit: "fix(examples): 修正 random_quests 示範的迴圈與跳躍..." | Re-trigger Greptile
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.
這個 PR 做什麼
修正
examples/quests/random_quests/十五題參考解答裡三類會讓學員實際跑不出結果的問題:while True。 既然進度不累積,迴圈只是重複送出同一件事。bot.wait(0.5)。bot.jump()按完鍵就返回、不等落地(一次跳躍約 0.6 秒),而跳躍鍵只在站在地上時有作用 —— 連續呼叫大約有一半是在半空中按的,for i in range(10)只跳得出約五下,門檻十下永遠達不到。t09 的轉向同理補bot.wait(0.6)。print,讓學員自己判讀後再bot.chat送答案。驗證
只動
examples/,沒有碰src/,不影響 stub / lint / type-check 範圍。跳躍節奏那條是實機觀察(十次呼叫只跳出約五下)得到的結論。🤖 Generated with Claude Code