-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
445 additions
and
243 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "pumpkin-entity" | ||
version.workspace = true | ||
edition.workspace = true | ||
|
||
[dependencies] | ||
num-traits = "0.2" | ||
num-derive = "0.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use num_derive::ToPrimitive; | ||
|
||
// todo | ||
#[derive(ToPrimitive, Clone)] | ||
pub enum EntityType { | ||
Zombie = 124, | ||
Player = 128, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use entity_type::EntityType; | ||
|
||
pub mod entity_type; | ||
|
||
pub type EntityId = i32; | ||
|
||
pub struct Entity { | ||
pub entity_id: EntityId, | ||
pub entity_type: EntityType, | ||
} | ||
|
||
impl Entity { | ||
pub fn new(entity_id: EntityId, entity_type: EntityType) -> Self { | ||
Self { | ||
entity_id, | ||
entity_type, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
use pumpkin_macros::packet; | ||
use serde::Serialize; | ||
|
||
use crate::VarInt32; | ||
use crate::VarInt; | ||
|
||
#[derive(Serialize)] | ||
#[packet(0x03)] | ||
pub struct CSetCompression { | ||
threshold: VarInt32, | ||
threshold: VarInt, | ||
} | ||
|
||
impl CSetCompression { | ||
pub fn new(threshold: VarInt32) -> Self { | ||
pub fn new(threshold: VarInt) -> Self { | ||
Self { threshold } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use pumpkin_macros::packet; | ||
|
||
use crate::{ClientPacket, VarInt}; | ||
|
||
#[derive(Clone)] | ||
#[packet(0x01)] | ||
pub struct CSpawnEntity { | ||
entity_id: VarInt, | ||
entity_uuid: uuid::Uuid, | ||
typ: VarInt, | ||
x: f64, | ||
y: f64, | ||
z: f64, | ||
pitch: u8, // angle | ||
yaw: u8, // angle | ||
head_yaw: u8, // angle | ||
data: VarInt, | ||
velocity_x: i16, | ||
velocity_y: i16, | ||
velocity_z: i16, | ||
} | ||
|
||
impl CSpawnEntity { | ||
pub fn new( | ||
entity_id: VarInt, | ||
entity_uuid: uuid::Uuid, | ||
typ: VarInt, | ||
x: f64, | ||
y: f64, | ||
z: f64, | ||
pitch: u8, // angle | ||
yaw: u8, // angle | ||
head_yaw: u8, // angle | ||
data: VarInt, | ||
velocity_x: i16, | ||
velocity_y: i16, | ||
velocity_z: i16, | ||
) -> Self { | ||
Self { | ||
entity_id, | ||
entity_uuid, | ||
typ, | ||
x, | ||
y, | ||
z, | ||
pitch, | ||
yaw, | ||
head_yaw, | ||
data, | ||
velocity_x, | ||
velocity_y, | ||
velocity_z, | ||
} | ||
} | ||
} | ||
|
||
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); | ||
} | ||
} |
Oops, something went wrong.