mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 22:41:30 +11:00
Rename entity data
This commit is contained in:
parent
e21fd70160
commit
6b5e795f81
|
@ -357,13 +357,13 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
let field_index = field.index;
|
let field_index = field.index;
|
||||||
let default_expr = field.default_value.default_expr();
|
let default_expr = field.default_value.default_expr();
|
||||||
let type_id = field.default_value.type_id();
|
let type_id = field.default_value.type_id();
|
||||||
let encodeable = field.default_value.encodable_expr(quote!(self.#field_name));
|
let encodable = field.default_value.encodable_expr(quote!(self.#field_name));
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
if self.#field_name != (#default_expr) {
|
if self.#field_name != (#default_expr) {
|
||||||
data.push(#field_index);
|
data.push(#field_index);
|
||||||
VarInt(#type_id).encode(data).unwrap();
|
VarInt(#type_id).encode(data).unwrap();
|
||||||
#encodeable.encode(data).unwrap();
|
#encodable.encode(data).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -372,13 +372,13 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
let field_name = ident(&field.name);
|
let field_name = ident(&field.name);
|
||||||
let field_index = field.index;
|
let field_index = field.index;
|
||||||
let type_id = field.default_value.type_id();
|
let type_id = field.default_value.type_id();
|
||||||
let encodeable = field.default_value.encodable_expr(quote!(self.#field_name));
|
let encodable = field.default_value.encodable_expr(quote!(self.#field_name));
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
if (self.__modified_flags >> #field_index as #modified_flags_type) & 1 == 1 {
|
if (self.__modified_flags >> #field_index as #modified_flags_type) & 1 == 1 {
|
||||||
data.push(#field_index);
|
data.push(#field_index);
|
||||||
VarInt(#type_id).encode(data).unwrap();
|
VarInt(#type_id).encode(data).unwrap();
|
||||||
#encodeable.encode(data).unwrap();
|
#encodable.encode(data).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -446,11 +446,11 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum EntityEnum {
|
pub enum TrackedData {
|
||||||
#(#concrete_entity_names(#concrete_entity_names),)*
|
#(#concrete_entity_names(#concrete_entity_names),)*
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EntityEnum {
|
impl TrackedData {
|
||||||
pub(super) fn new(kind: EntityKind) -> Self {
|
pub(super) fn new(kind: EntityKind) -> Self {
|
||||||
match kind {
|
match kind {
|
||||||
#(EntityKind::#concrete_entity_names => Self::#concrete_entity_names(#concrete_entity_names::new()),)*
|
#(EntityKind::#concrete_entity_names => Self::#concrete_entity_names(#concrete_entity_names::new()),)*
|
||||||
|
|
|
@ -7,7 +7,7 @@ use valence::client::{ClientId, Event, GameMode, Hand, InteractWithEntityKind};
|
||||||
use valence::config::{Config, ServerListPing};
|
use valence::config::{Config, ServerListPing};
|
||||||
use valence::dimension::DimensionId;
|
use valence::dimension::DimensionId;
|
||||||
use valence::entity::data::Pose;
|
use valence::entity::data::Pose;
|
||||||
use valence::entity::{EntityEnum, EntityId, EntityKind, Event as EntityEvent};
|
use valence::entity::{TrackedData, EntityId, EntityKind, Event as EntityEvent};
|
||||||
use valence::server::{Server, SharedServer, ShutdownResult};
|
use valence::server::{Server, SharedServer, ShutdownResult};
|
||||||
use valence::text::{Color, TextFormat};
|
use valence::text::{Color, TextFormat};
|
||||||
use valence::{async_trait, Ticks};
|
use valence::{async_trait, Ticks};
|
||||||
|
@ -232,7 +232,7 @@ impl Config for Game {
|
||||||
player.set_pitch(client.pitch());
|
player.set_pitch(client.pitch());
|
||||||
player.set_on_ground(client.on_ground());
|
player.set_on_ground(client.on_ground());
|
||||||
|
|
||||||
if let EntityEnum::Player(player) = player.view_mut() {
|
if let TrackedData::Player(player) = player.view_mut() {
|
||||||
if client.is_sneaking() {
|
if client.is_sneaking() {
|
||||||
player.set_pose(Pose::Sneaking);
|
player.set_pose(Pose::Sneaking);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,7 +11,7 @@ use valence::client::{Event, Hand};
|
||||||
use valence::config::{Config, ServerListPing};
|
use valence::config::{Config, ServerListPing};
|
||||||
use valence::dimension::{Dimension, DimensionId};
|
use valence::dimension::{Dimension, DimensionId};
|
||||||
use valence::entity::data::Pose;
|
use valence::entity::data::Pose;
|
||||||
use valence::entity::{EntityEnum, EntityId, EntityKind, Event as EntityEvent};
|
use valence::entity::{TrackedData, EntityId, EntityKind, Event as EntityEvent};
|
||||||
use valence::server::{Server, SharedServer, ShutdownResult};
|
use valence::server::{Server, SharedServer, ShutdownResult};
|
||||||
use valence::text::{Color, TextFormat};
|
use valence::text::{Color, TextFormat};
|
||||||
use valence::{async_trait, ident};
|
use valence::{async_trait, ident};
|
||||||
|
@ -194,7 +194,7 @@ impl Config for Game {
|
||||||
player.set_pitch(client.pitch());
|
player.set_pitch(client.pitch());
|
||||||
player.set_on_ground(client.on_ground());
|
player.set_on_ground(client.on_ground());
|
||||||
|
|
||||||
if let EntityEnum::Player(player) = player.view_mut() {
|
if let TrackedData::Player(player) = player.view_mut() {
|
||||||
if client.is_sneaking() {
|
if client.is_sneaking() {
|
||||||
player.set_pose(Pose::Sneaking);
|
player.set_pose(Pose::Sneaking);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,7 +7,7 @@ use valence::block::{BlockPos, BlockState};
|
||||||
use valence::client::GameMode;
|
use valence::client::GameMode;
|
||||||
use valence::config::{Config, ServerListPing};
|
use valence::config::{Config, ServerListPing};
|
||||||
use valence::dimension::DimensionId;
|
use valence::dimension::DimensionId;
|
||||||
use valence::entity::{EntityEnum, EntityKind};
|
use valence::entity::{TrackedData, EntityKind};
|
||||||
use valence::server::{Server, SharedServer, ShutdownResult};
|
use valence::server::{Server, SharedServer, ShutdownResult};
|
||||||
use valence::spatial_index::RaycastHit;
|
use valence::spatial_index::RaycastHit;
|
||||||
use valence::text::{Color, TextFormat};
|
use valence::text::{Color, TextFormat};
|
||||||
|
@ -167,7 +167,7 @@ impl Config for Game {
|
||||||
|
|
||||||
for (_, e) in server.entities.iter_mut() {
|
for (_, e) in server.entities.iter_mut() {
|
||||||
let intersected = e.state;
|
let intersected = e.state;
|
||||||
if let EntityEnum::Sheep(sheep) = &mut e.view_mut() {
|
if let TrackedData::Sheep(sheep) = &mut e.view_mut() {
|
||||||
if intersected {
|
if intersected {
|
||||||
sheep.set_color(5);
|
sheep.set_color(5);
|
||||||
} else {
|
} else {
|
||||||
|
|
252
src/entity.rs
252
src/entity.rs
|
@ -6,7 +6,7 @@ use std::iter::FusedIterator;
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
use bitfield_struct::bitfield;
|
use bitfield_struct::bitfield;
|
||||||
pub use kinds::{EntityEnum, EntityKind};
|
pub use kinds::{TrackedData, EntityKind};
|
||||||
use rayon::iter::ParallelIterator;
|
use rayon::iter::ParallelIterator;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use vek::{Aabb, Vec3};
|
use vek::{Aabb, Vec3};
|
||||||
|
@ -74,7 +74,7 @@ impl<C: Config> Entities<C> {
|
||||||
Entry::Vacant(ve) => {
|
Entry::Vacant(ve) => {
|
||||||
let (k, e) = self.sm.insert(Entity {
|
let (k, e) = self.sm.insert(Entity {
|
||||||
state: data,
|
state: data,
|
||||||
variants: EntityEnum::new(kind),
|
variants: TrackedData::new(kind),
|
||||||
events: Vec::new(),
|
events: Vec::new(),
|
||||||
flags: EntityFlags(0),
|
flags: EntityFlags(0),
|
||||||
world: WorldId::NULL,
|
world: WorldId::NULL,
|
||||||
|
@ -243,7 +243,7 @@ impl EntityId {
|
||||||
pub struct Entity<C: Config> {
|
pub struct Entity<C: Config> {
|
||||||
/// Custom data.
|
/// Custom data.
|
||||||
pub state: C::EntityState,
|
pub state: C::EntityState,
|
||||||
variants: EntityEnum,
|
variants: TrackedData,
|
||||||
flags: EntityFlags,
|
flags: EntityFlags,
|
||||||
events: Vec<Event>,
|
events: Vec<Event>,
|
||||||
world: WorldId,
|
world: WorldId,
|
||||||
|
@ -271,11 +271,11 @@ impl<C: Config> Entity<C> {
|
||||||
self.flags
|
self.flags
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> &EntityEnum {
|
pub fn view(&self) -> &TrackedData {
|
||||||
&self.variants
|
&self.variants
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_mut(&mut self) -> &mut EntityEnum {
|
pub fn view_mut(&mut self) -> &mut TrackedData {
|
||||||
&mut self.variants
|
&mut self.variants
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,17 +408,17 @@ impl<C: Config> Entity<C> {
|
||||||
/// [interact event]: crate::client::Event::InteractWithEntity
|
/// [interact event]: crate::client::Event::InteractWithEntity
|
||||||
pub fn hitbox(&self) -> Aabb<f64> {
|
pub fn hitbox(&self) -> Aabb<f64> {
|
||||||
let dims = match &self.variants {
|
let dims = match &self.variants {
|
||||||
EntityEnum::Allay(_) => [0.6, 0.35, 0.6],
|
TrackedData::Allay(_) => [0.6, 0.35, 0.6],
|
||||||
EntityEnum::ChestBoat(_) => [1.375, 0.5625, 1.375],
|
TrackedData::ChestBoat(_) => [1.375, 0.5625, 1.375],
|
||||||
EntityEnum::Frog(_) => [0.5, 0.5, 0.5],
|
TrackedData::Frog(_) => [0.5, 0.5, 0.5],
|
||||||
EntityEnum::Tadpole(_) => [0.4, 0.3, 0.4],
|
TrackedData::Tadpole(_) => [0.4, 0.3, 0.4],
|
||||||
EntityEnum::Warden(_) => [0.9, 2.9, 0.9],
|
TrackedData::Warden(_) => [0.9, 2.9, 0.9],
|
||||||
EntityEnum::AreaEffectCloud(e) => [
|
TrackedData::AreaEffectCloud(e) => [
|
||||||
e.get_radius() as f64 * 2.0,
|
e.get_radius() as f64 * 2.0,
|
||||||
0.5,
|
0.5,
|
||||||
e.get_radius() as f64 * 2.0,
|
e.get_radius() as f64 * 2.0,
|
||||||
],
|
],
|
||||||
EntityEnum::ArmorStand(e) => {
|
TrackedData::ArmorStand(e) => {
|
||||||
if e.get_marker() {
|
if e.get_marker() {
|
||||||
[0.0, 0.0, 0.0]
|
[0.0, 0.0, 0.0]
|
||||||
} else if e.get_small() {
|
} else if e.get_small() {
|
||||||
|
@ -427,123 +427,123 @@ impl<C: Config> Entity<C> {
|
||||||
[0.5, 1.975, 0.5]
|
[0.5, 1.975, 0.5]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EntityEnum::Arrow(_) => [0.5, 0.5, 0.5],
|
TrackedData::Arrow(_) => [0.5, 0.5, 0.5],
|
||||||
EntityEnum::Axolotl(_) => [1.3, 0.6, 1.3],
|
TrackedData::Axolotl(_) => [1.3, 0.6, 1.3],
|
||||||
EntityEnum::Bat(_) => [0.5, 0.9, 0.5],
|
TrackedData::Bat(_) => [0.5, 0.9, 0.5],
|
||||||
EntityEnum::Bee(_) => [0.7, 0.6, 0.7], // TODO: baby size?
|
TrackedData::Bee(_) => [0.7, 0.6, 0.7], // TODO: baby size?
|
||||||
EntityEnum::Blaze(_) => [0.6, 1.8, 0.6],
|
TrackedData::Blaze(_) => [0.6, 1.8, 0.6],
|
||||||
EntityEnum::Boat(_) => [1.375, 0.5625, 1.375],
|
TrackedData::Boat(_) => [1.375, 0.5625, 1.375],
|
||||||
EntityEnum::Cat(_) => [0.6, 0.7, 0.6],
|
TrackedData::Cat(_) => [0.6, 0.7, 0.6],
|
||||||
EntityEnum::CaveSpider(_) => [0.7, 0.5, 0.7],
|
TrackedData::CaveSpider(_) => [0.7, 0.5, 0.7],
|
||||||
EntityEnum::Chicken(_) => [0.4, 0.7, 0.4], // TODO: baby size?
|
TrackedData::Chicken(_) => [0.4, 0.7, 0.4], // TODO: baby size?
|
||||||
EntityEnum::Cod(_) => [0.5, 0.3, 0.5],
|
TrackedData::Cod(_) => [0.5, 0.3, 0.5],
|
||||||
EntityEnum::Cow(_) => [0.9, 1.4, 0.9], // TODO: baby size?
|
TrackedData::Cow(_) => [0.9, 1.4, 0.9], // TODO: baby size?
|
||||||
EntityEnum::Creeper(_) => [0.6, 1.7, 0.6],
|
TrackedData::Creeper(_) => [0.6, 1.7, 0.6],
|
||||||
EntityEnum::Dolphin(_) => [0.9, 0.6, 0.9],
|
TrackedData::Dolphin(_) => [0.9, 0.6, 0.9],
|
||||||
EntityEnum::Donkey(_) => [1.5, 1.39648, 1.5], // TODO: baby size?
|
TrackedData::Donkey(_) => [1.5, 1.39648, 1.5], // TODO: baby size?
|
||||||
EntityEnum::DragonFireball(_) => [1.0, 1.0, 1.0],
|
TrackedData::DragonFireball(_) => [1.0, 1.0, 1.0],
|
||||||
EntityEnum::Drowned(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
TrackedData::Drowned(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
||||||
EntityEnum::ElderGuardian(_) => [1.9975, 1.9975, 1.9975],
|
TrackedData::ElderGuardian(_) => [1.9975, 1.9975, 1.9975],
|
||||||
EntityEnum::EndCrystal(_) => [2.0, 2.0, 2.0],
|
TrackedData::EndCrystal(_) => [2.0, 2.0, 2.0],
|
||||||
EntityEnum::EnderDragon(_) => [16.0, 8.0, 16.0],
|
TrackedData::EnderDragon(_) => [16.0, 8.0, 16.0],
|
||||||
EntityEnum::Enderman(_) => [0.6, 2.9, 0.6],
|
TrackedData::Enderman(_) => [0.6, 2.9, 0.6],
|
||||||
EntityEnum::Endermite(_) => [0.4, 0.3, 0.4],
|
TrackedData::Endermite(_) => [0.4, 0.3, 0.4],
|
||||||
EntityEnum::Evoker(_) => [0.6, 1.95, 0.6],
|
TrackedData::Evoker(_) => [0.6, 1.95, 0.6],
|
||||||
EntityEnum::EvokerFangs(_) => [0.5, 0.8, 0.5],
|
TrackedData::EvokerFangs(_) => [0.5, 0.8, 0.5],
|
||||||
EntityEnum::ExperienceOrb(_) => [0.5, 0.5, 0.5],
|
TrackedData::ExperienceOrb(_) => [0.5, 0.5, 0.5],
|
||||||
EntityEnum::EyeOfEnder(_) => [0.25, 0.25, 0.25],
|
TrackedData::EyeOfEnder(_) => [0.25, 0.25, 0.25],
|
||||||
EntityEnum::FallingBlock(_) => [0.98, 0.98, 0.98],
|
TrackedData::FallingBlock(_) => [0.98, 0.98, 0.98],
|
||||||
EntityEnum::FireworkRocket(_) => [0.25, 0.25, 0.25],
|
TrackedData::FireworkRocket(_) => [0.25, 0.25, 0.25],
|
||||||
EntityEnum::Fox(_) => [0.6, 0.7, 0.6], // TODO: baby size?
|
TrackedData::Fox(_) => [0.6, 0.7, 0.6], // TODO: baby size?
|
||||||
EntityEnum::Ghast(_) => [4.0, 4.0, 4.0],
|
TrackedData::Ghast(_) => [4.0, 4.0, 4.0],
|
||||||
EntityEnum::Giant(_) => [3.6, 12.0, 3.6],
|
TrackedData::Giant(_) => [3.6, 12.0, 3.6],
|
||||||
EntityEnum::GlowItemFrame(_) => todo!("account for rotation"),
|
TrackedData::GlowItemFrame(_) => todo!("account for rotation"),
|
||||||
EntityEnum::GlowSquid(_) => [0.8, 0.8, 0.8],
|
TrackedData::GlowSquid(_) => [0.8, 0.8, 0.8],
|
||||||
EntityEnum::Goat(_) => [1.3, 0.9, 1.3], // TODO: baby size?
|
TrackedData::Goat(_) => [1.3, 0.9, 1.3], // TODO: baby size?
|
||||||
EntityEnum::Guardian(_) => [0.85, 0.85, 0.85],
|
TrackedData::Guardian(_) => [0.85, 0.85, 0.85],
|
||||||
EntityEnum::Hoglin(_) => [1.39648, 1.4, 1.39648], // TODO: baby size?
|
TrackedData::Hoglin(_) => [1.39648, 1.4, 1.39648], // TODO: baby size?
|
||||||
EntityEnum::Horse(_) => [1.39648, 1.6, 1.39648], // TODO: baby size?
|
TrackedData::Horse(_) => [1.39648, 1.6, 1.39648], // TODO: baby size?
|
||||||
EntityEnum::Husk(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
TrackedData::Husk(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
||||||
EntityEnum::Illusioner(_) => [0.6, 1.95, 0.6],
|
TrackedData::Illusioner(_) => [0.6, 1.95, 0.6],
|
||||||
EntityEnum::IronGolem(_) => [1.4, 2.7, 1.4],
|
TrackedData::IronGolem(_) => [1.4, 2.7, 1.4],
|
||||||
EntityEnum::Item(_) => [0.25, 0.25, 0.25],
|
TrackedData::Item(_) => [0.25, 0.25, 0.25],
|
||||||
EntityEnum::ItemFrame(_) => todo!("account for rotation"),
|
TrackedData::ItemFrame(_) => todo!("account for rotation"),
|
||||||
EntityEnum::Fireball(_) => [1.0, 1.0, 1.0],
|
TrackedData::Fireball(_) => [1.0, 1.0, 1.0],
|
||||||
EntityEnum::LeashKnot(_) => [0.375, 0.5, 0.375],
|
TrackedData::LeashKnot(_) => [0.375, 0.5, 0.375],
|
||||||
EntityEnum::Lightning(_) => [0.0, 0.0, 0.0],
|
TrackedData::Lightning(_) => [0.0, 0.0, 0.0],
|
||||||
EntityEnum::Llama(_) => [0.9, 1.87, 0.9], // TODO: baby size?
|
TrackedData::Llama(_) => [0.9, 1.87, 0.9], // TODO: baby size?
|
||||||
EntityEnum::LlamaSpit(_) => [0.25, 0.25, 0.25],
|
TrackedData::LlamaSpit(_) => [0.25, 0.25, 0.25],
|
||||||
EntityEnum::MagmaCube(e) => {
|
TrackedData::MagmaCube(e) => {
|
||||||
let s = e.get_slime_size() as f64 * 0.51000005;
|
let s = e.get_slime_size() as f64 * 0.51000005;
|
||||||
[s, s, s]
|
[s, s, s]
|
||||||
}
|
}
|
||||||
EntityEnum::Marker(_) => [0.0, 0.0, 0.0],
|
TrackedData::Marker(_) => [0.0, 0.0, 0.0],
|
||||||
EntityEnum::Minecart(_) => [0.98, 0.7, 0.98],
|
TrackedData::Minecart(_) => [0.98, 0.7, 0.98],
|
||||||
EntityEnum::ChestMinecart(_) => [0.98, 0.7, 0.98],
|
TrackedData::ChestMinecart(_) => [0.98, 0.7, 0.98],
|
||||||
EntityEnum::CommandBlockMinecart(_) => [0.98, 0.7, 0.98],
|
TrackedData::CommandBlockMinecart(_) => [0.98, 0.7, 0.98],
|
||||||
EntityEnum::FurnaceMinecart(_) => [0.98, 0.7, 0.98],
|
TrackedData::FurnaceMinecart(_) => [0.98, 0.7, 0.98],
|
||||||
EntityEnum::HopperMinecart(_) => [0.98, 0.7, 0.98],
|
TrackedData::HopperMinecart(_) => [0.98, 0.7, 0.98],
|
||||||
EntityEnum::SpawnerMinecart(_) => [0.98, 0.7, 0.98],
|
TrackedData::SpawnerMinecart(_) => [0.98, 0.7, 0.98],
|
||||||
EntityEnum::TntMinecart(_) => [0.98, 0.7, 0.98],
|
TrackedData::TntMinecart(_) => [0.98, 0.7, 0.98],
|
||||||
EntityEnum::Mule(_) => [1.39648, 1.6, 1.39648], // TODO: baby size?
|
TrackedData::Mule(_) => [1.39648, 1.6, 1.39648], // TODO: baby size?
|
||||||
EntityEnum::Mooshroom(_) => [0.9, 1.4, 0.9], // TODO: baby size?
|
TrackedData::Mooshroom(_) => [0.9, 1.4, 0.9], // TODO: baby size?
|
||||||
EntityEnum::Ocelot(_) => [0.6, 0.7, 0.6], // TODO: baby size?
|
TrackedData::Ocelot(_) => [0.6, 0.7, 0.6], // TODO: baby size?
|
||||||
EntityEnum::Painting(_) => todo!("account for rotation and type"),
|
TrackedData::Painting(_) => todo!("account for rotation and type"),
|
||||||
EntityEnum::Panda(_) => [0.6, 0.7, 0.6], // TODO: baby size?
|
TrackedData::Panda(_) => [0.6, 0.7, 0.6], // TODO: baby size?
|
||||||
EntityEnum::Parrot(_) => [0.5, 0.9, 0.5],
|
TrackedData::Parrot(_) => [0.5, 0.9, 0.5],
|
||||||
EntityEnum::Phantom(_) => [0.9, 0.5, 0.9],
|
TrackedData::Phantom(_) => [0.9, 0.5, 0.9],
|
||||||
EntityEnum::Pig(_) => [0.9, 0.9, 0.9], // TODO: baby size?
|
TrackedData::Pig(_) => [0.9, 0.9, 0.9], // TODO: baby size?
|
||||||
EntityEnum::Piglin(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
TrackedData::Piglin(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
||||||
EntityEnum::PiglinBrute(_) => [0.6, 1.95, 0.6],
|
TrackedData::PiglinBrute(_) => [0.6, 1.95, 0.6],
|
||||||
EntityEnum::Pillager(_) => [0.6, 1.95, 0.6],
|
TrackedData::Pillager(_) => [0.6, 1.95, 0.6],
|
||||||
EntityEnum::PolarBear(_) => [1.4, 1.4, 1.4], // TODO: baby size?
|
TrackedData::PolarBear(_) => [1.4, 1.4, 1.4], // TODO: baby size?
|
||||||
EntityEnum::Tnt(_) => [0.98, 0.98, 0.98],
|
TrackedData::Tnt(_) => [0.98, 0.98, 0.98],
|
||||||
EntityEnum::Pufferfish(_) => [0.7, 0.7, 0.7],
|
TrackedData::Pufferfish(_) => [0.7, 0.7, 0.7],
|
||||||
EntityEnum::Rabbit(_) => [0.4, 0.5, 0.4], // TODO: baby size?
|
TrackedData::Rabbit(_) => [0.4, 0.5, 0.4], // TODO: baby size?
|
||||||
EntityEnum::Ravager(_) => [1.95, 2.2, 1.95],
|
TrackedData::Ravager(_) => [1.95, 2.2, 1.95],
|
||||||
EntityEnum::Salmon(_) => [0.7, 0.4, 0.7],
|
TrackedData::Salmon(_) => [0.7, 0.4, 0.7],
|
||||||
EntityEnum::Sheep(_) => [0.9, 1.3, 0.9], // TODO: baby size?
|
TrackedData::Sheep(_) => [0.9, 1.3, 0.9], // TODO: baby size?
|
||||||
EntityEnum::Shulker(_) => [1.0, 1.0, 1.0], // TODO: how is height calculated?
|
TrackedData::Shulker(_) => [1.0, 1.0, 1.0], // TODO: how is height calculated?
|
||||||
EntityEnum::ShulkerBullet(_) => [0.3125, 0.3125, 0.3125],
|
TrackedData::ShulkerBullet(_) => [0.3125, 0.3125, 0.3125],
|
||||||
EntityEnum::Silverfish(_) => [0.4, 0.3, 0.4],
|
TrackedData::Silverfish(_) => [0.4, 0.3, 0.4],
|
||||||
EntityEnum::Skeleton(_) => [0.6, 1.99, 0.6],
|
TrackedData::Skeleton(_) => [0.6, 1.99, 0.6],
|
||||||
EntityEnum::SkeletonHorse(_) => [1.39648, 1.6, 1.39648], // TODO: baby size?
|
TrackedData::SkeletonHorse(_) => [1.39648, 1.6, 1.39648], // TODO: baby size?
|
||||||
EntityEnum::Slime(e) => {
|
TrackedData::Slime(e) => {
|
||||||
let s = 0.51000005 * e.get_slime_size() as f64;
|
let s = 0.51000005 * e.get_slime_size() as f64;
|
||||||
[s, s, s]
|
[s, s, s]
|
||||||
}
|
}
|
||||||
EntityEnum::SmallFireball(_) => [0.3125, 0.3125, 0.3125],
|
TrackedData::SmallFireball(_) => [0.3125, 0.3125, 0.3125],
|
||||||
EntityEnum::SnowGolem(_) => [0.7, 1.9, 0.7],
|
TrackedData::SnowGolem(_) => [0.7, 1.9, 0.7],
|
||||||
EntityEnum::Snowball(_) => [0.25, 0.25, 0.25],
|
TrackedData::Snowball(_) => [0.25, 0.25, 0.25],
|
||||||
EntityEnum::SpectralArrow(_) => [0.5, 0.5, 0.5],
|
TrackedData::SpectralArrow(_) => [0.5, 0.5, 0.5],
|
||||||
EntityEnum::Spider(_) => [1.4, 0.9, 1.4],
|
TrackedData::Spider(_) => [1.4, 0.9, 1.4],
|
||||||
EntityEnum::Squid(_) => [0.8, 0.8, 0.8],
|
TrackedData::Squid(_) => [0.8, 0.8, 0.8],
|
||||||
EntityEnum::Stray(_) => [0.6, 1.99, 0.6],
|
TrackedData::Stray(_) => [0.6, 1.99, 0.6],
|
||||||
EntityEnum::Strider(_) => [0.9, 1.7, 0.9], // TODO: baby size?
|
TrackedData::Strider(_) => [0.9, 1.7, 0.9], // TODO: baby size?
|
||||||
EntityEnum::Egg(_) => [0.25, 0.25, 0.25],
|
TrackedData::Egg(_) => [0.25, 0.25, 0.25],
|
||||||
EntityEnum::EnderPearl(_) => [0.25, 0.25, 0.25],
|
TrackedData::EnderPearl(_) => [0.25, 0.25, 0.25],
|
||||||
EntityEnum::ExperienceBottle(_) => [0.25, 0.25, 0.25],
|
TrackedData::ExperienceBottle(_) => [0.25, 0.25, 0.25],
|
||||||
EntityEnum::Potion(_) => [0.25, 0.25, 0.25],
|
TrackedData::Potion(_) => [0.25, 0.25, 0.25],
|
||||||
EntityEnum::Trident(_) => [0.5, 0.5, 0.5],
|
TrackedData::Trident(_) => [0.5, 0.5, 0.5],
|
||||||
EntityEnum::TraderLlama(_) => [0.9, 1.87, 0.9],
|
TrackedData::TraderLlama(_) => [0.9, 1.87, 0.9],
|
||||||
EntityEnum::TropicalFish(_) => [0.5, 0.4, 0.5],
|
TrackedData::TropicalFish(_) => [0.5, 0.4, 0.5],
|
||||||
EntityEnum::Turtle(_) => [1.2, 0.4, 1.2], // TODO: baby size?
|
TrackedData::Turtle(_) => [1.2, 0.4, 1.2], // TODO: baby size?
|
||||||
EntityEnum::Vex(_) => [0.4, 0.8, 0.4],
|
TrackedData::Vex(_) => [0.4, 0.8, 0.4],
|
||||||
EntityEnum::Villager(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
TrackedData::Villager(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
||||||
EntityEnum::Vindicator(_) => [0.6, 1.95, 0.6],
|
TrackedData::Vindicator(_) => [0.6, 1.95, 0.6],
|
||||||
EntityEnum::WanderingTrader(_) => [0.6, 1.95, 0.6],
|
TrackedData::WanderingTrader(_) => [0.6, 1.95, 0.6],
|
||||||
EntityEnum::Witch(_) => [0.6, 1.95, 0.6],
|
TrackedData::Witch(_) => [0.6, 1.95, 0.6],
|
||||||
EntityEnum::Wither(_) => [0.9, 3.5, 0.9],
|
TrackedData::Wither(_) => [0.9, 3.5, 0.9],
|
||||||
EntityEnum::WitherSkeleton(_) => [0.7, 2.4, 0.7],
|
TrackedData::WitherSkeleton(_) => [0.7, 2.4, 0.7],
|
||||||
EntityEnum::WitherSkull(_) => [0.3125, 0.3125, 0.3125],
|
TrackedData::WitherSkull(_) => [0.3125, 0.3125, 0.3125],
|
||||||
EntityEnum::Wolf(_) => [0.6, 0.85, 0.6], // TODO: baby size?
|
TrackedData::Wolf(_) => [0.6, 0.85, 0.6], // TODO: baby size?
|
||||||
EntityEnum::Zoglin(_) => [1.39648, 1.4, 1.39648], // TODO: baby size?
|
TrackedData::Zoglin(_) => [1.39648, 1.4, 1.39648], // TODO: baby size?
|
||||||
EntityEnum::Zombie(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
TrackedData::Zombie(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
||||||
EntityEnum::ZombieHorse(_) => [1.39648, 1.6, 1.39648], // TODO: baby size?
|
TrackedData::ZombieHorse(_) => [1.39648, 1.6, 1.39648], // TODO: baby size?
|
||||||
EntityEnum::ZombieVillager(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
TrackedData::ZombieVillager(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
||||||
EntityEnum::ZombifiedPiglin(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
TrackedData::ZombifiedPiglin(_) => [0.6, 1.95, 0.6], // TODO: baby size?
|
||||||
EntityEnum::Player(_) => [0.6, 1.8, 0.6], // TODO: changes depending on the pose.
|
TrackedData::Player(_) => [0.6, 1.8, 0.6], // TODO: changes depending on the pose.
|
||||||
EntityEnum::FishingBobber(_) => [0.25, 0.25, 0.25],
|
TrackedData::FishingBobber(_) => [0.25, 0.25, 0.25],
|
||||||
};
|
};
|
||||||
|
|
||||||
aabb_from_bottom_and_size(self.new_position, dims.into())
|
aabb_from_bottom_and_size(self.new_position, dims.into())
|
||||||
|
@ -583,15 +583,15 @@ impl<C: Config> Entity<C> {
|
||||||
|
|
||||||
pub(crate) fn spawn_packet(&self, this_id: EntityId) -> Option<EntitySpawnPacket> {
|
pub(crate) fn spawn_packet(&self, this_id: EntityId) -> Option<EntitySpawnPacket> {
|
||||||
match &self.variants {
|
match &self.variants {
|
||||||
EntityEnum::Marker(_) => None,
|
TrackedData::Marker(_) => None,
|
||||||
EntityEnum::ExperienceOrb(_) => {
|
TrackedData::ExperienceOrb(_) => {
|
||||||
Some(EntitySpawnPacket::ExperienceOrb(ExperienceOrbSpawn {
|
Some(EntitySpawnPacket::ExperienceOrb(ExperienceOrbSpawn {
|
||||||
entity_id: VarInt(this_id.to_network_id()),
|
entity_id: VarInt(this_id.to_network_id()),
|
||||||
position: self.new_position,
|
position: self.new_position,
|
||||||
count: 0, // TODO
|
count: 0, // TODO
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
EntityEnum::Player(_) => Some(EntitySpawnPacket::Player(PlayerSpawn {
|
TrackedData::Player(_) => Some(EntitySpawnPacket::Player(PlayerSpawn {
|
||||||
entity_id: VarInt(this_id.to_network_id()),
|
entity_id: VarInt(this_id.to_network_id()),
|
||||||
player_uuid: self.uuid,
|
player_uuid: self.uuid,
|
||||||
position: self.new_position,
|
position: self.new_position,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! Contains the [`EntityEnum`] and the types for each variant.
|
//! Contains the [`TrackedData`] and the types for each variant.
|
||||||
|
|
||||||
#![allow(clippy::all, missing_docs, trivial_numeric_casts)]
|
#![allow(clippy::all, missing_docs, trivial_numeric_casts)]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue