Add: Basic Combat

This commit is contained in:
Snowiiii committed 2024-08-13 09:16:00 +02:00
1 parent c2bde2f73e
commit 9fc86e260b
15 files changed
+163 -55

No files matched your search

+7 -2
View File
@@ -27,8 +27,8 @@ use pumpkin_protocol::{
handshake::SHandShake,
login::{SEncryptionResponse, SLoginAcknowledged, SLoginPluginResponse, SLoginStart},
play::{
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SPlayerCommand,
SPlayerPosition, SPlayerPositionRotation, SPlayerRotation, SSwingArm,
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation, SSwingArm,
},
status::{SPingRequest, SStatusRequest},
},
@@ -159,6 +159,8 @@ impl Client {
}
pub fn set_gamemode(&mut self, gamemode: GameMode) {
let player = self.player.as_mut().unwrap();
player.gamemode = gamemode;
self.send_packet(&CGameEvent::new(3, gamemode.to_f32().unwrap()));
}
@@ -282,6 +284,9 @@ impl Client {
server,
SClientInformationPlay::read(bytebuf).unwrap(),
),
SInteract::PACKET_ID => {
self.handle_interact(server, SInteract::read(bytebuf).unwrap());
}
_ => log::error!("Failed to handle player packet id {}", packet.id.0),
}
}