Skip to content

Commit 864a137

Browse files
committed
Rename EntityId => NetorkId
1 parent b8dc118 commit 864a137

17 files changed

Lines changed: 44 additions & 44 deletions

File tree

server/entity/src/broadcasters/entity_creation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use feather_core::entitymeta::EntityMetadata;
22
use feather_core::network::packets::PacketEntityMetadata;
33
use feather_core::util::Position;
44
use feather_server_types::{
5-
CreationPacketCreator, EntityId, EntitySendEvent, EntitySpawnEvent, Game, Network,
5+
CreationPacketCreator, EntitySendEvent, EntitySpawnEvent, Game, Network, NetworkId,
66
PlayerJoinEvent, SpawnPacketCreator,
77
};
88
use fecs::{IntoQuery, Read, World};
@@ -29,7 +29,7 @@ pub fn on_entity_spawn_send_to_clients(
2929
// the entity immediately after sending.
3030
if let Some(meta) = world.try_get::<EntityMetadata>(event.entity) {
3131
let packet = PacketEntityMetadata {
32-
entity_id: world.get::<EntityId>(event.entity).0,
32+
entity_id: world.get::<NetworkId>(event.entity).0,
3333
metadata: (&*meta).clone(),
3434
};
3535
game.broadcast_entity_update(world, packet, event.entity, Some(event.entity));

server/entity/src/broadcasters/entity_deletion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use feather_core::network::packets::{DestroyEntities, PlayerInfo, PlayerInfoAction};
2-
use feather_server_types::{EntityDespawnEvent, EntityId, Game, Player, Uuid};
2+
use feather_server_types::{EntityDespawnEvent, Game, NetworkId, Player, Uuid};
33
use fecs::World;
44

55
/// Broadcasts when an entity is deleted.
@@ -9,7 +9,7 @@ pub fn on_entity_despawn_broadcast_despawn(
99
game: &mut Game,
1010
world: &mut World,
1111
) {
12-
let id = world.get::<EntityId>(event.entity).0;
12+
let id = world.get::<NetworkId>(event.entity).0;
1313
let packet = DestroyEntities {
1414
entity_ids: vec![id],
1515
};

server/entity/src/broadcasters/inventory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::inventory::Equipment;
44
use feather_core::inventory::{Inventory, SlotIndex, SLOT_HOTBAR_OFFSET};
55
use feather_core::network::packets::{EntityEquipment, SetSlot};
66
use feather_server_types::{
7-
EntityId, EntitySendEvent, Game, HeldItem, InventoryUpdateEvent, Network,
7+
EntitySendEvent, Game, HeldItem, InventoryUpdateEvent, Network, NetworkId,
88
};
99
use fecs::World;
1010
use num_traits::ToPrimitive;
@@ -26,7 +26,7 @@ pub fn on_inventory_update_broadcast_equipment_update(
2626
let item = inv.item_at(slot).cloned();
2727

2828
let packet = EntityEquipment {
29-
entity_id: world.get::<EntityId>(event.player).0,
29+
entity_id: world.get::<NetworkId>(event.player).0,
3030
slot: equipment.to_i32().unwrap(),
3131
item,
3232
};
@@ -74,7 +74,7 @@ pub fn on_entity_send_send_equipment(event: &EntitySendEvent, world: &mut World)
7474
let equipment_slot = equipment.to_i32().unwrap();
7575

7676
let packet = EntityEquipment {
77-
entity_id: world.get::<EntityId>(entity).0,
77+
entity_id: world.get::<NetworkId>(entity).0,
7878
slot: equipment_slot,
7979
item: Some(item),
8080
};

server/entity/src/broadcasters/item_collect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use feather_core::network::packets::CollectItem;
2-
use feather_server_types::{EntityId, Game, ItemCollectEvent};
2+
use feather_server_types::{Game, ItemCollectEvent, NetworkId};
33
use fecs::World;
44

55
/// Sends `CollectItem` packet when an item is collected.
66
#[fecs::event_handler]
77
pub fn on_item_collect_broadcast(event: &ItemCollectEvent, game: &Game, world: &mut World) {
88
let packet = CollectItem {
9-
collected: world.get::<EntityId>(event.item).0,
10-
collector: world.get::<EntityId>(event.collector).0,
9+
collected: world.get::<NetworkId>(event.item).0,
10+
collector: world.get::<NetworkId>(event.collector).0,
1111
count: event.amount as i32,
1212
};
1313

server/entity/src/broadcasters/metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use feather_core::entitymeta::EntityMetadata;
44
use feather_core::network::packets::PacketEntityMetadata;
5-
use feather_server_types::{EntityId, EntitySendEvent, Network};
5+
use feather_server_types::{EntitySendEvent, Network, NetworkId};
66
use fecs::World;
77

88
/// System which sends entity metadata when an entity
@@ -11,7 +11,7 @@ use fecs::World;
1111
pub fn on_entity_send_send_metadata(event: &EntitySendEvent, world: &mut World) {
1212
if let Some(metadata) = world.try_get::<EntityMetadata>(event.entity) {
1313
if let Some(network) = world.try_get::<Network>(event.client) {
14-
let entity_id = world.get::<EntityId>(event.entity).0;
14+
let entity_id = world.get::<NetworkId>(event.entity).0;
1515
let packet = PacketEntityMetadata {
1616
entity_id,
1717
metadata: (&*metadata).clone(),

server/entity/src/broadcasters/movement.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use feather_core::network::packets::{
66
use feather_core::network::Packet;
77
use feather_core::util::Position;
88
use feather_server_types::{
9-
EntityClientRemoveEvent, EntityId, EntitySendEvent, Game, LastKnownPositions, Network,
9+
EntityClientRemoveEvent, EntitySendEvent, Game, LastKnownPositions, Network, NetworkId,
1010
PreviousPosition, PreviousVelocity, Velocity,
1111
};
1212
use feather_server_util::{calculate_relative_move, degrees_to_stops, protocol_velocity};
@@ -17,7 +17,7 @@ use std::ops::Deref;
1717
/// System to broadcast when an entity moves.
1818
#[fecs::system]
1919
pub fn broadcast_movement(game: &mut Game, world: &mut World) {
20-
<(Read<Position>, Read<PreviousPosition>, Read<EntityId>)>::query().par_entities_for_each(
20+
<(Read<Position>, Read<PreviousPosition>, Read<NetworkId>)>::query().par_entities_for_each(
2121
world.inner(),
2222
|(entity, (pos, prev_pos, id))| {
2323
let pos: Position = *pos;
@@ -91,7 +91,7 @@ pub fn on_entity_client_remove_update_last_known_positions(
9191
/// Broadcasts an entity's velocity.
9292
#[fecs::system]
9393
pub fn broadcast_velocity(world: &mut World, game: &mut Game) {
94-
<(Read<Velocity>, Read<PreviousVelocity>, Read<EntityId>)>::query().par_entities_for_each(
94+
<(Read<Velocity>, Read<PreviousVelocity>, Read<NetworkId>)>::query().par_entities_for_each(
9595
world.inner(),
9696
|(entity, (vel, prev_vel, entity_id))| {
9797
let entity_id = entity_id.0;

server/entity/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub use object::item::{item_collect, on_item_drop_spawn_item_entity};
2222
extern crate nalgebra_glm as glm;
2323

2424
use feather_core::util::Position;
25-
use feather_server_types::{EntityId, PreviousPosition, PreviousVelocity, Velocity};
25+
use feather_server_types::{NetworkId, PreviousPosition, PreviousVelocity, Velocity};
2626
use fecs::{EntityBuilder, IntoQuery, Read, World, Write};
2727
use std::sync::atomic::{AtomicI32, Ordering};
2828

@@ -53,7 +53,7 @@ pub fn previous_position_velocity_reset(world: &mut World) {
5353
pub fn base() -> EntityBuilder {
5454
let id = new_id();
5555
EntityBuilder::new()
56-
.with(EntityId(id))
56+
.with(NetworkId(id))
5757
.with(Velocity::default())
5858
.with(PreviousVelocity::default())
5959
.with(PreviousPosition(position!(0.0, 0.0, 0.0)))

server/entity/src/mob.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use feather_core::entitymeta::EntityMetadata;
1212
use feather_core::network::packets::SpawnMob;
1313
use feather_core::network::Packet;
1414
use feather_core::util::Position;
15-
use feather_server_types::{EntityId, SpawnPacketCreator, Uuid, Velocity};
15+
use feather_server_types::{NetworkId, SpawnPacketCreator, Uuid, Velocity};
1616
use feather_server_util::{degrees_to_stops, protocol_velocity};
1717
use fecs::{EntityBuilder, EntityRef};
1818
pub use hostile::*;
@@ -97,7 +97,7 @@ pub fn base(kind: MobKind) -> EntityBuilder {
9797
/// Returns a `SpawnPacketCreator` for a mob with the given kind.
9898
pub fn spawn_packet_creator(kind: MobKind) -> SpawnPacketCreator {
9999
let f = Box::new(move |accessor: &EntityRef| {
100-
let entity_id = accessor.get::<EntityId>().0;
100+
let entity_id = accessor.get::<NetworkId>().0;
101101
let uuid = accessor
102102
.try_get::<Uuid>()
103103
.map(|r| *r)

server/entity/src/object/arrow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use feather_core::network::packets::SpawnObject;
33
use feather_core::network::Packet;
44
use feather_core::util::{Position, Vec3d};
55
use feather_server_types::{
6-
ComponentSerializer, EntityId, Game, PhysicsBuilder, SpawnPacketCreator, Uuid, Velocity,
6+
ComponentSerializer, Game, NetworkId, PhysicsBuilder, SpawnPacketCreator, Uuid, Velocity,
77
};
88
use feather_server_util::{degrees_to_stops, protocol_velocity};
99
use fecs::{EntityBuilder, EntityRef};
@@ -25,7 +25,7 @@ pub fn create() -> EntityBuilder {
2525
fn create_spawn_packet(accessor: &EntityRef) -> Box<dyn Packet> {
2626
let position = *accessor.get::<Position>();
2727
let velocity = *accessor.get::<Velocity>();
28-
let entity_id = accessor.get::<EntityId>().0;
28+
let entity_id = accessor.get::<NetworkId>().0;
2929

3030
let (velocity_x, velocity_y, velocity_z) = protocol_velocity(velocity.0);
3131

server/entity/src/object/falling_block.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use feather_core::network::packets::SpawnObject;
66
use feather_core::network::Packet;
77
use feather_core::util::{BlockPosition, Position};
88
use feather_server_types::{
9-
BumpVec, EntityId, EntityLandEvent, EntitySpawnEvent, Game, PhysicsBuilder, SpawnPacketCreator,
10-
Uuid, Velocity,
9+
BumpVec, EntityLandEvent, EntitySpawnEvent, Game, NetworkId, PhysicsBuilder,
10+
SpawnPacketCreator, Uuid, Velocity,
1111
};
1212
use feather_server_util::{
1313
degrees_to_stops, protocol_velocity, BlockNotifyBlock, BlockNotifyFallingBlock,
@@ -107,7 +107,7 @@ pub fn create(ty: BlockId, spawn_pos: BlockPosition) -> EntityBuilder {
107107
fn create_spawn_packet(accessor: &EntityRef) -> Box<dyn Packet> {
108108
let data = i32::from(accessor.get::<FallingBlockType>().0.vanilla_id());
109109
let position = accessor.get::<Position>();
110-
let entity_id = accessor.get::<EntityId>().0;
110+
let entity_id = accessor.get::<NetworkId>().0;
111111

112112
let velocity = accessor.get::<Velocity>().0;
113113

0 commit comments

Comments
 (0)