Server: track primed TNT, falling blocks, projectiles, tridents, fireworks and crystals

These entities had no id in Horizon, so a server could not send them to
its clients. Each now has one, given from the entity counter before it is
first tracked, and goes to guests as vanilla's ServerEntity sends it:

- primed TNT with its fuse (sent each tick it changes) and falling blocks
  with their block state and start position; both sync their exact
  position while they touch a block (requiresPrecisePosition);
- arrows and tridents send their position and rotation every update
  (AbstractArrow), with their flags, pierce level, in-ground state,
  loyalty and foil; their owner is the spawn data;
- fireballs, wither skulls and wind charges bundle their velocity with
  ClientboundProjectilePowerPacket (new in horizon-protocol);
- snowballs, eggs, pearls, llama spit, shulker bullets and splash potions;
- firework rockets with their item, the player they boost and whether
  they were shot at an angle; end crystals with their beam and base.

The entity harness's scene gains primed TNT, a falling block, an arrow, a
snowball and a trident that land, a fireball, a firework and a crystal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-17 22:39:00 +02:00
parent 583502f0f4
commit 866e772227
15 changed files with 313 additions and 27 deletions
+3
View File
@@ -649,6 +649,8 @@ impl LevelAccess for GameLevel<'_> {
/// FallingBlockEntity carrying a block state.
#[derive(Clone, Debug)]
struct FallingBlock {
/// The entity id a server tracks it by (0 until it is tracked).
id: u32,
state: BlockStateId,
/// `DATA_START_POS`: spawn position used to select weighted block models.
start_pos: BlockPos,
@@ -2054,6 +2056,7 @@ impl Game<'_> {
f64::from(pos.z) + 0.5,
);
self.falling.push(FallingBlock {
id: 0,
state,
start_pos: pos,
position: p,
+6
View File
@@ -74,6 +74,8 @@ impl Respawn {
}
#[derive(Clone, Debug)]
pub(super) struct Crystal {
/// The entity id a server tracks it by (0 until it is tracked).
pub id: u32,
pub position: Vec3,
pub show_bottom: bool,
/// EndCrystal.time (the bob and spin), starting random.
@@ -553,6 +555,7 @@ impl Game<'_> {
}
let time = self.world.random.next_int_bound(100_000).unwrap_or(0);
self.crystals.push(Crystal {
id: 0,
position: at,
show_bottom: true,
time,
@@ -2301,6 +2304,7 @@ impl Crystal {
pub(super) fn from_nbt(tag: &Tag, time: i32) -> Option<Self> {
let (position, _, _) = horizon_client::entity_nbt::boat_from_nbt(tag)?;
Some(Self {
id: 0,
position,
show_bottom: !matches!(tag.get("ShowBottom"), Some(Tag::Byte(0))),
time,
@@ -2403,6 +2407,7 @@ impl Game<'_> {
}
let time = self.world.random.next_int_bound(100_000).unwrap_or(0);
self.crystals.push(Crystal {
id: 0,
position: Vec3::new(x + 0.5, y, z + 0.5),
show_bottom: false,
time,
@@ -2665,6 +2670,7 @@ impl Game<'_> {
.retain(|c| c.position.distance_squared(at) > 0.01);
let time = self.world.random.next_int_bound(100_000).unwrap_or(0);
self.crystals.push(Crystal {
id: 0,
position: at,
show_bottom: true,
time,
+8 -5
View File
@@ -18,19 +18,21 @@ use horizon_core::{
};
pub(super) struct Rocket {
position: Vec3,
/// The entity id a server tracks it by (0 until it is tracked).
pub id: u32,
pub(super) position: Vec3,
previous: Vec3,
velocity: Vec3,
pub(super) velocity: Vec3,
life: i32,
lifetime: i32,
explosions: Vec<FireworkExplosion>,
/// Boosting the player (attachedToEntity).
attached: bool,
pub(super) attached: bool,
/// `DATA_SHOT_AT_ANGLE` (dispensers): constant velocity, exploding on
/// the first block it hits.
angled: bool,
pub(super) angled: bool,
/// `DATA_ID_FIREWORKS_ITEM`: the stack it was launched from.
item: ItemStack,
pub(super) item: ItemStack,
}
impl Rocket {
/// Position and motion (the dispenser parity fixture).
@@ -56,6 +58,7 @@ impl Game<'_> {
+ r.next_int_bound(6).unwrap_or(0)
+ r.next_int_bound(7).unwrap_or(0);
Rocket {
id: 0,
position: at,
previous: at,
velocity,
+11 -5
View File
@@ -718,7 +718,7 @@ impl Game<'_> {
}
/// The entities guests track: mobs, items and the rest (game/lan_entities.rs).
fn lan_entities(&self, hub: &mut Hub) -> Vec<EntityState> {
fn lan_entities(&self, host_entity: Option<i32>, hub: &mut Hub) -> Vec<EntityState> {
let mut out = Vec::with_capacity(self.mobs.len() + self.dropped.len() + self.orbs.len());
for m in self.mobs.iter().filter(|m| !m.removed) {
let kind = m.kind.id.as_str();
@@ -738,6 +738,7 @@ impl Game<'_> {
data: 0,
meta,
equipment,
precise: false,
});
}
for d in &self.dropped {
@@ -755,6 +756,7 @@ impl Game<'_> {
data: 0,
meta: vec![(8, serializer::ITEM_STACK, Value::Item(stack))],
equipment: Vec::new(),
precise: false,
});
}
for o in &self.orbs {
@@ -772,9 +774,10 @@ impl Game<'_> {
// ExperienceOrb.DATA_VALUE.
meta: vec![(8, serializer::INT, Value::Int(o.value as i32))],
equipment: Vec::new(),
precise: false,
});
}
self.lan_object_states(hub, &mut out);
self.lan_object_states(host_entity, hub, &mut out);
out
}
@@ -790,8 +793,10 @@ impl Game<'_> {
if state.is_some() || host.hub.config.dedicated {
let has_guests = !host.hub.guests.is_empty();
let entities = if has_guests {
self.lan_riding(state.as_ref().map(|s| s.entity_id), &mut host.hub.riding);
self.lan_entities(&mut host.hub)
let host_entity = state.as_ref().map(|s| s.entity_id);
self.lan_assign_ids();
self.lan_riding(host_entity, &mut host.hub.riding);
self.lan_entities(host_entity, &mut host.hub)
} else {
Vec::new()
};
@@ -974,7 +979,8 @@ impl Game<'_> {
log::error!("could not open {}: {e}", level.id());
return;
}
theirs = self.lan_entities(&mut host.hub);
// A dedicated server has no host player.
theirs = self.lan_entities(None, &mut host.hub);
&theirs[..]
} else {
entities
+191 -1
View File
@@ -37,6 +37,7 @@ fn state(id: u32, kind: &str, position: [f64; 3], yaw: f32, on_ground: bool) ->
data: 0,
meta: Vec::new(),
equipment: Vec::new(),
precise: false,
}
}
@@ -101,7 +102,12 @@ impl Game<'_> {
/// Boats, minecarts, armor stands, item frames, paintings and the
/// entities kept unsimulated, as guests track them.
pub(super) fn lan_object_states(&self, hub: &mut Hub, out: &mut Vec<EntityState>) {
pub(super) fn lan_object_states(
&self,
host_entity: Option<i32>,
hub: &mut Hub,
out: &mut Vec<EntityState>,
) {
for b in &self.boats {
let p = b.position;
let mut e = state(b.id, &b.entity_type(), [p.x, p.y, p.z], b.yaw, b.on_ground);
@@ -225,6 +231,7 @@ impl Game<'_> {
}
out.push(e);
}
self.lan_projectile_states(host_entity, hub, out);
for o in &self.others {
let p = o.position;
let mut e = state(o.id, &o.kind, [p.x, p.y, p.z], o.yaw, false);
@@ -235,6 +242,189 @@ impl Game<'_> {
}
}
impl Game<'_> {
/// Gives the entities Horizon keeps without an id one (`Entity.id`, from
/// the same counter as the rest) before they are first tracked.
pub(super) fn lan_assign_ids(&mut self) {
let next = &mut self.next_entity;
let mut give = |id: &mut u32| {
if *id == 0 {
*next += 1;
*id = *next;
}
};
self.tnts.iter_mut().for_each(|t| give(&mut t.id));
self.falling.iter_mut().for_each(|f| give(&mut f.id));
self.creatures
.projectiles
.iter_mut()
.for_each(|p| give(&mut p.id));
self.tridents.iter_mut().for_each(|t| give(&mut t.id));
self.rockets.iter_mut().for_each(|r| give(&mut r.id));
self.crystals.iter_mut().for_each(|c| give(&mut c.id));
}
/// Primed TNT, falling blocks, projectiles, tridents, firework rockets and
/// end crystals, as guests track them.
fn lan_projectile_states(
&self,
host_entity: Option<i32>,
hub: &mut Hub,
out: &mut Vec<EntityState>,
) {
let owner = |who: Option<horizon_client::mobs::Who>| match who {
Some(horizon_client::mobs::Who::Mob(id)) => id as i32,
Some(horizon_client::mobs::Who::Player) => host_entity.unwrap_or(0),
None => 0,
};
let at = |p: horizon_core::geometry::Vec3| [p.x, p.y, p.z];
for t in self.tnts.iter().filter(|t| t.id != 0) {
let mut e = state(t.id, "minecraft:tnt", at(t.position), 0.0, t.on_ground);
e.velocity = at(t.velocity);
// PrimedTnt.DATA_FUSE_ID, 80 by default; requiresPrecisePosition
// while it touches a block.
if t.fuse != 80 {
e.meta.push((8, serializer::INT, Value::Int(t.fuse)));
}
e.precise = t.on_ground;
out.push(e);
}
for f in self.falling.iter().filter(|f| f.id != 0) {
let mut e = state(f.id, "minecraft:falling_block", at(f.position), 0.0, false);
e.velocity = at(f.velocity);
// getAddEntityPacket: the block state; DATA_START_POS.
e.data = f.state.0 as i32;
if f.no_gravity {
e.meta.push((5, serializer::BOOLEAN, Value::Bool(true)));
}
let start = [f.start_pos.x, f.start_pos.y, f.start_pos.z];
if start != [0; 3] {
e.meta.push((8, serializer::BLOCK_POS, Value::Pos(start)));
}
out.push(e);
}
for p in self.creatures.projectiles.iter().filter(|p| p.id != 0) {
use horizon_client::projectiles::ProjectileKind as K;
let kind = match &p.kind {
K::Arrow { .. } => "minecraft:arrow",
K::Snowball => "minecraft:snowball",
K::Egg => "minecraft:egg",
K::EnderPearl => "minecraft:ender_pearl",
K::SmallFireball => "minecraft:small_fireball",
K::LargeFireball { .. } => "minecraft:fireball",
K::LlamaSpit => "minecraft:llama_spit",
K::WindCharge => "minecraft:wind_charge",
K::BreezeWindCharge => "minecraft:breeze_wind_charge",
K::ShulkerBullet { .. } => "minecraft:shulker_bullet",
K::WitherSkull { .. } => "minecraft:wither_skull",
K::Potion { .. } => "minecraft:splash_potion",
};
let mut e = state(p.id, kind, at(p.position), p.yaw, false);
e.pitch = p.pitch;
e.velocity = at(p.velocity);
e.data = owner(p.owner);
match &p.kind {
K::Arrow { critical, .. } => {
let a = p.arrow.as_deref();
e.meta.extend(arrow_meta(
*critical,
a.is_some_and(|a| a.no_physics),
a.map_or(0, |a| a.pierce),
a.is_some_and(|a| a.in_ground) || p.stuck,
));
}
// WitherSkull.DATA_DANGEROUS.
K::WitherSkull { dangerous: true } => {
e.meta.push((8, serializer::BOOLEAN, Value::Bool(true)));
}
_ => {}
}
out.push(e);
}
for t in self.tridents.iter().filter(|t| t.id != 0) {
let mut e = state(t.id, "minecraft:trident", at(t.position), t.yaw, false);
e.pitch = t.pitch;
e.velocity = at(t.velocity);
e.meta = arrow_meta(false, t.no_physics, 0, t.in_ground);
// ThrownTrident.ID_LOYALTY and ID_FOIL.
if t.loyalty != 0 {
e.meta
.push((11, serializer::BYTE, Value::Byte(t.loyalty as i8)));
}
if t.stack.has_any_enchantments() {
e.meta.push((12, serializer::BOOLEAN, Value::Bool(true)));
}
out.push(e);
}
for r in self.rockets.iter().filter(|r| r.id != 0) {
let mut e = state(
r.id,
"minecraft:firework_rocket",
at(r.position),
0.0,
false,
);
e.velocity = at(r.velocity);
// DATA_ID_FIREWORKS_ITEM once set from a stack, DATA_ATTACHED_TO_TARGET,
// DATA_SHOT_AT_ANGLE.
let plain = &*r.item.item == "minecraft:firework_rocket"
&& r.item.count == 1
&& r.item.extra.is_none();
if !plain {
e.meta.push((
8,
serializer::ITEM_STACK,
Value::Item(hub.stack(&Some(r.item.clone()))),
));
}
if r.attached
&& let Some(host) = host_entity
{
e.meta
.push((9, serializer::OPTIONAL_UNSIGNED_INT, Value::Id(host + 1)));
}
if r.angled {
e.meta.push((10, serializer::BOOLEAN, Value::Bool(true)));
}
out.push(e);
}
for c in self.crystals.iter().filter(|c| c.id != 0) {
let mut e = state(c.id, "minecraft:end_crystal", at(c.position), 0.0, false);
// EndCrystal.DATA_BEAM_TARGET and DATA_SHOW_BOTTOM (true by default).
if c.beam.is_some() {
e.meta
.push((8, serializer::OPTIONAL_BLOCK_POS, Value::OptPos(c.beam)));
}
if !c.show_bottom {
e.meta.push((9, serializer::BOOLEAN, Value::Bool(false)));
}
out.push(e);
}
}
}
/// `AbstractArrow`'s ID_FLAGS (critical 1, no physics 2), PIERCE_LEVEL and
/// IN_GROUND, when they differ from the defaults.
fn arrow_meta(
critical: bool,
no_physics: bool,
pierce: u8,
in_ground: bool,
) -> Vec<(u8, i32, Value)> {
let mut meta = Vec::new();
let flags = i8::from(critical) | i8::from(no_physics) << 1;
if flags != 0 {
meta.push((8, serializer::BYTE, Value::Byte(flags)));
}
if pierce != 0 {
meta.push((9, serializer::BYTE, Value::Byte(pierce as i8)));
}
if in_ground {
meta.push((10, serializer::BOOLEAN, Value::Bool(true)));
}
meta
}
#[cfg(test)]
mod tests {
use super::*;
@@ -202,6 +202,7 @@ impl Game<'_> {
{
let (no_gravity, drop_item) = entity_nbt::falling_block_flags(&tag);
self.falling.push(FallingBlock {
id: 0,
state,
// DATA_START_POS is not persisted by vanilla.
start_pos: horizon_core::position::BlockPos::default(),
+4
View File
@@ -12,6 +12,8 @@ use horizon_world::level::flags as level_flags;
#[derive(Clone, Debug)]
pub(super) struct PrimedTnt {
/// The entity id a server tracks it by (0 until it is tracked).
pub id: u32,
pub position: Vec3,
pub previous: Vec3,
pub velocity: Vec3,
@@ -140,6 +142,7 @@ impl Game<'_> {
f64::from(pos.z) + 0.5,
);
self.tnts.push(PrimedTnt {
id: 0,
position,
previous: position,
velocity: Vec3::new(-rot.sin() * 0.02, f64::from(0.2f32), -rot.cos() * 0.02),
@@ -484,6 +487,7 @@ mod tests {
world.set(21, 4, 20, flowing).unwrap();
let at = Vec3::new(20.5, 4.0, 20.5);
let mut tnt = PrimedTnt {
id: 0,
position: at,
previous: at,
velocity: Vec3::ZERO,
+11 -8
View File
@@ -15,17 +15,19 @@ use horizon_core::{
};
pub(super) struct ThrownTrident {
stack: ItemStack,
position: Vec3,
/// The entity id a server tracks it by (0 until it is tracked).
pub id: u32,
pub(super) stack: ItemStack,
pub(super) position: Vec3,
previous: Vec3,
velocity: Vec3,
yaw: f32,
pitch: f32,
in_ground: bool,
pub(super) velocity: Vec3,
pub(super) yaw: f32,
pub(super) pitch: f32,
pub(super) in_ground: bool,
in_ground_time: u32,
dealt_damage: bool,
loyalty: u32,
no_physics: bool,
pub(super) loyalty: u32,
pub(super) no_physics: bool,
returning: u32,
creative_only: bool,
}
@@ -163,6 +165,7 @@ impl Game<'_> {
on_ground,
);
self.tridents.push(ThrownTrident {
id: 0,
loyalty: thrown.enchantment_level("minecraft:loyalty"),
stack: thrown,
position: start,
+48 -5
View File
@@ -35,6 +35,30 @@ pub struct EntityState {
/// EquipmentSlot ordinals (0 main hand, 1 off hand, 2 feet, 3 legs,
/// 4 chest, 5 head, 6 body, 7 saddle) and their stacks.
pub equipment: Vec<(u8, Option<Stack>)>,
/// `Entity.getRequiresPrecisePosition` (primed TNT and falling blocks
/// touching a block): moves are sent as full position syncs.
pub precise: bool,
}
/// `AbstractArrow`: every update sends its position and rotation.
fn is_arrow(kind: &str) -> bool {
matches!(
kind,
"minecraft:arrow" | "minecraft:spectral_arrow" | "minecraft:trident"
)
}
/// `AbstractHurtingProjectile.accelerationPower` (0.1, none for wind
/// charges), sent with each velocity update.
fn acceleration_power(kind: &str) -> Option<f64> {
match kind {
"minecraft:fireball"
| "minecraft:small_fireball"
| "minecraft:dragon_fireball"
| "minecraft:wither_skull" => Some(0.1),
"minecraft:wind_charge" | "minecraft:breeze_wind_charge" => Some(0.0),
_ => None,
}
}
/// What a client was last told about one entity (ServerEntity's fields).
@@ -207,7 +231,9 @@ impl Tracker {
if due || dirty {
let rotation = (pack_degrees(e.pitch), pack_degrees(e.yaw));
let turned = |a: i8, b: i8| (i32::from(a) - i32::from(b)).abs() >= 1;
let rotate = turned(rotation.1, s.rotation.1) || turned(rotation.0, s.rotation.0);
let arrow = is_arrow(&e.kind);
let rotate =
arrow || turned(rotation.1, s.rotation.1) || turned(rotation.0, s.rotation.0);
if riding.vehicle.contains_key(&e.id) {
// A passenger: its rotation alone (its vehicle places it).
if rotate {
@@ -231,7 +257,7 @@ impl Tracker {
}
s.teleport_delay += 1;
let d: f64 = (0..3).map(|k| (e.position[k] - s.base[k]).powi(2)).sum();
let send_position = d >= 7.629_394_5e-6 || s.tick.is_multiple_of(60);
let send_position = arrow || d >= 7.629_394_5e-6 || s.tick.is_multiple_of(60);
let sync = EntityPositionSync {
id: e.id,
path: PositionPath::Linear(e.position),
@@ -240,7 +266,10 @@ impl Tracker {
on_ground: e.on_ground,
};
// ServerEntity.createMovePacket.
let packet = if s.teleport_delay > 400 || s.was_riding || s.was_on_ground != e.on_ground
let packet = if e.precise
|| s.teleport_delay > 400
|| s.was_riding
|| s.was_on_ground != e.on_ground
{
s.was_on_ground = e.on_ground;
s.teleport_delay = 0;
@@ -282,10 +311,23 @@ impl Tracker {
let still = e.velocity.iter().all(|v| *v == 0.0);
if diff > 1.0e-7 || diff > 0.0 && still {
s.velocity = e.velocity;
out.push(play::Clientbound::SetEntityMotion(SetEntityMotion {
let motion = play::Clientbound::SetEntityMotion(SetEntityMotion {
id: e.id,
velocity: e.velocity,
}));
});
match acceleration_power(&e.kind) {
// A bundle: the motion and the projectile's power.
Some(power) => out.extend([
play::Clientbound::BundleDelimiter(horizon_protocol::packets::Empty),
motion,
play::Clientbound::ProjectilePower(play::ProjectilePower {
id: e.id,
power,
}),
play::Clientbound::BundleDelimiter(horizon_protocol::packets::Empty),
]),
None => out.push(motion),
}
}
}
if let Some(packet) = packet {
@@ -386,6 +428,7 @@ mod tests {
data: 0,
meta: Vec::new(),
equipment: Vec::new(),
precise: false,
}
}
+1
View File
@@ -1378,6 +1378,7 @@ impl Hub {
data: 0,
meta,
equipment,
precise: false,
}
}
+3
View File
@@ -63,6 +63,8 @@ pub enum ProjectileKind {
}
#[derive(Clone, Debug, PartialEq)]
pub struct Projectile {
/// The entity id a server tracks it by (0 until it is tracked).
pub id: u32,
pub kind: ProjectileKind,
pub owner: Option<Who>,
pub position: Vec3,
@@ -128,6 +130,7 @@ impl Projectile {
pub fn new(kind: ProjectileKind, position: Vec3, owner: Option<Who>) -> Self {
let kind_is_arrow = matches!(kind, ProjectileKind::Arrow { .. });
Self {
id: 0,
kind,
owner,
position,
+1
View File
@@ -422,6 +422,7 @@ fn guests_see_each_other_and_the_world_entities() {
data: 0,
meta: Vec::new(),
equipment: Vec::new(),
precise: false,
};
let first = thread::spawn(move || {
let mut bot = connect(port, "Alex", false)?;
@@ -567,6 +567,10 @@ packet!(PlayerPosition {
pitch: f32 => Float,
relatives: i32 => Int,
});
packet!(
/// ClientboundProjectilePowerPacket: an AbstractHurtingProjectile's accelerationPower.
ProjectilePower { id: i32 => VarInt, power: f64 => Double }
);
packet!(PlayerRotation { yaw: f32 => Float, relative_yaw: bool => Bool, pitch: f32 => Float, relative_pitch: bool => Bool });
packet!(RemoveEntities { ids: Vec<i32> => List<VarInt> });
packet!(Respawn { spawn: SpawnInfo => SpawnInfo, keep: i8 => Byte });
@@ -1431,6 +1435,7 @@ packet_enum!(Clientbound, crate::ids::play::clientbound {
SetHeldSlot(SetHeldSlot) = SET_HELD_SLOT,
SetObjective(SetObjective) = SET_OBJECTIVE,
SetPassengers(SetPassengers) = SET_PASSENGERS,
ProjectilePower(ProjectilePower) = PROJECTILE_POWER,
SetPlayerInventory(SetPlayerInventory) = SET_PLAYER_INVENTORY,
SetPlayerTeam(SetPlayerTeam) = SET_PLAYER_TEAM,
SetScore(SetScore) = SET_SCORE,
@@ -2061,6 +2066,7 @@ mod tests {
vehicle: 2,
passengers: vec![3, 300],
}),
Clientbound::ProjectilePower(ProjectilePower { id: 4, power: 0.1 }),
Clientbound::SetEquipment(SetEquipment {
id: 2,
slots: vec![(0, None), (5, Some(Stack::new(1, 1)))],
@@ -10,6 +10,7 @@ import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket;
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
import net.minecraft.network.protocol.game.ClientboundProjectilePowerPacket;
import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
@@ -47,6 +48,7 @@ final class EntityTranscript {
float headRot;
boolean onGround;
String motion;
String power = "";
boolean removed;
Tracked(ClientboundAddEntityPacket p) {
@@ -91,6 +93,7 @@ final class EntityTranscript {
case ClientboundEntityPositionSyncPacket p -> byId.get(p.id());
case ClientboundSetEntityMotionPacket p -> byId.get(p.id());
case ClientboundTeleportEntityPacket p -> byId.get(p.id());
case ClientboundProjectilePowerPacket p -> byId.get(p.getId());
case ClientboundMoveEntityPacket p -> byId.get(VanillaProtocolClient.moveEntityId(p));
case ClientboundRotateHeadPacket p -> byId.get(VanillaProtocolClient.rotateHeadId(p));
default -> null;
@@ -131,6 +134,7 @@ final class EntityTranscript {
t.onGround = p.onGround();
}
case ClientboundRotateHeadPacket p -> t.headRot = p.getYHeadRot();
case ClientboundProjectilePowerPacket p -> t.power = " power " + p.getAccelerationPower();
default -> {
}
}
@@ -152,7 +156,7 @@ final class EntityTranscript {
for (int id : t.passengers) riders.add(names.getOrDefault(id, "player or unknown"));
out.add("entity " + t.name + " | add " + t.add + " | pairing " + t.pairing + " | data " + t.data + " | equipment " + t.equipment
+ " | attributes " + t.attributes + " | passengers " + riders + " | now " + t.codec.getBase() + " rot " + t.xRot + ","
+ t.yRot + " head " + t.headRot + " ground " + t.onGround + " motion " + t.motion + (t.removed ? " | removed" : ""));
+ t.yRot + " head " + t.headRot + " ground " + t.onGround + " motion " + t.motion + t.power + (t.removed ? " | removed" : ""));
}
out.sort(null);
return out;
+14 -2
View File
@@ -6,7 +6,9 @@ world vanilla generated first, with the same server.properties (offline, view di
client (VanillaProtocolClient in its entity mode) joins, and once its chunks are in it asks for the scene: the
console freezes the ticks, builds a wall and a rail and summons, around the spawn, every kind of minecart (one
set rolling along the rail), boats and a raft (one falling onto the ground), armor stands (posed, small, with
arms, wearing a helmet, one falling), a chicken jockey, item frames (one holding a turned diamond) and paintings. The client records
arms, wearing a helmet, one falling), a chicken jockey, item frames (one holding a turned diamond), paintings,
primed TNT, a falling block, an arrow, a snowball and a trident that land, a fireball, a firework rocket and an
end crystal. The client records
for 20 seconds, the ticks running again after 3, what ClientPacketListener would make of the packets (EntityTranscript): each entity's spawn
packet (position, rotations, data, motion), the entity data it was paired with and all it was sent since, its
equipment and passengers, and where its position syncs leave it. Both transcripts must match exactly,
@@ -66,6 +68,15 @@ SCENE = [
'summon minecraft:glow_item_frame -1.5 -59 -4.97 {block_pos:[I;-2,-59,-5],Facing:3b}',
'summon minecraft:painting 1.5 -59 -4.97 {block_pos:[I;1,-59,-5],facing:0b,variant:"minecraft:kebab"}',
'summon minecraft:painting 4 -59 -4.97 {block_pos:[I;4,-59,-5],facing:0b,variant:"minecraft:courbet"}',
# Primed TNT that won't go off, a falling block, projectiles that land, a fireball, a firework, a crystal.
'summon minecraft:tnt 6.5 -60 6.5 {fuse:2000s}',
'summon minecraft:falling_block 2.5 -50 -0.5 {BlockState:{Name:"minecraft:sand"}}',
'summon minecraft:arrow 0.5 -55 -1.5 {Motion:[0.3d,0d,0d]}',
'summon minecraft:snowball -0.5 -55 1.5',
'summon minecraft:trident -2.5 -55 -0.5',
'summon minecraft:fireball 3.5 -57 -3.5',
'summon minecraft:firework_rocket 5.5 -60 -0.5',
'summon minecraft:end_crystal -6.5 -60 6.5 {ShowBottom:0b}',
]
@@ -161,7 +172,8 @@ def main():
schema=1, minecraft=lock['minecraft']['version'], platform=platform.platform(),
java=subprocess.check_output(['java', '--version'], text=True).splitlines()[0],
entities=len(vanilla), output_sha256=lab.digest(build / 'horizon.txt', 'sha256'),
scope='Minecarts (one rolling), boats (one falling), armor stands, a chicken jockey, item frames and paintings tracked to a '
scope='Minecarts (one rolling), boats (one falling), armor stands, a chicken jockey, item frames, paintings, primed '
'TNT, a falling block, projectiles, a fireball, a firework and an end crystal tracked to a '
'vanilla-codec client by a dedicated server: spawn packets, entity data, equipment, passengers and the '
'positions the syncs leave them at.'))
print(f'server entities: {len(vanilla)} entities identical')