use ghast_protocol::{BlockPos, RawPacket};
use super::*;
use crate::common::{Abilities, Controls, Outbound, Pose, Teleport, Vec3};
use crate::hands::{BlockQuery, HeldItem};
fn activates_1_12(id: u8) -> bool {
ACTIVATED_1_8.contains(&id) || matches!(id, 137 | 210 | 211 | 219..=234 | 255)
}
fn ray_1_12(w: &ghast_world::v1_12::World, x: i32, y: i32, z: i32) -> Option<[f64; 6]> {
let s = w.block_state(x, y, z)?;
let sel = s.selection();
if !sel.can_collide {
return None;
}
if sel.dependency == ghast_data::ShapeDependency::None {
let b = sel.bounds;
return Some([b.min_x, b.min_y, b.min_z, b.max_x, b.max_y, b.max_z]);
}
let local: Vec<ghast_data::Aabb> = ghast_physics::v1_12::collision_boxes(w, x, y, z)
.iter()
.map(|b| {
let (fx, fy, fz) = (f64::from(x), f64::from(y), f64::from(z));
ghast_data::Aabb::new(
b.min_x - fx,
b.min_y - fy,
b.min_z - fz,
b.max_x - fx,
b.max_y - fy,
b.max_z - fz,
)
})
.collect();
union(&local).or_else(|| {
let b = sel.bounds;
Some([b.min_x, b.min_y, b.min_z, b.max_x, b.max_y, b.max_z])
})
}
pub(crate) struct Sim12 {
world: ghast_world::v1_12::World,
player: ghast_physics::v1_12::PlayerState,
packets: ghast_physics::Packets,
force_step_position: ForceStepPosition,
entities: Option<ghast_entity::v1_12::Tracker>,
updates: BlockUpdates,
session: SessionPackets,
block_entities: bool,
near: Option<Box<Near12>>,
profile_name: Box<str>,
entity_push: bool,
}
impl std::fmt::Debug for Sim12 {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Sim12")
.field("world", &self.world)
.field("pos", &self.player.pos)
.finish_non_exhaustive()
}
}
impl Sim12 {
#[cfg(all(test, feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
pub(crate) fn test_set_block(
&mut self,
x: i32,
y: i32,
z: i32,
st: ghast_data::v1_12::BlockState,
) {
self.world.set_block_state(x, y, z, st);
}
#[cfg(all(
test,
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1"
))]
pub(crate) fn test_set_player(&mut self, p: ghast_physics::v1_12::PlayerState) {
self.player = p;
}
#[cfg(all(
test,
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1"
))]
pub(crate) fn test_set_profile_name(&mut self, name: &str) {
self.profile_name = name.into();
}
pub(crate) fn new() -> Self {
Sim12 {
world: ghast_world::v1_12::World::new(config()),
player: fresh_player_1_12(),
packets: ghast_physics::Packets::new(),
force_step_position: ForceStepPosition::Off,
entities: None,
updates: BlockUpdates::default(),
session: SessionPackets::default(),
block_entities: false,
near: None,
profile_name: "".into(),
entity_push: true,
}
}
pub(crate) fn with(opts: &SimOptions) -> Self {
let mut s = Self::new();
s.force_step_position = opts.force_step_position;
s.entities = opts.entities.map(ghast_entity::v1_12::Tracker::new);
s.near = s.entities.is_some().then(Box::default);
if let Some(n) = &opts.profile_name {
s.profile_name = n.as_str().into();
}
if let Some(c) = opts.world {
s.world = ghast_world::v1_12::World::new(c);
s.block_entities = c.block_entities;
}
if opts.shared_chunks.is_some() {
log::debug!("shared chunks are not used on 1.12.2; every section stays owned");
}
if let Some(p) = opts.record.as_deref() {
log::warn!(
"movement recording is not supported on 1.12.2; not recording to {}",
p.display()
);
}
s
}
}
impl Sim12 {
#[cold]
#[inline(never)]
fn step_near(&mut self, pose: &Pose, controls: Controls, using_item: bool) {
let input = ghast_physics::TickInput {
keys: keys(controls),
yaw: pose.yaw,
pitch: pose.pitch,
using_item,
};
let (Some(n), Some(t)) = (self.near.as_deref_mut(), self.entities.as_ref()) else {
return;
};
n.solids(t, &self.world, &self.player);
ghast_physics::v1_12::tick_in(
&mut self.player,
&input,
&self.world,
&ghast_physics::v1_12::Options::default(),
&n.solids,
&mut self.packets,
);
}
#[cold]
#[inline(never)]
fn tick_near(&mut self, pose: &mut Pose) {
let (Some(n), Some(t)) = (self.near.as_deref_mut(), self.entities.as_ref()) else {
return;
};
n.ghosts.clear();
if n.list.is_empty() {
return;
}
let p = &mut self.player;
let pushing = self.entity_push
&& p.added_to_chunk
&& !p.removed
&& !t
.me()
.is_some_and(|m| m.vehicle().is_some() || !m.passengers().is_empty());
n.tick(t, &self.world, &p.bb, pushing, &self.profile_name);
let mut changed = false;
for (_, pusher) in &n.pushers {
changed |= ghast_physics::v1_12::push_by(p, &self.world, pusher);
}
if changed {
pose.motion = Vec3::new(p.vel[0], p.vel[1], p.vel[2]);
}
for &[x, y, z] in &n.lily_pads {
self.world
.set_block_state(x, y, z, ghast_data::v1_12::BlockState::AIR);
}
}
}
fn fresh_player_1_12() -> ghast_physics::v1_12::PlayerState {
let mut p = ghast_physics::v1_12::PlayerState::new([0.0; 3], 0.0, 0.0);
p.added_to_chunk = false;
p
}
impl WorldView for Sim12 {
fn column(&self, chunk_x: i32, chunk_z: i32) -> Option<&ghast_world::Column> {
self.world.column(chunk_x, chunk_z)
}
fn is_column_loaded(&self, chunk_x: i32, chunk_z: i32) -> bool {
self.world.is_column_loaded(chunk_x, chunk_z)
}
fn raw_block(&self, x: i32, y: i32, z: i32) -> Option<u32> {
self.world.block_state(x, y, z).map(|s| u32::from(s.raw()))
}
fn entities(&self) -> Option<&ghast_entity::Entities> {
self.entities.as_deref()
}
fn loaded_columns(&self) -> usize {
self.world.columns().len()
}
fn block_query(&self, x: i32, y: i32, z: i32) -> Option<BlockQuery> {
let s = self.world.block_state(x, y, z)?;
let b = s.block();
let info = b.info();
Some(BlockQuery {
exact: Some(crate::hands::ExactDig::V1_12),
air: b.material().kind == ghast_data::v1_12::MaterialKind::Air,
water: matches!(b.id(), 8 | 9),
block: u16::from(b.id()),
hardness: info.hardness.unwrap_or(-1.0),
dig_material: info.material,
harvest_tools: info.harvest_tools,
selection: ray_1_12(&self.world, x, y, z),
stairs: None,
activates: activates_1_12(b.id()),
})
}
fn crosshair(
&self,
eyes: Vec3,
(yaw, pitch): (f32, f32),
_look: Vec3,
reach: f64,
) -> Option<crate::BlockHit> {
use ghast_physics::pick::v1_12 as pick;
let eye = [eyes.x, eyes.y, eyes.z];
let hit = pick::pick(&self.world, eye, pick::look_vector(yaw, pitch), reach)?;
block_hit(&hit, eye)
}
}
impl Sim for Sim12 {
fn crosshair_target(&self, q: &PickQuery<'_>) -> Crosshair {
use ghast_physics::pick::v1_12 as pick;
let eye = [q.eyes.x, q.eyes.y, q.eyes.z];
let look = pick::look_vector(q.rotation.0, q.rotation.1);
if q.entities.is_empty() {
let reach = if q.creative {
pick::CREATIVE_REACH
} else {
pick::REACH
};
return Crosshair::Block(
pick::pick(&self.world, eye, look, reach).and_then(|h| block_hit(&h, eye)),
);
}
let t = pick::pick_target(&self.world, eye, look, q.creative, &q.player_bb, q.entities);
legacy_crosshair(t, eye)
}
fn world_packet(&mut self, raw: &RawPacket) -> Result<(), SimError> {
{
use ghast_protocol::v1_12_2::play::clientbound::id;
self.session.note(raw, id::LOGIN, id::RESPAWN);
}
if let Some(t) = &mut self.entities
&& t.wants(raw.id)
{
t.apply(raw)?;
if let Some(n) = &mut self.near {
n.packet(t, raw);
}
}
use ghast_protocol::v1_12_2::play::clientbound as cb;
if raw.id == cb::id::TEAMS {
if let Some(n) = &mut self.near
&& !n
.teams
.apply(&raw.body, super::teams::TeamLayout::Legacy1_12)
{
log::debug!("bad teams packet ({} B)", raw.body.len());
}
return Ok(());
}
if let Some(n) = &mut self.near
&& matches!(
raw.id,
cb::id::MAP_CHUNK
| cb::id::BLOCK_CHANGE
| cb::id::MULTI_BLOCK_CHANGE
| cb::id::LOGIN
| cb::id::RESPAWN
)
{
n.world_version = n.world_version.wrapping_add(1);
}
let w = &mut self.world;
match raw.id {
cb::id::LOGIN => {
w.apply_login(&raw.decode_as()?);
}
cb::id::RESPAWN => {
w.apply_respawn(&raw.decode_as()?);
}
cb::id::MAP_CHUNK => {
w.apply_map_chunk(&raw.decode_as()?)?;
}
cb::id::UNLOAD_CHUNK => {
w.apply_unload_chunk(&raw.decode_as()?);
}
cb::id::BLOCK_CHANGE => {
let p: cb::BlockChange = raw.decode_as()?;
self.updates.push(p.location, p.r#type as u32);
w.apply_block_change(&p);
}
cb::id::MULTI_BLOCK_CHANGE => {
let p: cb::MultiBlockChange = raw.decode_as()?;
for r in &p.records {
let x = p.chunk_x * 16 + i32::from(r.horizontal_pos >> 4);
let z = p.chunk_z * 16 + i32::from(r.horizontal_pos & 15);
self.updates
.push(BlockPos::new(x, i32::from(r.y), z), r.block_id as u32);
}
w.apply_multi_block_change(&p);
}
cb::id::EXPLOSION => {
w.apply_explosion(&raw.decode_as()?);
}
cb::id::WORLD_BORDER => {
w.apply_world_border(&raw.decode_as()?);
}
cb::id::TILE_ENTITY_DATA if self.block_entities => {
w.apply_tile_entity_data(&raw.decode_as()?);
}
_ => {}
}
Ok(())
}
fn reset_player(&mut self) {
let abilities = self.player.abilities;
let food = self.player.food_level;
self.player = fresh_player_1_12();
self.player.abilities = abilities;
self.player.food_level = food;
}
fn teleport(&mut self, pose: &mut Pose, t: &Teleport) {
self.player.yaw = pose.yaw;
self.player.pitch = pose.pitch;
let _reply =
self.player
.apply_teleport([t.x, t.y, t.z], t.yaw, t.pitch, rel_flags(t.flags));
sync_pose_12(pose, &self.player);
}
fn abilities(&mut self, a: Abilities) {
self.player.apply_abilities(physics_abilities(a));
}
fn food(&mut self, food: i32) {
self.player.food_level = food;
}
fn velocity(&mut self, v: Vec3, add: bool) {
let p = &mut self.player;
if add {
p.vel[0] += v.x;
p.vel[1] += v.y;
p.vel[2] += v.z;
} else {
p.vel = [v.x, v.y, v.z];
}
}
fn movement_speed(&mut self, base: f64, modifiers: &[(u128, f64, u8)]) {
self.player.apply_speed_attribute(base, modifiers);
}
fn status_effects(&mut self, effects: &std::collections::BTreeMap<i8, i8>) {
let e = &mut self.player.effects;
e.jump_boost = effects.get(&8).map(|a| i32::from(*a));
e.blindness = effects.contains_key(&15);
e.levitation = effects.get(&25).map(|a| i32::from(*a));
}
fn boots(&mut self, depth_strider: u8, _soul_speed: u8) {
self.player.depth_strider = depth_strider;
}
fn spectator(&mut self, on: bool) {
self.player.spectator = on;
}
fn set_flying(&mut self, flying: bool, out: &mut Vec<Outbound>) {
let a = &mut self.player.abilities;
if a.flying == flying || (flying && !a.allow_flying) {
return;
}
a.flying = flying;
let a = *a;
out.push(Outbound::Abilities {
flags: abilities_flags(&a),
flying_speed: a.fly_speed,
walking_speed: a.walk_speed,
});
}
fn collect_block_updates(&mut self, on: bool) {
self.updates.on = on;
if !on {
self.updates.list.clear();
}
}
fn drain_block_updates(&mut self, out: &mut Vec<(BlockPos, u32)>) -> usize {
out.append(&mut self.updates.list);
std::mem::take(&mut self.updates.dropped)
}
fn world_packet_ids(&self) -> Vec<i32> {
self.world.packet_ids().collect()
}
fn entity_config(&self) -> Option<ghast_entity::Config> {
self.entities.as_ref().map(|t| t.config())
}
fn set_entities(&mut self, config: Option<ghast_entity::Config>) {
if self.entity_config() == config {
return;
}
self.entities = config.map(|c| {
let mut t = ghast_entity::v1_12::Tracker::new(c);
self.session.replay(|r| {
if let Err(e) = t.apply(r) {
log::debug!("entity tracker: session packet 0x{:02x}: {e}", r.id);
}
});
t
});
self.near = self.entities.is_some().then(Box::default);
}
fn entity_packet_ids(&self) -> Vec<i32> {
use ghast_protocol::v1_12_2::play::clientbound as cb;
self.entities
.as_ref()
.map(|t| t.packet_ids().chain([cb::id::TEAMS]).collect())
.unwrap_or_default()
}
fn tick_entities(&mut self, pose: &mut Pose) {
if self.near.is_some() {
self.tick_near(pose);
}
}
fn set_entity_push(&mut self, on: bool) {
self.entity_push = on;
}
fn predict_air(&mut self, x: i32, y: i32, z: i32) {
self.world
.set_block_state(x, y, z, ghast_data::v1_12::BlockState::AIR);
}
fn held_item(&self, id: u16, count: u8, efficiency: u8) -> HeldItem {
held_item_facts(DataSet::V1_12, id, count, efficiency)
}
fn step(
&mut self,
pose: &mut Pose,
controls: Controls,
using_item: bool,
entity_id: i32,
out: &mut Vec<Outbound>,
) {
self.packets.clear();
if self.near.as_deref().is_some_and(|n| !n.idle()) {
self.step_near(pose, controls, using_item);
} else {
let input = ghast_physics::TickInput {
keys: keys(controls),
yaw: pose.yaw,
pitch: pose.pitch,
using_item,
};
ghast_physics::v1_12::tick(&mut self.player, &input, &self.world, &mut self.packets);
}
if self.force_step_position != ForceStepPosition::Off {
let p = &mut self.player;
let cur = [p.pos[0], p.bb.min_y, p.pos[2]];
force_position(
&mut self.packets,
cur,
&mut p.sent.pos,
&mut p.sent.ticks_since_pos,
self.force_step_position,
);
}
push_packets(&self.packets, entity_id, out);
sync_pose_12(pose, &self.player);
self.world.advance_time(50);
}
}
fn sync_pose_12(pose: &mut Pose, p: &ghast_physics::v1_12::PlayerState) {
pose.pos = Vec3::new(p.pos[0], p.bb.min_y, p.pos[2]);
pose.motion = Vec3::new(p.vel[0], p.vel[1], p.vel[2]);
pose.yaw = p.yaw;
pose.pitch = p.pitch;
pose.on_ground = p.on_ground;
pose.flying = p.abilities.flying;
pose.sneaking = p.sneaking();
pose.sprinting = p.sprinting;
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Class12 {
Living,
Player,
Boat,
Shulker,
}
fn class_12(e: &ghast_entity::Entity) -> Option<Class12> {
use ghast_entity::EntityType as T;
match e.entity_type() {
T::Player => Some(Class12::Player),
T::LegacyObject(1) => Some(Class12::Boat),
t @ T::LegacyMob(_) => match ghast_entity::v1_12::info(t)?.name {
"shulker" => Some(Class12::Shulker),
"bat" | "parrot" | "armor_stand" | "ender_dragon" => None,
_ => Some(Class12::Living),
},
_ => None,
}
}
const LILY_PAD_REACH: f64 = 16.0;
#[derive(Clone, Debug)]
struct Client12 {
id: i32,
seq: u64,
class: Class12,
pos: [f64; 3],
target: [f64; 3],
steps: u8,
dims: ghast_data::EntityDimensions,
at: [f64; 3],
bb: ghast_physics::math::Aabb,
name: Option<Box<str>>,
scanned: Option<(ghast_physics::math::Aabb, u32)>,
}
impl Client12 {
fn placed(&mut self) {
if self.class == Class12::Shulker {
let [x, y, z] = self.pos;
let (x, y, z) = (x.floor() + 0.5, y.floor(), z.floor() + 0.5);
self.at = [x, y, z];
self.bb =
ghast_physics::math::Aabb::new(x - 0.5, y, z - 0.5, x + 0.5, y + 1.0, z + 0.5);
} else {
self.at = self.pos;
self.bb = self
.dims
.bounding_box(self.pos[0], self.pos[1], self.pos[2]);
}
}
fn interpolate_to(&mut self, target: [f64; 3]) {
match self.class {
Class12::Shulker => {
self.pos = target;
self.target = target;
self.placed();
}
Class12::Boat => {
self.target = target;
self.steps = 10;
}
Class12::Living | Class12::Player => {
self.target = target;
self.steps = 3;
}
}
}
#[inline]
fn step(&mut self) {
if self.steps > 0 {
let n = f64::from(self.steps);
for k in 0..3 {
self.pos[k] += (self.target[k] - self.pos[k]) / n;
}
self.steps -= 1;
self.placed();
}
}
}
#[inline]
fn far(b: &ghast_physics::math::Aabb, p: &ghast_physics::math::Aabb, r: [f64; 3]) -> bool {
b.max_x < p.min_x - r[0]
|| b.min_x > p.max_x + r[0]
|| b.max_y < p.min_y - r[1]
|| b.min_y > p.max_y + r[1]
|| b.max_z < p.min_z - r[2]
|| b.min_z > p.max_z + r[2]
}
#[derive(Debug, Default)]
pub(crate) struct Near12 {
list: Vec<Client12>,
index: std::collections::HashMap<i32, u32>,
seq: u64,
boats: usize,
ghosts: Vec<ghast_physics::math::Aabb>,
solids: Vec<ghast_physics::math::Aabb>,
pushers: Vec<(u64, ghast_physics::v1_12::Pusher)>,
lily_pads: Vec<[i32; 3]>,
pub(super) world_version: u32,
pub(super) teams: super::teams::Teams,
}
fn first_varint(body: &[u8]) -> Option<i32> {
let mut v: u32 = 0;
for (k, &b) in body.iter().take(5).enumerate() {
v |= u32::from(b & 0x7f) << (7 * k);
if b & 0x80 == 0 {
return Some(v as i32);
}
}
None
}
impl Near12 {
fn idle(&self) -> bool {
self.list.is_empty() && self.ghosts.is_empty()
}
fn get_mut(&mut self, id: i32) -> Option<&mut Client12> {
let &k = self.index.get(&id)?;
self.list.get_mut(k as usize)
}
fn packet(&mut self, t: &ghast_entity::v1_12::Tracker, raw: &RawPacket) {
use ghast_protocol::v1_12_2::play::clientbound::id;
match raw.id {
id::LOGIN | id::RESPAWN => {
self.list.clear();
self.index.clear();
self.boats = 0;
self.ghosts.clear();
if raw.id == id::LOGIN {
self.teams.clear();
}
}
id::SPAWN_ENTITY | id::SPAWN_ENTITY_LIVING | id::NAMED_ENTITY_SPAWN => {
let Some(eid) = first_varint(&raw.body) else {
return;
};
self.remove(eid);
if let Some(e) = t.get(eid)
&& let Some(class) = class_12(e)
&& let Some(dims) = e.dimensions()
{
self.seq += 1;
self.boats += usize::from(class == Class12::Boat);
let pos = e.position();
let mut c = Client12 {
id: eid,
seq: self.seq,
class,
pos,
target: pos,
steps: 0,
dims,
at: pos,
bb: ghast_physics::math::Aabb::FULL,
name: t.player_name(eid).map(Into::into),
scanned: None,
};
c.placed();
self.index.insert(eid, self.list.len() as u32);
self.list.push(c);
}
}
id::ENTITY_TELEPORT => {
let Some(eid) = first_varint(&raw.body) else {
return;
};
if let (Some(c), Some(e)) = (self.get_mut(eid), t.get(eid)) {
let d = e.position();
#[allow(clippy::neg_cmp_op_on_partial_ord)]
let tiny = !((c.pos[0] - d[0]).abs() >= 0.03125)
&& !((c.pos[1] - d[1]).abs() >= 0.015625)
&& !((c.pos[2] - d[2]).abs() >= 0.03125);
if tiny && c.class != Class12::Shulker {
c.target = c.pos;
c.steps = 0;
} else {
c.interpolate_to(d);
}
}
}
id::REL_ENTITY_MOVE | id::ENTITY_MOVE_LOOK | id::ENTITY_LOOK | id::ENTITY => {
let Some(eid) = first_varint(&raw.body) else {
return;
};
if let (Some(c), Some(e)) = (self.get_mut(eid), t.get(eid)) {
c.interpolate_to(e.position());
}
}
id::ENTITY_METADATA => {
let Some(eid) = first_varint(&raw.body) else {
return;
};
if let (Some(c), Some(e)) = (self.get_mut(eid), t.get(eid))
&& let Some(d) = e.dimensions()
&& d != c.dims
{
c.dims = d;
c.placed();
}
}
id::ENTITY_DESTROY => {
let mut r = ghast_protocol::Reader::new(&raw.body);
let Ok(n) = r.read_varint() else { return };
for _ in 0..n.max(0) {
let Ok(eid) = r.read_varint() else { return };
self.remove(eid);
}
}
_ => {}
}
}
fn remove(&mut self, eid: i32) {
let Some(k) = self.index.remove(&eid) else {
return;
};
let c = self.list.swap_remove(k as usize);
if let Some(moved) = self.list.get(k as usize) {
self.index.insert(moved.id, k);
}
if c.class == Class12::Boat {
self.boats -= 1;
self.ghosts.push(c.bb);
}
}
fn present(
t: &ghast_entity::v1_12::Tracker,
world: &ghast_world::v1_12::World,
c: &Client12,
) -> bool {
let Some(e) = t.get(c.id) else { return false };
e.vehicle().is_none()
&& e.passengers().is_empty()
&& world.is_column_loaded((c.at[0].floor() as i32) >> 4, (c.at[2].floor() as i32) >> 4)
}
fn solids(
&mut self,
t: &ghast_entity::v1_12::Tracker,
world: &ghast_world::v1_12::World,
p: &ghast_physics::v1_12::PlayerState,
) {
self.solids.clear();
let riding = t.me().is_some_and(|m| m.vehicle().is_some());
let reach = |v: f64| v.abs() + 3.0;
let r = [reach(p.vel[0]), reach(p.vel[1]), reach(p.vel[2])];
for c in &self.list {
if !matches!(c.class, Class12::Boat | Class12::Shulker)
|| far(&c.bb, &p.bb, r)
|| riding
|| !Self::present(t, world, c)
{
continue;
}
if c.class == Class12::Shulker
&& !t
.get(c.id)
.and_then(ghast_entity::v1_12::health)
.is_none_or(|h| h > 0.0)
{
continue;
}
self.solids.push(c.bb);
}
self.solids.extend_from_slice(&self.ghosts);
}
fn tick(
&mut self,
t: &ghast_entity::v1_12::Tracker,
world: &ghast_world::v1_12::World,
p: &ghast_physics::math::Aabb,
pushing: bool,
profile_name: &str,
) {
use ghast_physics::v1_12::{PushKind, Pusher};
self.pushers.clear();
self.lily_pads.clear();
let version = self.world_version;
for c in &mut self.list {
c.step();
if c.class == Class12::Boat
&& c.scanned != Some((c.bb, version))
&& !far(&c.bb, p, [LILY_PAD_REACH; 3])
&& Self::present(t, world, c)
{
ghast_physics::v1_12::lily_pads_broken_by_boat(world, &c.bb, &mut self.lily_pads);
c.scanned = Some((c.bb, version));
}
if !pushing || far(&c.bb, p, [0.25; 3]) || !Self::present(t, world, c) {
continue;
}
let Some(e) = t.get(c.id) else { continue };
if c.class == Class12::Player && t.tab_game_mode(&e.uuid()) == Some(3) {
continue;
}
if self.teams.any_rule() {
let mut buf = [0u8; 36];
let name: &str = match &c.name {
Some(n) => n,
None => e.uuid().hyphenated().encode_lower(&mut buf),
};
if !self.teams.may_push(name, profile_name) {
continue;
}
}
let kind = if c.class == Class12::Boat {
PushKind::Boat
} else {
PushKind::Living
};
self.pushers.push((c.seq, Pusher::new(c.at, c.bb, kind)));
}
self.pushers.sort_unstable_by_key(|x| x.0);
}
}