pumpkinplus/modules/mechanics/entity/tameable.rs
1//! Tameable module — transfer tameable entity ownership via lead right-click.
2//!
3//! ## Configuration
4//!
5//! | Field | Default | Description |
6//! |-------------|---------|-----------------------------------------------------|
7//! | `enabled` | `false` | Whether this module is active |
8//!
9//! ## Mechanics
10//!
11//! When a player right-clicks another player while holding a lead:
12//! - If the source player has a leashed, tamed entity
13//! - And the source player is the owner of that entity
14//! - Ownership of the entity is transferred to the target player
15//! - The entity is leashed to the new owner
16//!
17//! ## Notes
18//!
19//! This module is currently a stub. The Pumpkin plugin API does not yet expose:
20//! - `PlayerInteractEntityEvent` (or equivalent) for right-clicking entities
21//! - Methods to query a player's leashed entity
22//! - Methods to check or modify entity tameable state / ownership
23//! - Methods to set an entity's leash holder
24//!
25//! Until these APIs are available, ownership transfer cannot be implemented.
26
27use crate::config::ConfigManager;
28use crate::mechanics::mechanic::Mechanic;
29use pumpkin_plugin_api::Context;
30use serde::{Deserialize, Serialize};
31
32/// Handles tameable entity ownership transfer.
33#[derive(Default)]
34pub struct Tameable;
35
36impl Mechanic for Tameable {
37 fn enabled(&self) -> bool {
38 ConfigManager::get()
39 .map(|cm| cm.get_config::<TameableConfig>().enabled)
40 .unwrap_or(false)
41 }
42
43 fn events(&self, _context: &Context) {
44 // TODO: Implement when PlayerInteractEntityEvent (or equivalent) and
45 // entity/leash/tameable APIs are available in the Pumpkin plugin API.
46 //
47 // The intended logic is:
48 //
49 // 1. Listen for player interact entity events.
50 // 2. If the interaction is not a right-click on another player, return.
51 // 3. If the source player is not holding a lead in their main hand, return.
52 // 4. Query the source player's leashed entity.
53 // 5. If the entity is not tamed or the source is not the owner, return.
54 // 6. Transfer ownership to the target player.
55 // 7. Set the target player as the new leash holder.
56 // 8. Cancel the event to prevent default interaction.
57 }
58}
59
60/// Configuration for the tameable ownership transfer module.
61#[derive(Debug, Clone, Default, Serialize, Deserialize)]
62pub struct TameableConfig {
63 /// Whether this module is active.
64 pub enabled: bool,
65}