dragonfly_plugin/event/
mutations.rs

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