Add Serverbound Confirm Teleportation
This commit is contained in:
parent
f111c7881c
commit
a45a43397c
@ -3,4 +3,5 @@
|
|||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod handshake;
|
pub mod handshake;
|
||||||
pub mod login;
|
pub mod login;
|
||||||
|
pub mod play;
|
||||||
pub mod status;
|
pub mod status;
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
use crate::{ServerPacket, VarInt};
|
||||||
|
|
||||||
|
pub struct SConfirmTeleport {
|
||||||
|
teleport_id: VarInt,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ServerPacket for SConfirmTeleport {
|
||||||
|
const PACKET_ID: VarInt = 0x00;
|
||||||
|
|
||||||
|
fn read(bytebuf: &mut crate::bytebuf::ByteBuffer) -> Self {
|
||||||
|
Self {
|
||||||
|
teleport_id: bytebuf.get_var_int(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -64,19 +64,23 @@ const NAMES: &[&str] = &[
|
|||||||
];
|
];
|
||||||
|
|
||||||
pub(super) fn entires() -> Vec<RegistryEntry> {
|
pub(super) fn entires() -> Vec<RegistryEntry> {
|
||||||
let items: Vec<_> = NAMES
|
let items: Vec<_> = NAMES
|
||||||
.iter()
|
.iter()
|
||||||
.map(|name| RegistryEntry {
|
.map(|name| RegistryEntry {
|
||||||
entry_id: (*name).into(),
|
entry_id: (*name).into(),
|
||||||
data: fastnbt::to_bytes_with_opts(&DamageType {
|
data: fastnbt::to_bytes_with_opts(
|
||||||
exhaustion: 0.1,
|
&DamageType {
|
||||||
message_id: "inFire".into(),
|
exhaustion: 0.1,
|
||||||
scaling: "when_caused_by_living_non_player".into(),
|
message_id: "inFire".into(),
|
||||||
death_message_type: None,
|
scaling: "when_caused_by_living_non_player".into(),
|
||||||
effects: None,
|
death_message_type: None,
|
||||||
}, SerOpts::network_nbt()).unwrap(),
|
effects: None,
|
||||||
})
|
},
|
||||||
.collect();
|
SerOpts::network_nbt(),
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
items
|
items
|
||||||
}
|
}
|
||||||
@ -30,15 +30,18 @@ impl Registry {
|
|||||||
};
|
};
|
||||||
let biomes = Registry {
|
let biomes = Registry {
|
||||||
registry_id: "minecraft:worldgen/biome".to_string(),
|
registry_id: "minecraft:worldgen/biome".to_string(),
|
||||||
registry_entries: vec![RegistryEntry {
|
registry_entries: vec![
|
||||||
entry_id: "minecraft:snowy_taiga".to_string(),
|
RegistryEntry {
|
||||||
data: fastnbt::to_bytes_with_opts(&Biome::default(), SerOpts::network_nbt())
|
entry_id: "minecraft:snowy_taiga".to_string(),
|
||||||
.unwrap(),
|
data: fastnbt::to_bytes_with_opts(&Biome::default(), SerOpts::network_nbt())
|
||||||
}, RegistryEntry {
|
.unwrap(),
|
||||||
entry_id: "minecraft:plains".to_string(),
|
},
|
||||||
data: fastnbt::to_bytes_with_opts(&Biome::default(), SerOpts::network_nbt())
|
RegistryEntry {
|
||||||
.unwrap(),
|
entry_id: "minecraft:plains".to_string(),
|
||||||
}]
|
data: fastnbt::to_bytes_with_opts(&Biome::default(), SerOpts::network_nbt())
|
||||||
|
.unwrap(),
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
let wolf_variants = Registry {
|
let wolf_variants = Registry {
|
||||||
registry_id: "minecraft:wolf_variant".to_string(),
|
registry_id: "minecraft:wolf_variant".to_string(),
|
||||||
|
|||||||
@ -28,7 +28,7 @@ use std::io::Read;
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
mod client_packet;
|
mod client_packet;
|
||||||
mod player_packet;
|
pub mod player_packet;
|
||||||
|
|
||||||
use client_packet::ClientPacketProcessor;
|
use client_packet::ClientPacketProcessor;
|
||||||
|
|
||||||
@ -185,6 +185,14 @@ impl Client {
|
|||||||
packet.id
|
packet.id
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
pumpkin_protocol::ConnectionState::Play => {
|
||||||
|
if let Some(player) = &mut self.player {
|
||||||
|
player.handle_packet(server, packet);
|
||||||
|
} else {
|
||||||
|
// should be impossible
|
||||||
|
self.kick("no player in play state?")
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => log::error!("Invalid Connection state {:?}", self.connection_state),
|
_ => log::error!("Invalid Connection state {:?}", self.connection_state),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,2 +1,13 @@
|
|||||||
|
use pumpkin_protocol::server::play::SConfirmTeleport;
|
||||||
|
|
||||||
|
use crate::{entity::player::Player, server::Server};
|
||||||
|
|
||||||
// implement player packets
|
// implement player packets
|
||||||
pub trait PlayerPacketProcessor {}
|
pub trait PlayerPacketProcessor {
|
||||||
|
fn handle_confirm_teleport(&mut self, server: &mut Server, confirm_teleport: SConfirmTeleport);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PlayerPacketProcessor for Player {
|
||||||
|
fn handle_confirm_teleport(&mut self, server: &mut Server, confirm_teleport: SConfirmTeleport) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
use pumpkin_protocol::VarInt;
|
use pumpkin_protocol::{server::play::SConfirmTeleport, RawPacket, ServerPacket, VarInt};
|
||||||
|
|
||||||
|
use crate::{client::player_packet::PlayerPacketProcessor, server::Server};
|
||||||
|
|
||||||
use super::{Entity, EntityId};
|
use super::{Entity, EntityId};
|
||||||
|
|
||||||
@ -14,6 +16,16 @@ impl Player {
|
|||||||
pub fn entity_id(&self) -> EntityId {
|
pub fn entity_id(&self) -> EntityId {
|
||||||
self.entity.entity_id
|
self.entity.entity_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn handle_packet(&mut self, server: &mut Server, packet: &mut RawPacket) {
|
||||||
|
let bytebuf = &mut packet.bytebuf;
|
||||||
|
match packet.id {
|
||||||
|
SConfirmTeleport::PACKET_ID => {
|
||||||
|
self.handle_confirm_teleport(server, SConfirmTeleport::read(bytebuf))
|
||||||
|
}
|
||||||
|
_ => log::error!("Failed to handle Player packet, id {}", packet.id),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Hand {
|
pub enum Hand {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user