pumpkinplus/modules/mechanics/entity/spawn_egg.rs
1//! Spawn egg module — rare spawn egg drops on entity death.
2//!
3//! ## Configuration
4//!
5//! | Field | Default | Description |
6//! |------------------------|---------|-----------------------------------------------------|
7//! | `enabled` | `false` | Whether this module is active |
8//! | `spawn_egg_drop_chance`| `0.001` | Chance (0.0 - 1.0) for an entity to drop its spawn egg |
9//!
10//! ## Notes
11//!
12//! This module is currently a stub. The Pumpkin plugin API does not yet expose
13//! an `EntityDeathEvent` (or equivalent), so spawn egg drop mechanics cannot be
14//! hooked until upstream support is added.
15
16use crate::config::ConfigManager;
17use crate::mechanics::mechanic::Mechanic;
18use pumpkin_plugin_api::Context;
19use serde::{Deserialize, Serialize};
20
21/// Handles rare spawn egg drops on entity death.
22#[derive(Default)]
23pub struct SpawnEgg;
24
25impl Mechanic for SpawnEgg {
26 fn enabled(&self) -> bool {
27 ConfigManager::get()
28 .map(|cm| cm.get_config::<SpawnEggConfig>().enabled)
29 .unwrap_or(false)
30 }
31
32 fn events(&self, _context: &Context) {
33 // TODO: Implement when EntityDeathEvent (or equivalent) is available
34 // in the Pumpkin plugin API. The intended logic is:
35 //
36 // 1. Listen for entity death events.
37 // 2. Roll `spawn_egg_drop_chance`.
38 // 3. If successful, map the entity type name to a spawn egg material.
39 // 4. Add the spawn egg item to the event drops.
40 }
41}
42
43/// Configuration for the spawn egg mechanics module.
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct SpawnEggConfig {
46 /// Whether this module is active.
47 pub enabled: bool,
48 /// Chance (0.0 - 1.0) for an entity to drop its spawn egg.
49 pub spawn_egg_drop_chance: f64,
50}
51
52impl Default for SpawnEggConfig {
53 fn default() -> Self {
54 Self {
55 enabled: false,
56 spawn_egg_drop_chance: 0.001,
57 }
58 }
59}