mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
refactor out double call to self.player
This commit is contained in:
@@ -400,11 +400,12 @@ impl Client {
|
||||
}
|
||||
|
||||
pub fn handle_set_creative_slot(&mut self, _server: &mut Server, packet: SSetCreativeSlot) {
|
||||
let gamemode = self.player.as_ref().unwrap().gamemode;
|
||||
if gamemode != GameMode::Creative {
|
||||
self.kick("Invalid action, you can only do that if you are in creative")
|
||||
let player = self.player.as_mut().unwrap();
|
||||
if player.gamemode != GameMode::Creative {
|
||||
self.kick("Invalid action, you can only do that if you are in creative");
|
||||
return;
|
||||
}
|
||||
let inventory = &mut self.player.as_mut().unwrap().inventory;
|
||||
let inventory = &mut player.inventory;
|
||||
|
||||
inventory.set_slot(packet.slot as usize, packet.clicked_item.to_item(), false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user