Pumpkin-MC/Pumpkin · critical
failed to add player resource
Error message
failed to add player resource
What it means
An `.expect("failed to add player resource")` in BlockMultiPlaceEvent::to_wasm_event. When converting the native event to its WASM representation, the player's Arc reference must be registered in PluginHostState's resource table; add_player returned None/Err, so the conversion aborts.
Solutions
- Ensure the player entity is still alive/valid when the event fires
- Inspect PluginHostState::add_player for why insertion failed
- Update server if this occurs during normal gameplay (likely a host-state bug)
- Avoid dispatching this event to WASM plugins for despawned players
Defensive patterns
Strategy: validation
Validate before calling
// guard before dispatching to WASM
if !player.is_alive() || player.is_removed() { skip_wasm_dispatch(event); } Prevention
- Only dispatch events for live players to WASM plugins
- Check resource-table insertion errors instead of expect in host code
- Test event dispatch during player disconnect/teardown scenarios
When it happens
Trigger: Serializing a BlockMultiPlaceEvent for a WASM plugin when the player resource cannot be inserted into the host state table (e.g. player already freed or table in a bad state).
Common situations: Firing a multi-block-place event during teardown or for an already-removed player; resource-table exhaustion or state bug in the WASM host.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- failed to add world resource
- failed to add text-component resource
- Cannot construct BlockFertilizeEvent from WASM
- unexpected event type
- Cannot construct BlockMultiPlaceEvent from WASM
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/7d570939ed853098.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/block.rs:915
self.cancelled = data.cancelled;
}
}
fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {
match event {
Event::BlockFertilizeEvent(_) => {
panic!("Cannot construct BlockFertilizeEvent from WASM")
}
_ => panic!("unexpected event type"),
}
}
}
impl ToFromWasmEvent for BlockMultiPlaceEvent {
fn to_wasm_event(&self, state: &mut PluginHostState) -> Event {
let player = state
.add_player(self.player.clone())
.expect("failed to add player resource");
let target_world = state
.add_world(self.world.clone())
.expect("failed to add world resource");
let placed_blocks = self
.placed_blocks
.iter()
.map(|(pos, id)| (to_wasm_block_position(*pos), id.as_u16()))
.collect();
Event::BlockMultiPlaceEvent(BlockMultiPlaceEventData {
player,
target_world,
placed_blocks,
cancelled: self.cancelled,
})
}
fn apply_wasm_event(&mut self, event: Event, state: &mut PluginHostState) {
cleanup_event(&event, state);View on GitHub (pinned to 8d4639e25a)