Pumpkin-MC/Pumpkin · error
Cannot construct CrafterCraftEvent from WASM
Error message
Cannot construct CrafterCraftEvent from WASM
What it means
`from_wasm_event` for CrafterCraftEvent unconditionally panics when it receives an Event::CrafterCraftEvent. This impl exists only to satisfy the trait; the crate deliberately forbids a plugin from *returning* a CrafterCraftEvent to the host (the event flows host->plugin only). Hitting this means a WASM plugin handed a CrafterCraftEvent back across the boundary.
Solutions
- Fix the plugin so it never returns the CrafterCraftEvent it received; consume it and return the expected value instead.
- Check the plugin's generated bindings for a wrong return type on the event handler method.
- Update the plugin SDK to match the host's WIT version so the handler's return type is correct.
- If you need the host to observe the event, use the cancellation/data-mutation API rather than returning the event.
Example fix
// plugin side, before
fn on_craft(event: CrafterCraftEvent) -> Event { Event::CrafterCraftEvent(event) }
// after
fn on_craft(event: CrafterCraftEvent) -> Event { let _ = event; /* handle, don't re-emit */ }
Defensive patterns
Strategy: validation
Validate before calling
// plugin side: never return the event object you received assert!(!matches!(return_value, Some(Event::CrafterCraftEvent(_))), "do not return CrafterCraftEvent to host");
Type guard
// host-side narrowing before calling from_wasm_event
fn is_crafter_event(e: &Event) -> bool { matches!(e, Event::CrafterCraftEvent(_)) } Prevention
- Treat host->plugin events as consume-only; use cancellation/mutation APIs, not returns.
- Regenerate bindings whenever the WIT version changes.
- Review generated bindings' handler return types after SDK upgrades.
When it happens
Trigger: A plugin method whose WIT signature allows returning an Event returns Event::CrafterCraftEvent, and the host calls ToFromWasmEvent::from_wasm_event on it.
Common situations: A plugin (or generated bindings) misusing the event API by echoing/re-emitting the event object it received; a plugin language binding that constructs the wrong direction of event.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot construct EntityBlockFormEvent from WASM
- Cannot construct BlockReceiveGameEvent from WASM
- failed to add item stack resource
- Cannot construct BlockShearEntityEvent from WASM
- unexpected event type
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/6e7e2bceb033629e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/block.rs:1180
.expect("failed to add item stack resource");
Event::CrafterCraftEvent(CrafterCraftEventData {
block_pos: to_wasm_block_position(self.block_pos),
target_world,
result,
cancelled: self.cancelled,
})
}
fn apply_wasm_event(&mut self, event: Event, state: &mut PluginHostState) {
cleanup_event(&event, state);
if let Event::CrafterCraftEvent(data) = event {
self.cancelled = data.cancelled;
}
}
fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {
match event {
Event::CrafterCraftEvent(_) => panic!("Cannot construct CrafterCraftEvent from WASM"),
_ => panic!("unexpected event type"),
}
}
}
impl ToFromWasmEvent for EntityBlockFormEvent {
fn to_wasm_event(&self, state: &mut PluginHostState) -> Event {
let target_world = state
.add_world(self.world.clone())
.expect("failed to add world resource");
Event::EntityBlockFormEvent(EntityBlockFormEventData {
entity_id: self.entity.get_entity().entity_id,
block_pos: to_wasm_block_position(self.block_pos),
target_world,
new_state_id: self.new_state_id.as_u16(),
cancelled: self.cancelled,
})
}View on GitHub (pinned to 8d4639e25a)