Skip to main content

pumpkinplus/modules/mechanics/entity/
husk.rs

1//! Husk module — custom husk sand drops with camel rider bonus.
2//!
3//! ## Configuration
4//!
5//! | Field                        | Default | Description                                         |
6//! |------------------------------|---------|-----------------------------------------------------|
7//! | `enabled`                    | `false` | Whether this module is active                       |
8//! | `sand_drop_chance`           | `1.0`   | Chance (0.0 - 1.0) for a husk to drop sand          |
9//! | `sand_base_min`              | `0`     | Minimum base amount of sand dropped                 |
10//! | `sand_base_max`              | `2`     | Maximum base amount of sand dropped                 |
11//! | `sand_looting_bonus`         | `1`     | Extra sand granted per level of Looting             |
12//! | `camel_rider_sand_base_max`  | `3`     | Maximum base sand for husks riding a camel          |
13//! | `camel_rider_looting_bonus`  | `2`     | Extra sand per Looting level for camel riders       |
14//!
15//! ## Notes
16//!
17//! This module is currently a stub. The Pumpkin plugin API does not yet expose
18//! an `EntityDeathEvent` (or equivalent), so husk drop mechanics cannot be hooked
19//! until upstream support is added.
20
21use crate::config::ConfigManager;
22use crate::mechanics::mechanic::Mechanic;
23use pumpkin_plugin_api::Context;
24use serde::{Deserialize, Serialize};
25
26/// Handles husk death drop mechanics.
27#[derive(Default)]
28pub struct Husk;
29
30impl Mechanic for Husk {
31    fn enabled(&self) -> bool {
32        ConfigManager::get()
33            .map(|cm| cm.get_config::<HuskConfig>().enabled)
34            .unwrap_or(false)
35    }
36
37    fn events(&self, _context: &Context) {
38        // TODO: Implement when EntityDeathEvent (or equivalent) is available
39        // in the Pumpkin plugin API. The intended logic is:
40        //
41        // 1. Listen for entity death events.
42        // 2. If the entity is not a Husk, return.
43        // 3. If the drop chance roll fails, return.
44        // 4. Determine if the husk is riding a Camel (`isCamelHusk`).
45        // 5. Determine the killer and their Looting enchantment level.
46        // 6. Calculate min and max sand amount based on config values and whether it's a camel rider.
47        // 7. Roll the amount: `Random.nextInt(minAmount, maxAmount + 1)`.
48        // 8. If amount > 0, add `Material::Sand` to the event drops.
49    }
50}
51
52/// Configuration for the husk mechanics module.
53#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct HuskConfig {
55    /// Whether this module is active.
56    pub enabled: bool,
57    /// Chance (0.0 - 1.0) for a husk to drop sand.
58    pub sand_drop_chance: f64,
59    /// Minimum base amount of sand dropped.
60    pub sand_base_min: u32,
61    /// Maximum base amount of sand dropped (non-camel).
62    pub sand_base_max: u32,
63    /// Extra sand granted per level of Looting (non-camel).
64    pub sand_looting_bonus: u32,
65    /// Maximum base amount of sand dropped when the husk is riding a camel.
66    pub camel_rider_sand_base_max: u32,
67    /// Extra sand per level of Looting when the husk is riding a camel.
68    pub camel_rider_looting_bonus: u32,
69}
70
71impl Default for HuskConfig {
72    fn default() -> Self {
73        Self {
74            enabled: false,
75            sand_drop_chance: 1.0,
76            sand_base_min: 0,
77            sand_base_max: 2,
78            sand_looting_bonus: 1,
79            camel_rider_sand_base_max: 3,
80            camel_rider_looting_bonus: 2,
81        }
82    }
83}