mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-31 08:22:33 +00:00
feat(wasm-api): add ServerTickStartEvent (#2099)
* feat(plugin-api): add ServerTickStartEvent Add a non-cancellable event fired at the start of every server tick, carrying the 0-indexed tick number. Wires through all five layers: WIT contract, plugin-api guest binding, runtime host struct, WASM bridge, and the ticker fire site. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix ci/ fmt --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
pub mod server_broadcast;
|
||||
pub mod server_command;
|
||||
pub mod server_tick_start;
|
||||
pub mod spawn_change;
|
||||
|
||||
pub use server_broadcast::*;
|
||||
pub use server_command::*;
|
||||
pub use server_tick_start::*;
|
||||
pub use spawn_change::*;
|
||||
|
||||
25
pumpkin-plugin-api/src/events/server/server_tick_start.rs
Normal file
25
pumpkin-plugin-api/src/events/server/server_tick_start.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use crate::wit::pumpkin::plugin::event::{Event, EventType, ServerTickStartEventData};
|
||||
|
||||
use super::super::FromIntoEvent;
|
||||
|
||||
/// An event that fires at the start of every server tick (~20 Hz under the
|
||||
/// default tick rate).
|
||||
///
|
||||
/// The associated [`ServerTickStartEventData`] carries the 0-indexed `tick`
|
||||
/// number of the tick about to run. This event is non-cancellable.
|
||||
pub struct ServerTickStartEvent;
|
||||
impl FromIntoEvent for ServerTickStartEvent {
|
||||
const EVENT_TYPE: EventType = EventType::ServerTickStartEvent;
|
||||
type Data = ServerTickStartEventData;
|
||||
|
||||
fn data_from_event(event: Event) -> Self::Data {
|
||||
match event {
|
||||
Event::ServerTickStartEvent(data) => data,
|
||||
_ => panic!("unexpected event"),
|
||||
}
|
||||
}
|
||||
|
||||
fn data_into_event(data: Self::Data) -> Event {
|
||||
Event::ServerTickStartEvent(data)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user