dragonfly_plugin/event/
mutations.rs

1//! This file is auto-generated by `xtask`. Do not edit manually.
2#![allow(clippy::all)]
3use crate::event::EventContext;
4use crate::types;
5impl<'a> EventContext<'a, types::ChatEvent> {
6    ///Sets the `message` for this event.
7    pub fn set_message(&mut self, message: impl Into<Option<String>>) {
8        let mutation = types::ChatMutation {
9            message: message.into(),
10            ..Default::default()
11        };
12        self.set_mutation(types::EventResultUpdate::Chat(mutation));
13    }
14}
15impl<'a> EventContext<'a, types::BlockBreakEvent> {
16    ///Sets the `drops` for this event.
17    pub fn set_drops(&mut self, drops: impl Into<Option<types::ItemStackList>>) {
18        let mutation = types::BlockBreakMutation {
19            drops: drops.into(),
20            ..Default::default()
21        };
22        self.set_mutation(types::EventResultUpdate::BlockBreak(mutation));
23    }
24    ///Sets the `xp` for this event.
25    pub fn set_xp(&mut self, xp: impl Into<Option<i32>>) {
26        let mutation = types::BlockBreakMutation {
27            xp: xp.into(),
28            ..Default::default()
29        };
30        self.set_mutation(types::EventResultUpdate::BlockBreak(mutation));
31    }
32}
33impl<'a> EventContext<'a, types::PlayerFoodLossEvent> {
34    ///Sets the `to` for this event.
35    pub fn set_to(&mut self, to: impl Into<Option<i32>>) {
36        let mutation = types::PlayerFoodLossMutation {
37            to: to.into(),
38            ..Default::default()
39        };
40        self.set_mutation(types::EventResultUpdate::PlayerFoodLoss(mutation));
41    }
42}
43impl<'a> EventContext<'a, types::PlayerHealEvent> {
44    ///Sets the `amount` for this event.
45    pub fn set_amount(&mut self, amount: impl Into<Option<f64>>) {
46        let mutation = types::PlayerHealMutation {
47            amount: amount.into(),
48            ..Default::default()
49        };
50        self.set_mutation(types::EventResultUpdate::PlayerHeal(mutation));
51    }
52}
53impl<'a> EventContext<'a, types::PlayerHurtEvent> {
54    ///Sets the `damage` for this event.
55    pub fn set_damage(&mut self, damage: impl Into<Option<f64>>) {
56        let mutation = types::PlayerHurtMutation {
57            damage: damage.into(),
58            ..Default::default()
59        };
60        self.set_mutation(types::EventResultUpdate::PlayerHurt(mutation));
61    }
62    ///Sets the `attack_immunity_ms` for this event.
63    pub fn set_attack_immunity_ms(&mut self, attack_immunity_ms: impl Into<Option<i64>>) {
64        let mutation = types::PlayerHurtMutation {
65            attack_immunity_ms: attack_immunity_ms.into(),
66            ..Default::default()
67        };
68        self.set_mutation(types::EventResultUpdate::PlayerHurt(mutation));
69    }
70}
71impl<'a> EventContext<'a, types::PlayerDeathEvent> {
72    ///Sets the `keep_inventory` for this event.
73    pub fn set_keep_inventory(&mut self, keep_inventory: impl Into<Option<bool>>) {
74        let mutation = types::PlayerDeathMutation {
75            keep_inventory: keep_inventory.into(),
76            ..Default::default()
77        };
78        self.set_mutation(types::EventResultUpdate::PlayerDeath(mutation));
79    }
80}
81impl<'a> EventContext<'a, types::PlayerRespawnEvent> {
82    ///Sets the `position` for this event.
83    pub fn set_position(&mut self, position: impl Into<Option<types::Vec3>>) {
84        let mutation = types::PlayerRespawnMutation {
85            position: position.into(),
86            ..Default::default()
87        };
88        self.set_mutation(types::EventResultUpdate::PlayerRespawn(mutation));
89    }
90    ///Sets the `world` for this event.
91    pub fn set_world(&mut self, world: impl Into<Option<types::WorldRef>>) {
92        let mutation = types::PlayerRespawnMutation {
93            world: world.into(),
94            ..Default::default()
95        };
96        self.set_mutation(types::EventResultUpdate::PlayerRespawn(mutation));
97    }
98}
99impl<'a> EventContext<'a, types::PlayerAttackEntityEvent> {
100    ///Sets the `force` for this event.
101    pub fn set_force(&mut self, force: impl Into<Option<f64>>) {
102        let mutation = types::PlayerAttackEntityMutation {
103            force: force.into(),
104            ..Default::default()
105        };
106        self.set_mutation(types::EventResultUpdate::PlayerAttackEntity(mutation));
107    }
108    ///Sets the `height` for this event.
109    pub fn set_height(&mut self, height: impl Into<Option<f64>>) {
110        let mutation = types::PlayerAttackEntityMutation {
111            height: height.into(),
112            ..Default::default()
113        };
114        self.set_mutation(types::EventResultUpdate::PlayerAttackEntity(mutation));
115    }
116    ///Sets the `critical` for this event.
117    pub fn set_critical(&mut self, critical: impl Into<Option<bool>>) {
118        let mutation = types::PlayerAttackEntityMutation {
119            critical: critical.into(),
120            ..Default::default()
121        };
122        self.set_mutation(types::EventResultUpdate::PlayerAttackEntity(mutation));
123    }
124}
125impl<'a> EventContext<'a, types::PlayerExperienceGainEvent> {
126    ///Sets the `amount` for this event.
127    pub fn set_amount(&mut self, amount: impl Into<Option<i32>>) {
128        let mutation = types::PlayerExperienceGainMutation {
129            amount: amount.into(),
130            ..Default::default()
131        };
132        self.set_mutation(types::EventResultUpdate::PlayerExperienceGain(mutation));
133    }
134}
135impl<'a> EventContext<'a, types::PlayerLecternPageTurnEvent> {
136    ///Sets the `new_page` for this event.
137    pub fn set_new_page(&mut self, new_page: impl Into<Option<i32>>) {
138        let mutation = types::PlayerLecternPageTurnMutation {
139            new_page: new_page.into(),
140            ..Default::default()
141        };
142        self.set_mutation(types::EventResultUpdate::PlayerLecternPageTurn(mutation));
143    }
144}
145impl<'a> EventContext<'a, types::PlayerItemPickupEvent> {
146    ///Sets the `item` for this event.
147    pub fn set_item(&mut self, item: impl Into<Option<types::ItemStack>>) {
148        let mutation = types::PlayerItemPickupMutation {
149            item: item.into(),
150            ..Default::default()
151        };
152        self.set_mutation(types::EventResultUpdate::PlayerItemPickup(mutation));
153    }
154}
155impl<'a> EventContext<'a, types::PlayerTransferEvent> {
156    ///Sets the `address` for this event.
157    pub fn set_address(&mut self, address: impl Into<Option<types::Address>>) {
158        let mutation = types::PlayerTransferMutation {
159            address: address.into(),
160            ..Default::default()
161        };
162        self.set_mutation(types::EventResultUpdate::PlayerTransfer(mutation));
163    }
164}
165impl<'a> EventContext<'a, types::WorldExplosionEvent> {
166    ///Sets the `entity_uuids` for this event.
167    pub fn set_entity_uuids(&mut self, entity_uuids: impl Into<Option<types::StringList>>) {
168        let mutation = types::WorldExplosionMutation {
169            entity_uuids: entity_uuids.into(),
170            ..Default::default()
171        };
172        self.set_mutation(types::EventResultUpdate::WorldExplosion(mutation));
173    }
174    ///Sets the `blocks` for this event.
175    pub fn set_blocks(&mut self, blocks: impl Into<Option<types::BlockPosList>>) {
176        let mutation = types::WorldExplosionMutation {
177            blocks: blocks.into(),
178            ..Default::default()
179        };
180        self.set_mutation(types::EventResultUpdate::WorldExplosion(mutation));
181    }
182    ///Sets the `item_drop_chance` for this event.
183    pub fn set_item_drop_chance(&mut self, item_drop_chance: impl Into<Option<f64>>) {
184        let mutation = types::WorldExplosionMutation {
185            item_drop_chance: item_drop_chance.into(),
186            ..Default::default()
187        };
188        self.set_mutation(types::EventResultUpdate::WorldExplosion(mutation));
189    }
190    ///Sets the `spawn_fire` for this event.
191    pub fn set_spawn_fire(&mut self, spawn_fire: impl Into<Option<bool>>) {
192        let mutation = types::WorldExplosionMutation {
193            spawn_fire: spawn_fire.into(),
194            ..Default::default()
195        };
196        self.set_mutation(types::EventResultUpdate::WorldExplosion(mutation));
197    }
198}