mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16: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(
|
||||
event.entity,
|
||||
ServerboundInteract {
|
||||
entity_id: *event.target,
|
||||
entity_id: event.target,
|
||||
action: s_interact::ActionType::Attack,
|
||||
using_secondary_action: **sneaking,
|
||||
},
|
||||
|
|
|
@ -303,7 +303,7 @@ fn send_sprinting_if_needed(
|
|||
send_packet_events.send(SendPacketEvent::new(
|
||||
entity,
|
||||
ServerboundPlayerCommand {
|
||||
id: **minecraft_entity_id,
|
||||
id: *minecraft_entity_id,
|
||||
action: sprinting_action,
|
||||
data: 0,
|
||||
},
|
||||
|
|
|
@ -301,7 +301,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
azalea_registry::EntityKind::Player,
|
||||
new_instance_name,
|
||||
);
|
||||
let entity_id = MinecraftEntityId(p.player_id);
|
||||
let entity_id = p.player_id;
|
||||
// insert our components into the ecs :)
|
||||
commands.entity(player_entity).insert((
|
||||
entity_id,
|
||||
|
@ -643,7 +643,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
let (mut entity_id_index, instance_name, tab_list) =
|
||||
query.get_mut(player_entity).unwrap();
|
||||
|
||||
let entity_id = MinecraftEntityId(p.id);
|
||||
let entity_id = p.id;
|
||||
|
||||
let Some(instance_name) = instance_name else {
|
||||
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 (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 {
|
||||
// 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 (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)
|
||||
// sometimes happens when killing mobs. it seems to be a vanilla bug, which is
|
||||
// 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 (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);
|
||||
continue;
|
||||
};
|
||||
|
@ -883,7 +883,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
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!(
|
||||
"Got move entity pos packet for unknown 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:?}");
|
||||
|
||||
let entity = entity_id_index.get(MinecraftEntityId(p.entity_id));
|
||||
let entity = entity_id_index.get(p.entity_id);
|
||||
|
||||
if let Some(entity) = entity {
|
||||
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 (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 {
|
||||
let new_look_direction = LookDirection {
|
||||
|
@ -1040,7 +1040,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
};
|
||||
|
||||
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");
|
||||
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 (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);
|
||||
death_events.send(DeathEvent {
|
||||
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 (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);
|
||||
continue;
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@ use azalea_protocol::packets::{
|
|||
ConnectionProtocol, Packet, ProtocolPacket,
|
||||
};
|
||||
use azalea_registry::DimensionType;
|
||||
use azalea_world::Instance;
|
||||
use azalea_world::{Instance, MinecraftEntityId};
|
||||
use bevy_app::App;
|
||||
use bevy_app::PluginGroup;
|
||||
use bevy_ecs::{prelude::*, schedule::ExecutorKind};
|
||||
|
@ -67,7 +67,7 @@ fn test_set_health_before_login() {
|
|||
assert_eq!(*simulation.component::<Health>(), 15.);
|
||||
|
||||
simulation.receive_packet(ClientboundLogin {
|
||||
player_id: 0,
|
||||
player_id: MinecraftEntityId(0),
|
||||
hardcore: false,
|
||||
levels: vec![],
|
||||
max_players: 20,
|
||||
|
|
|
@ -2,13 +2,14 @@ use azalea_buf::AzBuf;
|
|||
use azalea_core::{position::Vec3, resource_location::ResourceLocation};
|
||||
use azalea_entity::{metadata::apply_default_metadata, EntityBundle};
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundAddEntity {
|
||||
/// The id of the entity.
|
||||
/// The numeric ID of the entity being added to the world.
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub uuid: Uuid,
|
||||
pub entity_type: azalea_registry::EntityKind,
|
||||
pub position: Vec3,
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_core::position::Vec3;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundAddExperienceOrb {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub pos: Vec3,
|
||||
pub value: u16,
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundAnimate {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub action: AnimationAction,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_core::position::BlockPos;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundBlockDestruction {
|
||||
/// The ID of the entity breaking the block.
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub pos: BlockPos,
|
||||
/// 0–9 to set it, any other value to remove it.
|
||||
pub progress: u8,
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
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_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundDamageEvent {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
#[var]
|
||||
pub source_type_id: u32,
|
||||
pub source_cause_id: OptionalEntityId,
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundEntityEvent {
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub event_id: u8,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
use crate::common::movements::PositionMoveRotation;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundEntityPositionSync {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub values: PositionMoveRotation,
|
||||
pub on_ground: bool,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundHorseScreenOpen {
|
||||
|
@ -7,5 +8,5 @@ pub struct ClientboundHorseScreenOpen {
|
|||
pub container_id: i32,
|
||||
#[var]
|
||||
pub inventory_columns: u32,
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundHurtAnimation {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub yaw: f32,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
use crate::packets::common::CommonPlayerSpawnInfo;
|
||||
|
||||
|
@ -10,7 +11,7 @@ use crate::packets::common::CommonPlayerSpawnInfo;
|
|||
/// world, and the registry.
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundLogin {
|
||||
pub player_id: u32,
|
||||
pub player_id: MinecraftEntityId,
|
||||
pub hardcore: bool,
|
||||
pub levels: Vec<ResourceLocation>,
|
||||
#[var]
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_core::delta::PositionDelta8;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundMoveEntityPos {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub delta: PositionDelta8,
|
||||
pub on_ground: bool,
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_core::delta::PositionDelta8;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
/// This packet is sent by the server when an entity moves less then 8 blocks.
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundMoveEntityPosRot {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub delta: PositionDelta8,
|
||||
pub y_rot: i8,
|
||||
pub x_rot: i8,
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundMoveEntityRot {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub y_rot: i8,
|
||||
pub x_rot: i8,
|
||||
pub on_ground: bool,
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_core::position::Vec3;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundMoveMinecartAlongTrack {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub lerp_steps: Vec<MinecartStep>,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
/// Used to send a respawn screen.
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundPlayerCombatKill {
|
||||
#[var]
|
||||
pub player_id: u32,
|
||||
pub player_id: MinecraftEntityId,
|
||||
pub message: FormattedText,
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use crate::common::movements::{PositionMoveRotation, RelativeMovements};
|
|||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundPlayerPosition {
|
||||
/// The teleport ID.
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub change: PositionMoveRotation,
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundProjectilePower {
|
||||
pub id: u32,
|
||||
#[var]
|
||||
pub id: MinecraftEntityId,
|
||||
pub acceleration_power: f64,
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundRemoveEntities {
|
||||
#[var]
|
||||
pub entity_ids: Vec<u32>,
|
||||
pub entity_ids: Vec<MinecraftEntityId>,
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundRemoveMobEffect {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub effect: azalea_registry::MobEffect,
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundRotateHead {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub y_head_rot: i8,
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundSetCamera {
|
||||
#[var]
|
||||
pub camera_id: u32,
|
||||
pub camera_id: MinecraftEntityId,
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_entity::EntityMetadataItems;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundSetEntityData {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub packed_items: EntityMetadataItems,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundSetEntityLink {
|
||||
pub source_id: u32,
|
||||
pub dest_id: u32,
|
||||
pub source_id: MinecraftEntityId,
|
||||
pub dest_id: MinecraftEntityId,
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundSetEntityMotion {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub xa: i16,
|
||||
pub ya: i16,
|
||||
pub za: i16,
|
||||
|
|
|
@ -4,11 +4,12 @@ use azalea_buf::{AzBuf, BufReadError};
|
|||
use azalea_buf::{AzaleaRead, AzaleaWrite};
|
||||
use azalea_inventory::ItemStack;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundSetEquipment {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub slots: EquipmentSlots,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_registry::SoundEvent;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
use super::c_sound::{CustomSound, SoundSource};
|
||||
|
||||
|
@ -9,7 +10,7 @@ pub struct ClientboundSoundEntity {
|
|||
pub sound: azalea_registry::Holder<SoundEvent, CustomSound>,
|
||||
pub source: SoundSource,
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub volume: f32,
|
||||
pub pitch: f32,
|
||||
pub seed: u64,
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundTakeItemEntity {
|
||||
#[var]
|
||||
pub item_id: u32,
|
||||
#[var]
|
||||
pub player_id: u32,
|
||||
pub player_id: MinecraftEntityId,
|
||||
#[var]
|
||||
pub amount: u32,
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
use crate::common::movements::{PositionMoveRotation, RelativeMovements};
|
||||
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundTeleportEntity {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub change: PositionMoveRotation,
|
||||
pub relatives: RelativeMovements,
|
||||
pub on_ground: bool,
|
||||
|
|
|
@ -2,11 +2,12 @@ use azalea_buf::AzBuf;
|
|||
use azalea_entity::attributes::AttributeModifier;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_registry::Attribute;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundUpdateAttributes {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub values: Vec<AttributeSnapshot>,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use azalea_registry::MobEffect;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundUpdateMobEffect {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub mob_effect: MobEffect,
|
||||
#[var]
|
||||
pub effect_amplifier: u32,
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundEntityTagQuery {
|
||||
#[var]
|
||||
pub transaction_id: u32,
|
||||
#[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_core::position::Vec3;
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
use crate::packets::BufReadError;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundInteract {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
pub entity_id: MinecraftEntityId,
|
||||
pub action: ActionType,
|
||||
/// Whether the player is sneaking
|
||||
pub using_secondary_action: bool,
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundPickItemFromEntity {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub include_data: bool,
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use azalea_buf::AzBuf;
|
||||
use azalea_protocol_macros::ServerboundGamePacket;
|
||||
use azalea_world::MinecraftEntityId;
|
||||
|
||||
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
|
||||
pub struct ServerboundPlayerCommand {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub id: MinecraftEntityId,
|
||||
pub action: Action,
|
||||
#[var]
|
||||
pub data: u32,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::fmt::Formatter;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::io::{self, Cursor};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
fmt::Debug,
|
||||
|
@ -7,6 +8,7 @@ use std::{
|
|||
|
||||
use azalea_block::fluid_state::FluidState;
|
||||
use azalea_block::BlockState;
|
||||
use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
|
||||
use azalea_core::position::{BlockPos, ChunkPos};
|
||||
use azalea_core::registry_holder::RegistryHolder;
|
||||
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
|
||||
/// shared worlds, that's what [`Entity`] is for.
|
||||
/// An entity ID used by Minecraft.
|
||||
///
|
||||
/// 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
|
||||
#[derive(Component, Copy, Clone, Debug, PartialEq, Eq, Deref, DerefMut)]
|
||||
pub struct MinecraftEntityId(pub u32);
|
||||
pub struct MinecraftEntityId(pub i32);
|
||||
|
||||
impl Hash for MinecraftEntityId {
|
||||
fn hash<H: Hasher>(&self, hasher: &mut H) {
|
||||
hasher.write_u32(self.0);
|
||||
hasher.write_i32(self.0);
|
||||
}
|
||||
}
|
||||
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
|
||||
/// world.
|
||||
#[derive(Debug, Default)]
|
||||
|
|
Loading…
Add table
Reference in a new issue