Add survival/creative modes, inventory, and robust mouse input#2
Conversation
Survival + creative gameplay loop (Luanti/VoxeLibre-flavoured): - Item registry (block items + food), 36-slot inventory with stacks & merge, drops, and per-seed save/load (localStorage) - Vitals: 20 HP (10 hearts), hunger/saturation/exhaustion, breath; fall & cactus damage, drowning, starvation, regen; death + respawn - Minetest-style inventory screen: backpack + shared hotbar, crafting placeholder, searchable creative palette, trash, Survival/Creative toggle (E to open) - Mining: instant in creative, timed hold-to-mine (with overlay) in survival; placing consumes a stack in survival, infinite in creative - Eating (hold right-click with food) - HUD: hearts/hunger/air bars, inventory-driven hotbar with counts Robust input (Firefox-friendly): - Cursor-aiming fallback via createPickingRay when pointer lock is unavailable; break/place also ride on click/auxclick/contextmenu (reliable in Firefox), not just mousedown - Pointer-lock error handling + try/catch around requestPointerLock - Steeper spawn pitch + reach 8 so a block is always targetable Debug logging gated behind `voxl.debug` localStorage flag (off by default).
📋 SummaryNo linked issues (e.g., 📌 Review Metadata
🔴 Critical IssuesNone identified.
|
| Principle | Score | Notes |
|---|---|---|
| Single Responsibility | 5 | Game.ts remains a large orchestrator handling rendering, input, inventory, survival systems, and UI state. |
| Open/Closed | 7 | New item/survival systems extend the block registry without reordering or mutating BLOCKS. |
| Liskov Substitution | 8 | Few inheritance hierarchies; no subtype violations observed. |
| Interface Segregation | 8 | Small, focused interfaces (ClickEdges, ItemStack, SerializedStats). |
| Dependency Inversion | 6 | Game depends on concrete classes (Inventory, PlayerState) rather than abstractions, which is acceptable for this prototype scope. |
| Average | 6.8 |
🎯 Final Assessment
Overall Confidence Score: 70%
How to interpret: 61-80%: Minor concerns, mostly ready with some fixes.
Confidence Breakdown:
- Code Quality: 75% (clean TypeScript, follows repo patterns, builds pass; some validation gaps)
- Completeness: 85% (covers all described Tier 1/2 features; crafting is intentionally placeholder)
- Risk Level: 60% (large surface area across input/game loop/UI, but no observed crashes)
- Test Coverage: 30% (no automated tests; relies on manual/build verification)
Merge Readiness:
- All critical issues resolved
- SOLID average score >= 6.0
- Overall confidence >= 60%
- No security concerns
- Tests present and passing (no test suite exists)
Verdict:
MERGE WITH FIXES
Address the water fall-damage bug and save-data validation before merging; the remaining issues are minor polish/UX items.
- [HIGH] Water now cushions falls: trackFall resets when inWater - [HIGH] Validate saved `mode` in loadSave; invalid values are dropped - [MED] Inventory.load skips unknown item ids and clamps counts to maxStack - [MED] Escape closes the inventory even when the search field has focus - [LOW] Remove unused HOTBAR_BLOCKS export - [LOW] Named block constants (WATER/CACTUS/MUSHROOM) replace magic ids - [LOW] Water is no longer breakable (punching fluids does nothing), and the unbreakable toast is now generic
📋 SummaryNo linked issues (e.g., 📌 Review Metadata
🔴 Critical Issues✅ All previously reported critical issues have been resolved.
|
- [MED] Hotbar wheel cycling now works in cursor-aiming mode (was gated on pointer lock); UI overlays still scroll naturally - [MED] Survival placement only consumes an item when setBlock reports a change (no more wasting blocks on no-op placements) - [LOW] loadSettings validates `mode`, falling back to the default - [LOW] Trash slot uses an inline SVG instead of an emoji (matches the SVG icon convention used for hearts/hunger/air)
📋 SummaryNo linked issues (e.g., 📌 Review Metadata
This PR adds a large, coherent survival/creative slice: item registry, inventory, player vitals, save/load, inventory UI, HUD bars, and a multi-event input fallback. The author has addressed every issue raised in the two prior automated review rounds. One new functional issue remains in the input layer, plus a few minor robustness/cleanup items. 🔴 Critical Issues✅ All previously reported critical issues have been resolved.
|

Summary
Adds a full survival + creative gameplay loop with an inventory system, plus a Firefox-robust input layer. Built to Luanti/VoxeLibre conventions (per the task).
Gameplay (Tier 1+2)
src/game/Items.ts): every block becomes a placeable item (b<id>) plus food items; drop table (grass→dirt, leaves/ice→nothing), per-block dig times,GameMode.src/game/Inventory.ts): 36 slots (9 hotbar + 27 backpack), stacks + merge, JSON serialize.src/game/PlayerState.ts): 20 HP (10 hearts), hunger/saturation/exhaustion (overflow @4000), breath (10); fall & cactus damage, drowning, starvation, regen; death + respawn. Fall damage from a real fall-distance tracker.src/ui/InventoryUI.ts): backpack + shared hotbar, crafting placeholder, searchable creative palette, trash slot, and a Survival/Creative toggle (pressE).src/state/SaveData.ts): inventory + vitals persist in localStorage keyed by seed.Mining / placing / eating
HUD (
src/ui/HUD.ts+ui.css)Robust input (
src/engine/Input.ts,src/game/Player.ts)scene.createPickingRaywhen pointer lock is unavailable, so the game is playable without mouse-look.click/auxclick/contextmenu(which fire reliably in Firefox even whenmousedownflakes during pointer-lock transitions) — not justmousedown.requestPointerLockwrapped intry/catch;pointerlockerrorsurfaced as a toast.REACH 8so a block is always within targeting range.Other
src/state/Debug.ts) gated behindlocalStorage.voxl.debug— off by default, enable withlocalStorage.setItem("voxl.debug","1").Verification
bunx tsc --noEmitpassesvite buildbundles clean (game + website sync)Notes / follow-ups
README.md/AGENTS.mdstill reference Three.js (stale from the Babylon migration) — left untouched here.Controls
Einventory + mode toggle · holdL-clickmine ·R-clickplace · holdR-click(food) eat ·1–9/scroll/Fhotbar · double-tapSpacefly (creative).