Add ChatType
This commit is contained in:
1 parent
65c2207c0a
commit
5cf19a4e98
16 files changed
+158
-151
No files matched your search
@@ -1,7 +1,9 @@
|
||||
use pumpkin_macros::packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{bytebuf::ByteBuffer, ClientPacket};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[packet(0x01)]
|
||||
pub struct CPluginMessage<'a> {
|
||||
channel: &'a str,
|
||||
@@ -13,10 +15,3 @@ impl<'a> CPluginMessage<'a> {
|
||||
Self { channel, data }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ClientPacket for CPluginMessage<'a> {
|
||||
fn write(&self, bytebuf: &mut ByteBuffer) {
|
||||
bytebuf.put_string(self.channel);
|
||||
bytebuf.put_slice(self.data);
|
||||
}
|
||||
}
|
||||
@@ -8,24 +8,24 @@ use crate::{RawBytes, VarInt};
|
||||
pub struct CEncryptionRequest<'a> {
|
||||
server_id: &'a str, // 20
|
||||
public_key_length: VarInt,
|
||||
public_key: RawBytes<'a>,
|
||||
public_key: &'a [u8],
|
||||
verify_token_length: VarInt,
|
||||
verify_token: RawBytes<'a>,
|
||||
verify_token: &'a [u8],
|
||||
should_authenticate: bool,
|
||||
}
|
||||
|
||||
impl<'a> CEncryptionRequest<'a> {
|
||||
pub fn new(
|
||||
server_id: &'a str,
|
||||
public_key: RawBytes<'a>,
|
||||
verify_token: RawBytes<'a>,
|
||||
public_key: &'a [u8],
|
||||
verify_token: &'a [u8],
|
||||
should_authenticate: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
server_id,
|
||||
public_key_length: public_key.0.len().into(),
|
||||
public_key_length: public_key.len().into(),
|
||||
public_key,
|
||||
verify_token_length: verify_token.0.len().into(),
|
||||
verify_token_length: verify_token.len().into(),
|
||||
verify_token,
|
||||
should_authenticate,
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ use pumpkin_macros::packet;
|
||||
use pumpkin_text::TextComponent;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{BitSet, VarInt};
|
||||
use crate::{uuid::UUID, BitSet, VarInt};
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[packet(0x39)]
|
||||
pub struct CPlayerChatMessage<'a> {
|
||||
sender: uuid::Uuid,
|
||||
sender: UUID,
|
||||
index: VarInt,
|
||||
message_signature: Option<&'a [u8]>,
|
||||
message: String,
|
||||
@@ -29,7 +29,7 @@ pub struct CPlayerChatMessage<'a> {
|
||||
impl<'a> CPlayerChatMessage<'a> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
sender: uuid::Uuid,
|
||||
sender: UUID,
|
||||
index: VarInt,
|
||||
message_signature: Option<&'a [u8]>,
|
||||
message: String,
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
use pumpkin_macros::packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{ClientPacket, VarInt};
|
||||
use crate::{uuid::UUID, VarInt};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Serialize, Clone)]
|
||||
#[packet(0x01)]
|
||||
pub struct CSpawnEntity {
|
||||
entity_id: VarInt,
|
||||
entity_uuid: uuid::Uuid,
|
||||
entity_uuid: UUID,
|
||||
typ: VarInt,
|
||||
x: f64,
|
||||
y: f64,
|
||||
@@ -24,7 +25,7 @@ impl CSpawnEntity {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
entity_id: VarInt,
|
||||
entity_uuid: uuid::Uuid,
|
||||
entity_uuid: UUID,
|
||||
typ: VarInt,
|
||||
x: f64,
|
||||
y: f64,
|
||||
@@ -54,21 +55,3 @@ impl CSpawnEntity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ClientPacket for CSpawnEntity {
|
||||
fn write(&self, bytebuf: &mut crate::bytebuf::ByteBuffer) {
|
||||
bytebuf.put_var_int(&self.entity_id);
|
||||
bytebuf.put_uuid(self.entity_uuid);
|
||||
bytebuf.put_var_int(&self.typ);
|
||||
bytebuf.put_f64(self.x);
|
||||
bytebuf.put_f64(self.y);
|
||||
bytebuf.put_f64(self.z);
|
||||
bytebuf.put_u8(self.pitch);
|
||||
bytebuf.put_u8(self.yaw);
|
||||
bytebuf.put_u8(self.head_yaw);
|
||||
bytebuf.put_var_int(&self.data);
|
||||
bytebuf.put_i16(self.velocity_x);
|
||||
bytebuf.put_i16(self.velocity_y);
|
||||
bytebuf.put_i16(self.velocity_z);
|
||||
}
|
||||
}
|
||||
@@ -91,16 +91,6 @@ impl VarInt {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RawBytes<'a>(pub &'a [u8]);
|
||||
impl<'a> Serialize for RawBytes<'a> {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
serializer.serialize_bytes(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for VarInt {
|
||||
fn from(value: i32) -> Self {
|
||||
VarInt(value)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct UUID(pub uuid::Uuid);
|
||||
|
||||
impl Serialize for UUID {
|
||||
|
||||
Reference in new issue
Block a user