Pumpkin-MC/Pumpkin · error
unexpected event
Error message
unexpected event
What it means
This panic fires inside `data_from_event` for EntityDismountEvent when the incoming `Event` is not `Event::EntityDismountEvent`. The function exists to unwrap the generic `Event` enum into the concrete `EntityDismountEventData`; the catch-all arm treats any other variant as an impossible state, because the dispatcher contract guarantees only matching variants are delivered. Hitting it means event routing delivered a mismatched payload.
Solutions
- Verify the event is routed/dispatched as `Event::EntityDismountEvent` before reaching `data_from_event`
- In manual dispatch code, match on the variant yourself or check `event_type()` equals `EventType::EntityDismountEvent` first
- Align plugin-api versions across server and plugin so the `Event` enum layout is identical
- Soften the catch-all to return a `Result`/log instead of panicking if robustness matters more than strictness
Example fix
// before
match event {
Event::EntityDeathEvent(d) => <EntityDismountEvent as Event>::data_from_event(Event::EntityDeathEvent(d)),
_ => unreachable!(),
}
// after
match event {
Event::EntityDismountEvent(d) => <EntityDismountEvent as Event>::data_from_event(Event::EntityDismountEvent(d)),
_ => unreachable!(),
} Defensive patterns
Strategy: type-guard
Validate before calling
if !matches!(event, Event::EntityDismountEvent(_)) { return; }
<crate::events::entity::entity_dismount::EntityDismountEvent as Event>::data_from_event(event); Type guard
fn as_entity_dismount(event: &Event) -> Option<&EntityDismountEventData> {
match event { Event::EntityDismountEvent(d) => Some(d), _ => None }
} Try / catch
// guard before unwrapping:
if let Event::EntityDismountEvent(data) = event {
// use data
} else {
log::error!("misrouted event: expected EntityDismountEvent");
} Prevention
- Pattern-match the expected variant before invoking `data_from_event`
- Avoid forwarding raw `Event` values through handlers without checking `EVENT_TYPE`
- Round-trip test each event implementation (`data_into_event` then `data_from_event`)
- Pin matching versions of plugin-api across plugin and host
When it happens
Trigger: Invoking the `Event` trait's `data_from_event` with any variant other than `Event::EntityDismountEvent` — manual dispatch with the wrong variant, a dispatcher that pairs `EventType::EntityDismountEvent` with the wrong data, or test harness code feeding arbitrary events through the wrong implementation.
Common situations: Copy-pasted dispatch code in tests using a neighboring event variant; custom event-bus code that stores `Event` values and forwards them without checking `EVENT_TYPE`; version skew between plugin-api crates where variant names drifted.
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
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/b922c533501f5daf.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-plugin-api/src/events/entity/entity_dismount.rs:14
use crate::wit::pumpkin::plugin::event::{EntityDismountEventData, Event, EventType};
use super::super::FromIntoEvent;
/// Event triggered when an entity dismounts another entity.
pub struct EntityDismountEvent;
impl FromIntoEvent for EntityDismountEvent {
const EVENT_TYPE: EventType = EventType::EntityDismountEvent;
type Data = EntityDismountEventData;
fn data_from_event(event: Event) -> Self::Data {
match event {
Event::EntityDismountEvent(data) => data,
_ => panic!("unexpected event"),
}
}
fn data_into_event(data: Self::Data) -> Event {
Event::EntityDismountEvent(data)
}
}
View on GitHub (pinned to 8d4639e25a)