mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
use MinecraftEntityId type instead of u32 in az-protocol
This commit is contained in:
parent
4fb6b07746
commit
228489dded
39 changed files with 133 additions and 57 deletions
|
@ -86,7 +86,7 @@ pub fn handle_attack_event(
|
||||||
send_packet_events.send(SendPacketEvent::new(
|
send_packet_events.send(SendPacketEvent::new(
|
||||||
event.entity,
|
event.entity,
|
||||||
ServerboundInteract {
|
ServerboundInteract {
|
||||||
entity_id: *event.target,
|
entity_id: event.target,
|
||||||
action: s_interact::ActionType::Attack,
|
action: s_interact::ActionType::Attack,
|
||||||
using_secondary_action: **sneaking,
|
using_secondary_action: **sneaking,
|
||||||
},
|
},
|
||||||
|
|
|
@ -303,7 +303,7 @@ fn send_sprinting_if_needed(
|
||||||
send_packet_events.send(SendPacketEvent::new(
|
send_packet_events.send(SendPacketEvent::new(
|
||||||
entity,
|
entity,
|
||||||
ServerboundPlayerCommand {
|
ServerboundPlayerCommand {
|
||||||
id: **minecraft_entity_id,
|
id: *minecraft_entity_id,
|
||||||
action: sprinting_action,
|
action: sprinting_action,
|
||||||
data: 0,
|
data: 0,
|
||||||
},
|
},
|
||||||
|
|
|
@ -301,7 +301,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
azalea_registry::EntityKind::Player,
|
azalea_registry::EntityKind::Player,
|
||||||
new_instance_name,
|
new_instance_name,
|
||||||
);
|
);
|
||||||
let entity_id = MinecraftEntityId(p.player_id);
|
let entity_id = p.player_id;
|
||||||
// insert our components into the ecs :)
|
// insert our components into the ecs :)
|
||||||
commands.entity(player_entity).insert((
|
commands.entity(player_entity).insert((
|
||||||
entity_id,
|
entity_id,
|
||||||
|
@ -643,7 +643,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut entity_id_index, instance_name, tab_list) =
|
let (mut entity_id_index, instance_name, tab_list) =
|
||||||
query.get_mut(player_entity).unwrap();
|
query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let entity_id = MinecraftEntityId(p.id);
|
let entity_id = p.id;
|
||||||
|
|
||||||
let Some(instance_name) = instance_name else {
|
let Some(instance_name) = instance_name else {
|
||||||
warn!("got add player packet but we haven't gotten a login packet yet");
|
warn!("got add player packet but we haven't gotten a login packet yet");
|
||||||
|
@ -721,7 +721,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query, entity_kind_query) = system_state.get_mut(ecs);
|
let (mut commands, mut query, entity_kind_query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let entity = entity_id_index.get(MinecraftEntityId(p.id));
|
let entity = entity_id_index.get(p.id);
|
||||||
|
|
||||||
let Some(entity) = entity else {
|
let Some(entity) = entity else {
|
||||||
// some servers like hypixel trigger this a lot :(
|
// some servers like hypixel trigger this a lot :(
|
||||||
|
@ -768,7 +768,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else {
|
let Some(entity) = entity_id_index.get(p.id) else {
|
||||||
// note that this log (and some other ones like the one in RemoveEntities)
|
// note that this log (and some other ones like the one in RemoveEntities)
|
||||||
// sometimes happens when killing mobs. it seems to be a vanilla bug, which is
|
// sometimes happens when killing mobs. it seems to be a vanilla bug, which is
|
||||||
// why it's a debug log instead of a warning
|
// why it's a debug log instead of a warning
|
||||||
|
@ -837,7 +837,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else {
|
let Some(entity) = entity_id_index.get(p.id) else {
|
||||||
warn!("Got teleport entity packet for unknown entity id {}", p.id);
|
warn!("Got teleport entity packet for unknown entity id {}", p.id);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@ -883,7 +883,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
|
|
||||||
debug!("Got move entity pos packet {p:?}");
|
debug!("Got move entity pos packet {p:?}");
|
||||||
|
|
||||||
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.entity_id)) else {
|
let Some(entity) = entity_id_index.get(p.entity_id) else {
|
||||||
debug!(
|
debug!(
|
||||||
"Got move entity pos packet for unknown entity id {}",
|
"Got move entity pos packet for unknown entity id {}",
|
||||||
p.entity_id
|
p.entity_id
|
||||||
|
@ -924,7 +924,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
|
|
||||||
debug!("Got move entity pos rot packet {p:?}");
|
debug!("Got move entity pos rot packet {p:?}");
|
||||||
|
|
||||||
let entity = entity_id_index.get(MinecraftEntityId(p.entity_id));
|
let entity = entity_id_index.get(p.entity_id);
|
||||||
|
|
||||||
if let Some(entity) = entity {
|
if let Some(entity) = entity {
|
||||||
let new_delta = p.delta.clone();
|
let new_delta = p.delta.clone();
|
||||||
|
@ -977,7 +977,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let entity = entity_id_index.get(MinecraftEntityId(p.entity_id));
|
let entity = entity_id_index.get(p.entity_id);
|
||||||
|
|
||||||
if let Some(entity) = entity {
|
if let Some(entity) = entity {
|
||||||
let new_look_direction = LookDirection {
|
let new_look_direction = LookDirection {
|
||||||
|
@ -1040,7 +1040,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
};
|
};
|
||||||
|
|
||||||
for &id in &p.entity_ids {
|
for &id in &p.entity_ids {
|
||||||
let Some(entity) = entity_id_index.remove(MinecraftEntityId(id)) else {
|
let Some(entity) = entity_id_index.remove(id) else {
|
||||||
debug!("Tried to remove entity with id {id} but it wasn't in the EntityIdIndex");
|
debug!("Tried to remove entity with id {id} but it wasn't in the EntityIdIndex");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@ -1334,7 +1334,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query, mut death_events) = system_state.get_mut(ecs);
|
let (mut commands, mut query, mut death_events) = system_state.get_mut(ecs);
|
||||||
let (entity_id, dead) = query.get_mut(player_entity).unwrap();
|
let (entity_id, dead) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
if **entity_id == p.player_id && dead.is_none() {
|
if *entity_id == p.player_id && dead.is_none() {
|
||||||
commands.entity(player_entity).insert(Dead);
|
commands.entity(player_entity).insert(Dead);
|
||||||
death_events.send(DeathEvent {
|
death_events.send(DeathEvent {
|
||||||
entity: player_entity,
|
entity: player_entity,
|
||||||
|
@ -1475,7 +1475,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
||||||
let (mut commands, mut query) = system_state.get_mut(ecs);
|
let (mut commands, mut query) = system_state.get_mut(ecs);
|
||||||
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap();
|
||||||
|
|
||||||
let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else {
|
let Some(entity) = entity_id_index.get(p.id) else {
|
||||||
debug!("Got teleport entity packet for unknown entity id {}", p.id);
|
debug!("Got teleport entity packet for unknown entity id {}", p.id);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@ use azalea_protocol::packets::{
|
||||||
ConnectionProtocol, Packet, ProtocolPacket,
|
ConnectionProtocol, Packet, ProtocolPacket,
|
||||||
};
|
};
|
||||||
use azalea_registry::DimensionType;
|
use azalea_registry::DimensionType;
|
||||||
use azalea_world::Instance;
|
use azalea_world::{Instance, MinecraftEntityId};
|
||||||
use bevy_app::App;
|
use bevy_app::App;
|
||||||
use bevy_app::PluginGroup;
|
use bevy_app::PluginGroup;
|
||||||
use bevy_ecs::{prelude::*, schedule::ExecutorKind};
|
use bevy_ecs::{prelude::*, schedule::ExecutorKind};
|
||||||
|
@ -67,7 +67,7 @@ fn test_set_health_before_login() {
|
||||||
assert_eq!(*simulation.component::<Health>(), 15.);
|
assert_eq!(*simulation.component::<Health>(), 15.);
|
||||||
|
|
||||||
simulation.receive_packet(ClientboundLogin {
|
simulation.receive_packet(ClientboundLogin {
|
||||||
player_id: 0,
|
player_id: MinecraftEntityId(0),
|
||||||
hardcore: false,
|
hardcore: false,
|
||||||
levels: vec![],
|
levels: vec![],
|
||||||
max_players: 20,
|
max_players: 20,
|
||||||
|
|
|
@ -2,13 +2,14 @@ use azalea_buf::AzBuf;
|
||||||
use azalea_core::{position::Vec3, resource_location::ResourceLocation};
|
use azalea_core::{position::Vec3, resource_location::ResourceLocation};
|
||||||
use azalea_entity::{metadata::apply_default_metadata, EntityBundle};
|
use azalea_entity::{metadata::apply_default_metadata, EntityBundle};
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundAddEntity {
|
pub struct ClientboundAddEntity {
|
||||||
/// The id of the entity.
|
/// The numeric ID of the entity being added to the world.
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub uuid: Uuid,
|
pub uuid: Uuid,
|
||||||
pub entity_type: azalea_registry::EntityKind,
|
pub entity_type: azalea_registry::EntityKind,
|
||||||
pub position: Vec3,
|
pub position: Vec3,
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_core::position::Vec3;
|
use azalea_core::position::Vec3;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundAddExperienceOrb {
|
pub struct ClientboundAddExperienceOrb {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub pos: Vec3,
|
pub pos: Vec3,
|
||||||
pub value: u16,
|
pub value: u16,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundAnimate {
|
pub struct ClientboundAnimate {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub action: AnimationAction,
|
pub action: AnimationAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_core::position::BlockPos;
|
use azalea_core::position::BlockPos;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundBlockDestruction {
|
pub struct ClientboundBlockDestruction {
|
||||||
/// The ID of the entity breaking the block.
|
/// The ID of the entity breaking the block.
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub pos: BlockPos,
|
pub pos: BlockPos,
|
||||||
/// 0–9 to set it, any other value to remove it.
|
/// 0–9 to set it, any other value to remove it.
|
||||||
pub progress: u8,
|
pub progress: u8,
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
use std::io::{Cursor, Write};
|
use std::io::{Cursor, Write};
|
||||||
|
|
||||||
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWriteVar, AzaleaWrite};
|
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar};
|
||||||
use azalea_core::position::Vec3;
|
use azalea_core::position::Vec3;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundDamageEvent {
|
pub struct ClientboundDamageEvent {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
#[var]
|
#[var]
|
||||||
pub source_type_id: u32,
|
pub source_type_id: u32,
|
||||||
pub source_cause_id: OptionalEntityId,
|
pub source_cause_id: OptionalEntityId,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundEntityEvent {
|
pub struct ClientboundEntityEvent {
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub event_id: u8,
|
pub event_id: u8,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
use crate::common::movements::PositionMoveRotation;
|
use crate::common::movements::PositionMoveRotation;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundEntityPositionSync {
|
pub struct ClientboundEntityPositionSync {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub values: PositionMoveRotation,
|
pub values: PositionMoveRotation,
|
||||||
pub on_ground: bool,
|
pub on_ground: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundHorseScreenOpen {
|
pub struct ClientboundHorseScreenOpen {
|
||||||
|
@ -7,5 +8,5 @@ pub struct ClientboundHorseScreenOpen {
|
||||||
pub container_id: i32,
|
pub container_id: i32,
|
||||||
#[var]
|
#[var]
|
||||||
pub inventory_columns: u32,
|
pub inventory_columns: u32,
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundHurtAnimation {
|
pub struct ClientboundHurtAnimation {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub yaw: f32,
|
pub yaw: f32,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_core::resource_location::ResourceLocation;
|
use azalea_core::resource_location::ResourceLocation;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
use crate::packets::common::CommonPlayerSpawnInfo;
|
use crate::packets::common::CommonPlayerSpawnInfo;
|
||||||
|
|
||||||
|
@ -10,7 +11,7 @@ use crate::packets::common::CommonPlayerSpawnInfo;
|
||||||
/// world, and the registry.
|
/// world, and the registry.
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundLogin {
|
pub struct ClientboundLogin {
|
||||||
pub player_id: u32,
|
pub player_id: MinecraftEntityId,
|
||||||
pub hardcore: bool,
|
pub hardcore: bool,
|
||||||
pub levels: Vec<ResourceLocation>,
|
pub levels: Vec<ResourceLocation>,
|
||||||
#[var]
|
#[var]
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_core::delta::PositionDelta8;
|
use azalea_core::delta::PositionDelta8;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundMoveEntityPos {
|
pub struct ClientboundMoveEntityPos {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub delta: PositionDelta8,
|
pub delta: PositionDelta8,
|
||||||
pub on_ground: bool,
|
pub on_ground: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_core::delta::PositionDelta8;
|
use azalea_core::delta::PositionDelta8;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
/// This packet is sent by the server when an entity moves less then 8 blocks.
|
/// This packet is sent by the server when an entity moves less then 8 blocks.
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundMoveEntityPosRot {
|
pub struct ClientboundMoveEntityPosRot {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub delta: PositionDelta8,
|
pub delta: PositionDelta8,
|
||||||
pub y_rot: i8,
|
pub y_rot: i8,
|
||||||
pub x_rot: i8,
|
pub x_rot: i8,
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundMoveEntityRot {
|
pub struct ClientboundMoveEntityRot {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub y_rot: i8,
|
pub y_rot: i8,
|
||||||
pub x_rot: i8,
|
pub x_rot: i8,
|
||||||
pub on_ground: bool,
|
pub on_ground: bool,
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_core::position::Vec3;
|
use azalea_core::position::Vec3;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundMoveMinecartAlongTrack {
|
pub struct ClientboundMoveMinecartAlongTrack {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub lerp_steps: Vec<MinecartStep>,
|
pub lerp_steps: Vec<MinecartStep>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_chat::FormattedText;
|
use azalea_chat::FormattedText;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
/// Used to send a respawn screen.
|
/// Used to send a respawn screen.
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPlayerCombatKill {
|
pub struct ClientboundPlayerCombatKill {
|
||||||
#[var]
|
#[var]
|
||||||
pub player_id: u32,
|
pub player_id: MinecraftEntityId,
|
||||||
pub message: FormattedText,
|
pub message: FormattedText,
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ use crate::common::movements::{PositionMoveRotation, RelativeMovements};
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPlayerPosition {
|
pub struct ClientboundPlayerPosition {
|
||||||
|
/// The teleport ID.
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
pub change: PositionMoveRotation,
|
pub change: PositionMoveRotation,
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundProjectilePower {
|
pub struct ClientboundProjectilePower {
|
||||||
pub id: u32,
|
#[var]
|
||||||
|
pub id: MinecraftEntityId,
|
||||||
pub acceleration_power: f64,
|
pub acceleration_power: f64,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundRemoveEntities {
|
pub struct ClientboundRemoveEntities {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_ids: Vec<u32>,
|
pub entity_ids: Vec<MinecraftEntityId>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundRemoveMobEffect {
|
pub struct ClientboundRemoveMobEffect {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub effect: azalea_registry::MobEffect,
|
pub effect: azalea_registry::MobEffect,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundRotateHead {
|
pub struct ClientboundRotateHead {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub y_head_rot: i8,
|
pub y_head_rot: i8,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetCamera {
|
pub struct ClientboundSetCamera {
|
||||||
#[var]
|
#[var]
|
||||||
pub camera_id: u32,
|
pub camera_id: MinecraftEntityId,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_entity::EntityMetadataItems;
|
use azalea_entity::EntityMetadataItems;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetEntityData {
|
pub struct ClientboundSetEntityData {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub packed_items: EntityMetadataItems,
|
pub packed_items: EntityMetadataItems,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetEntityLink {
|
pub struct ClientboundSetEntityLink {
|
||||||
pub source_id: u32,
|
pub source_id: MinecraftEntityId,
|
||||||
pub dest_id: u32,
|
pub dest_id: MinecraftEntityId,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetEntityMotion {
|
pub struct ClientboundSetEntityMotion {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub xa: i16,
|
pub xa: i16,
|
||||||
pub ya: i16,
|
pub ya: i16,
|
||||||
pub za: i16,
|
pub za: i16,
|
||||||
|
|
|
@ -4,11 +4,12 @@ use azalea_buf::{AzBuf, BufReadError};
|
||||||
use azalea_buf::{AzaleaRead, AzaleaWrite};
|
use azalea_buf::{AzaleaRead, AzaleaWrite};
|
||||||
use azalea_inventory::ItemStack;
|
use azalea_inventory::ItemStack;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundSetEquipment {
|
pub struct ClientboundSetEquipment {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub slots: EquipmentSlots,
|
pub slots: EquipmentSlots,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use azalea_registry::SoundEvent;
|
use azalea_registry::SoundEvent;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
use super::c_sound::{CustomSound, SoundSource};
|
use super::c_sound::{CustomSound, SoundSource};
|
||||||
|
|
||||||
|
@ -9,7 +10,7 @@ pub struct ClientboundSoundEntity {
|
||||||
pub sound: azalea_registry::Holder<SoundEvent, CustomSound>,
|
pub sound: azalea_registry::Holder<SoundEvent, CustomSound>,
|
||||||
pub source: SoundSource,
|
pub source: SoundSource,
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub volume: f32,
|
pub volume: f32,
|
||||||
pub pitch: f32,
|
pub pitch: f32,
|
||||||
pub seed: u64,
|
pub seed: u64,
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundTakeItemEntity {
|
pub struct ClientboundTakeItemEntity {
|
||||||
#[var]
|
#[var]
|
||||||
pub item_id: u32,
|
pub item_id: u32,
|
||||||
#[var]
|
#[var]
|
||||||
pub player_id: u32,
|
pub player_id: MinecraftEntityId,
|
||||||
#[var]
|
#[var]
|
||||||
pub amount: u32,
|
pub amount: u32,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
use crate::common::movements::{PositionMoveRotation, RelativeMovements};
|
use crate::common::movements::{PositionMoveRotation, RelativeMovements};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundTeleportEntity {
|
pub struct ClientboundTeleportEntity {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub change: PositionMoveRotation,
|
pub change: PositionMoveRotation,
|
||||||
pub relatives: RelativeMovements,
|
pub relatives: RelativeMovements,
|
||||||
pub on_ground: bool,
|
pub on_ground: bool,
|
||||||
|
|
|
@ -2,11 +2,12 @@ use azalea_buf::AzBuf;
|
||||||
use azalea_entity::attributes::AttributeModifier;
|
use azalea_entity::attributes::AttributeModifier;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use azalea_registry::Attribute;
|
use azalea_registry::Attribute;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundUpdateAttributes {
|
pub struct ClientboundUpdateAttributes {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub values: Vec<AttributeSnapshot>,
|
pub values: Vec<AttributeSnapshot>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use azalea_registry::MobEffect;
|
use azalea_registry::MobEffect;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundUpdateMobEffect {
|
pub struct ClientboundUpdateMobEffect {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub mob_effect: MobEffect,
|
pub mob_effect: MobEffect,
|
||||||
#[var]
|
#[var]
|
||||||
pub effect_amplifier: u32,
|
pub effect_amplifier: u32,
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ServerboundGamePacket;
|
use azalea_protocol_macros::ServerboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundEntityTagQuery {
|
pub struct ServerboundEntityTagQuery {
|
||||||
#[var]
|
#[var]
|
||||||
pub transaction_id: u32,
|
pub transaction_id: u32,
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,14 @@ use std::io::{Cursor, Write};
|
||||||
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar};
|
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar};
|
||||||
use azalea_core::position::Vec3;
|
use azalea_core::position::Vec3;
|
||||||
use azalea_protocol_macros::ServerboundGamePacket;
|
use azalea_protocol_macros::ServerboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
use crate::packets::BufReadError;
|
use crate::packets::BufReadError;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundInteract {
|
pub struct ServerboundInteract {
|
||||||
#[var]
|
#[var]
|
||||||
pub entity_id: u32,
|
pub entity_id: MinecraftEntityId,
|
||||||
pub action: ActionType,
|
pub action: ActionType,
|
||||||
/// Whether the player is sneaking
|
/// Whether the player is sneaking
|
||||||
pub using_secondary_action: bool,
|
pub using_secondary_action: bool,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ServerboundGamePacket;
|
use azalea_protocol_macros::ServerboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundPickItemFromEntity {
|
pub struct ServerboundPickItemFromEntity {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub include_data: bool,
|
pub include_data: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use azalea_buf::AzBuf;
|
use azalea_buf::AzBuf;
|
||||||
use azalea_protocol_macros::ServerboundGamePacket;
|
use azalea_protocol_macros::ServerboundGamePacket;
|
||||||
|
use azalea_world::MinecraftEntityId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
||||||
pub struct ServerboundPlayerCommand {
|
pub struct ServerboundPlayerCommand {
|
||||||
#[var]
|
#[var]
|
||||||
pub id: u32,
|
pub id: MinecraftEntityId,
|
||||||
pub action: Action,
|
pub action: Action,
|
||||||
#[var]
|
#[var]
|
||||||
pub data: u32,
|
pub data: u32,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use std::fmt::Formatter;
|
use std::fmt::{self, Display, Formatter};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
use std::io::{self, Cursor};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
|
@ -7,6 +8,7 @@ use std::{
|
||||||
|
|
||||||
use azalea_block::fluid_state::FluidState;
|
use azalea_block::fluid_state::FluidState;
|
||||||
use azalea_block::BlockState;
|
use azalea_block::BlockState;
|
||||||
|
use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
|
||||||
use azalea_core::position::{BlockPos, ChunkPos};
|
use azalea_core::position::{BlockPos, ChunkPos};
|
||||||
use azalea_core::registry_holder::RegistryHolder;
|
use azalea_core::registry_holder::RegistryHolder;
|
||||||
use bevy_ecs::{component::Component, entity::Entity};
|
use bevy_ecs::{component::Component, entity::Entity};
|
||||||
|
@ -39,20 +41,60 @@ impl PartialInstance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An entity ID used by Minecraft. These are not guaranteed to be unique in
|
/// An entity ID used by Minecraft.
|
||||||
/// shared worlds, that's what [`Entity`] is for.
|
///
|
||||||
|
/// These IDs are picked by the server. Some server softwares (like Bungeecord)
|
||||||
|
/// may pick entity IDs per-player, so you should avoid relying on them for
|
||||||
|
/// identifying IDs (especially if you're using a shared world -- i.e. a swarm).
|
||||||
|
///
|
||||||
|
/// You might find [`Entity`] more useful, since that's an ID decided by us that
|
||||||
|
/// is likely to be correct across shared worlds. You could also use the
|
||||||
|
/// `EntityUuid` from `azalea_entity`, that one is unlikely to change even
|
||||||
|
/// across server restarts.
|
||||||
|
///
|
||||||
|
/// This serializes as a i32. Usually it's a VarInt in the protocol, but not
|
||||||
|
/// always. If you do need it to serialize as a VarInt, make sure to use use the
|
||||||
|
/// `#[var]` attribute.
|
||||||
///
|
///
|
||||||
/// [`Entity`]: bevy_ecs::entity::Entity
|
/// [`Entity`]: bevy_ecs::entity::Entity
|
||||||
#[derive(Component, Copy, Clone, Debug, PartialEq, Eq, Deref, DerefMut)]
|
#[derive(Component, Copy, Clone, Debug, PartialEq, Eq, Deref, DerefMut)]
|
||||||
pub struct MinecraftEntityId(pub u32);
|
pub struct MinecraftEntityId(pub i32);
|
||||||
|
|
||||||
impl Hash for MinecraftEntityId {
|
impl Hash for MinecraftEntityId {
|
||||||
fn hash<H: Hasher>(&self, hasher: &mut H) {
|
fn hash<H: Hasher>(&self, hasher: &mut H) {
|
||||||
hasher.write_u32(self.0);
|
hasher.write_i32(self.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl nohash_hasher::IsEnabled for MinecraftEntityId {}
|
impl nohash_hasher::IsEnabled for MinecraftEntityId {}
|
||||||
|
|
||||||
|
// we can't have the default be #[var] because mojang doesn't use varints for
|
||||||
|
// entities sometimes :(
|
||||||
|
impl AzaleaRead for MinecraftEntityId {
|
||||||
|
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
|
||||||
|
i32::azalea_read(buf).map(MinecraftEntityId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl AzaleaWrite for MinecraftEntityId {
|
||||||
|
fn azalea_write(&self, buf: &mut impl io::Write) -> Result<(), io::Error> {
|
||||||
|
i32::azalea_write(&self.0, buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl AzaleaReadVar for MinecraftEntityId {
|
||||||
|
fn azalea_read_var(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
|
||||||
|
i32::azalea_read_var(buf).map(MinecraftEntityId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl AzaleaWriteVar for MinecraftEntityId {
|
||||||
|
fn azalea_write_var(&self, buf: &mut impl io::Write) -> Result<(), io::Error> {
|
||||||
|
i32::azalea_write_var(&self.0, buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Display for MinecraftEntityId {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(f, "eid({})", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Keep track of certain metadatas that are only relevant for this partial
|
/// Keep track of certain metadatas that are only relevant for this partial
|
||||||
/// world.
|
/// world.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue