Implements the vanilla /debug start and /debug stop commands (tracked in #15):
- /debug start opens one server-wide tick profiling session and rejects duplicate starts.
- /debug stop reports elapsed seconds, processed ticks, and average TPS, then returns the floored average TPS.
- Profiling state handles tick counter wraparound and can be restarted after a completed session.
- Registers minecraft:command.debug at operator permission level 3 and uses the existing Java and Bedrock translation keys.
/debug function is intentionally out of scope because Pumpkin does not yet have the required function runtime.
Every trait method wasmtime's bindgen! generates must be `async fn`
regardless of whether a given implementation needs to await anything,
so clippy::unused_async_trait_impl fired 578 times across the WASM
plugin bridge (crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1)
plus a handful of similarly-shaped trait impls elsewhere (redstone
pressure plates, several plant blocks, the pathfinder, three Entity
setter methods). This blocks "Run lints (debug/release)" CI on every
branch regardless of what it actually changes.
Allow the lint at the module level for wasm_host's submodules (one
attribute per module covers every impl inside it) and per-function for
the scattered non-WASM occurrences, rather than restructuring any of
the affected code.
Also fixes three unrelated pre-existing lint failures uncovered once
the above stopped masking them:
- pumpkin-macros::count_placeholders needed to be a const fn
(clippy::missing_const_for_fn) - this alone was blocking every other
lint check from ever running, since pumpkin-macros failing to
compile takes the whole workspace down with it.
- `Result<_, ()>` in Plugin::send_message (clippy::result_unit_err).
- `.ok().is_some_and(..)` that clippy::manual_is_variant_and wants as
`.is_ok_and(..)`.
Verified with `cargo clippy --all-targets --all-features` (debug and
release) and `cargo test -p pumpkin --lib` (257 passed).
* feat(command): add /locate structure
Implements /locate structure <name> on top of the existing
find_nearest_structure infrastructure (already used by eyes of ender),
with tab-completion for the known structure sets and vanilla-style
clickable [x, ~, z] teleport coordinates plus horizontal distance in
the success message.
Notes:
- Structure names refer to the generator's structure sets (villages,
desert_pyramids, ...), optionally prefixed with minecraft:.
- Like the ender-eye path, stronghold (concentric-rings) lookups depend
on the global structure cache being populated.
Closes#2230
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor(command): derive locate suggestions from generated StructureSet::NAMES
Addresses review feedback: the structure set names are now emitted by
pumpkin-codegen alongside StructureSet::ALL instead of being hard coded
in the locate command.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(command): add /locate biome and /locate poi, use ResourceOrTag arguments
Addresses review feedback on the /locate PR:
- New ResourceOrTagKeyArgument / ResourceOrTagArgument types mirroring
vanilla's argument pair: both parse `id` or `#tag`, the latter also
validates against the generated registry/tag data at parse time and
raises vanilla's argument.resource(_tag).not_found errors.
/locate structure now uses them instead of StringArgument.
- /locate biome: vanilla-parity spiral search (6400 block radius, 32
block horizontal / 64 block vertical steps) over the dimension's noise
biome source via the new find_closest_biome_3d in pumpkin-world,
including the possibleBiomes short-circuit (walked from the BiomeTree)
and superflat support. Runs on a blocking thread, reports the 3D
distance and absolute-y clickable coordinates, and appends the
concretely found biome for tag searches ("#minecraft:is_forest
(minecraft:forest)"), all like vanilla.
- /locate poi: searches the world's POI storage within 256 blocks via
the new PoiStorage::find_closest_matching (chebyshev gather, closest
by 3D distance, like PoiManager.findClosestWithType), with tag
support from the generated point_of_interest_type tag data.
- Suggestion matching now also treats ':' as a word separator so that
e.g. "vil" completes to "minecraft:villages".
Notes / limitations:
- There is no generated structure tag or POI type registry data yet, so
structure "#tags" resolve to the invalid-structure error and POI ids
are accepted leniently (unknown ones simply report not-found); only
nether portal POIs are currently recorded by the server.
Closes#2230
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor(command): run structure search off the async executor, drop panic on join errors
Review follow-ups on the /locate PR:
- /locate structure now runs its search on spawn_blocking like the
biome search does; scanning up to 100 regions of placement data is
just as CPU-bound as the biome spiral.
- Blocking-task join errors (panic/cancellation) are mapped to a
"search failed" command error instead of panicking the command task
via .expect.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* chore(command): adapt /locate to upstream API changes
Rebasing onto master picked up three signature changes: WorldGenerator
gained a Custom variant for plugin generators, BIOME_REGISTRY became a
reference, and Level::world_gen is now an ArcSwap.
Plugin generators only expose biomes by generating a whole chunk, so
/locate biome reports no match for them rather than pretending to
search.
* fix(command): report structures /locate can actually find
/locate structure returned the placement grid's candidate chunk without
checking whether a structure grows there. Candidates are only possible
sites: the biome at one can reject every structure in the set, so the
command happily pointed at empty terrain.
Resolve the structure start for random-spread sets instead, over every
structure the set contains, which is what explorer maps already do.
Strongholds keep using the ring cache, whose positions are real and
which the start lookup does not handle.
Co-authored-by: Mcxiaocaibug <Mcxiaocaibug@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
`TNTEntity` claimed to be immune to explosions, and `damage_entities` drops
immune entities before it gets anywhere near the knockback, so a chained TNT
never got the outward kick. Vanilla's TNT entity does not override
`ignoreExplosion`. The TNT case for the knockback origin in `damage_entities`
was unreachable until now.
`tick` also snapshotted velocity before moving and wrote back from that stale
value, so a push landing during the awaits was thrown away. Entities tick
concurrently, so this happened often enough to matter. It reads the velocity
back after `move_entity` now, like vanilla.
Nothing bounds the handshake, status and login phase. Once a player is in
game, progress_player_packets keeps the connection honest with keep-alives,
but there is no equivalent before that, and accepted sockets only get
set_nodelay, so there is no TCP keep-alive either. A peer that stops talking
without closing holds its descriptor until the process exits.
get_packet now gives up after 30s of silence. The timer is reset on every
packet rather than bounding the whole handshake, so a slow but progressing
login is never cut off.
Closes#2627
* fix: persist item data components dropped on save
`DataComponentImpl::write_data` defaults to returning `NbtTag::End`, so any
component relying on that default serialized to nothing. `write_item_stack`
walks the component patch and calls `write_data` on every entry, which meant
those components were silently dropped whenever an item stack was written to
NBT (chests, player inventories, chunk saves). Most of them already had a
deserializer, so the data just vanished on the next save/load.
Implement `write_data` for the data-carrying components that were missing it:
MaxDamage, Enchantable, Food, Tool, BlockEntityData, Container and
BundleContents. For the ones without a deserializer yet (MaxDamage,
Enchantable, Food, Tool) add the matching `read_data` and register them in the
`read_data` dispatcher so they round-trip through write_item_stack/
read_item_stack. The output follows the vanilla NBT shape for each component.
Add round-trip tests for the scalar and compound cases.
* test: use the assert_round_trip helper