pumpkinplus/modules/mechanics/player/head.rs
1//! Head module — player head drops on death.
2//!
3//! ## Configuration
4//!
5//! | Field | Default | Description |
6//! |--------------------|---------|-----------------------------------------------------|
7//! | `enabled` | `false` | Whether this module is active |
8//! | `skull_drop_chance`| `0.01` | Chance (0.0 - 1.0) for a player's head to drop |
9//!
10//! ## Mechanics
11//!
12//! When a player dies, there is a chance their head (with their skin profile)
13//! is dropped at their death location.
14//!
15//! ## Notes
16//!
17//! This module is currently a stub. The Pumpkin plugin API does not yet expose
18//! a `PlayerDeathEvent` (or equivalent), so player head drop mechanics cannot be
19//! hooked until upstream support is added. Additionally, creating player head
20//! items with skin profiles requires item data component APIs that may not be
21//! available in the WASM plugin environment.
22
23use crate::config::ConfigManager;
24use crate::mechanics::mechanic::Mechanic;
25use pumpkin_plugin_api::Context;
26use serde::{Deserialize, Serialize};
27
28/// Handles player head drops on death.
29#[derive(Default)]
30pub struct Head;
31
32impl Mechanic for Head {
33 fn enabled(&self) -> bool {
34 ConfigManager::get()
35 .map(|cm| cm.get_config::<HeadConfig>().enabled)
36 .unwrap_or(false)
37 }
38
39 fn events(&self, _context: &Context) {
40 // TODO: Implement when PlayerDeathEvent (or equivalent) is available
41 // in the Pumpkin plugin API. The intended logic is:
42 //
43 // 1. Listen for player death events.
44 // 2. Roll `skull_drop_chance`.
45 // 3. If successful, create a player head ItemStack.
46 // 4. Apply the player's skin profile to the head item.
47 // 5. Drop the item naturally at the player's death location.
48 }
49}
50
51/// Configuration for the player head drop module.
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct HeadConfig {
54 /// Whether this module is active.
55 pub enabled: bool,
56 /// Chance (0.0 - 1.0) for a player's head to drop on death.
57 pub skull_drop_chance: f64,
58}
59
60impl Default for HeadConfig {
61 fn default() -> Self {
62 Self {
63 enabled: false,
64 skull_drop_chance: 0.01,
65 }
66 }
67}