Merge pull request #951 from ludovic111/fix/entity-ticks-ticking-area
🤖 Agent: merged after verify and CI parity passed. Non-living entities (TNT, falling blocks, boats, frames…) now tick only in entity-ticking chunks, as in vanilla.
This commit is contained in:
@@ -2594,7 +2594,12 @@ impl Game<'_> {
|
||||
let mut dropped = Vec::new();
|
||||
let mut collision_error = None;
|
||||
let entity_drops = self.ui.rules.bool("entity_drops");
|
||||
// ServerLevel.tick: only entities in entity-ticking chunks tick.
|
||||
let ticking = self.entity_ticking_area();
|
||||
falling.retain_mut(|f| {
|
||||
if !ticking(f.position.x.floor() as i32, f.position.z.floor() as i32) {
|
||||
return true;
|
||||
}
|
||||
let original = f.clone();
|
||||
f.previous = f.position;
|
||||
f.age = f.age.wrapping_add(1);
|
||||
|
||||
@@ -382,7 +382,12 @@ impl Game<'_> {
|
||||
subject: None,
|
||||
};
|
||||
let mut dead = Vec::new();
|
||||
// ServerLevel.tick: only entities in entity-ticking chunks tick.
|
||||
let ticking = self.entity_ticking_area();
|
||||
for (i, a) in self.armor_stands.iter_mut().enumerate() {
|
||||
if !ticking(a.position.x.floor() as i32, a.position.z.floor() as i32) {
|
||||
continue;
|
||||
}
|
||||
a.tick(&mut scene);
|
||||
if !a.environment_tick(&self.world, self.res.facts(), self.pack.assets.registry) {
|
||||
dead.push(i);
|
||||
|
||||
@@ -443,8 +443,13 @@ impl Game<'_> {
|
||||
}
|
||||
/// Every boat but the ridden one (which ticks with its rider).
|
||||
pub(super) fn tick_boats(&mut self) {
|
||||
// ServerLevel.tick: only entities in entity-ticking chunks tick.
|
||||
let ticking = self.entity_ticking_area();
|
||||
for i in 0..self.boats.len() {
|
||||
if Some(self.boats[i].id) == self.riding {
|
||||
let p = self.boats[i].position;
|
||||
if Some(self.boats[i].id) == self.riding
|
||||
|| !ticking(p.x.floor() as i32, p.z.floor() as i32)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let b = self.boats[i].clone();
|
||||
|
||||
@@ -282,8 +282,15 @@ impl Game<'_> {
|
||||
}
|
||||
/// BlockAttachedEntity.tick for frames.
|
||||
pub(super) fn tick_item_frames(&mut self) {
|
||||
// ServerLevel.tick: only entities in entity-ticking chunks tick.
|
||||
let ticking = self.entity_ticking_area();
|
||||
let mut i = 0;
|
||||
while i < self.item_frames.len() {
|
||||
let at = center(&self.item_frames[i]);
|
||||
if !ticking(at[0].floor() as i32, at[2].floor() as i32) {
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
self.item_frames[i].check_interval += 1;
|
||||
if self.item_frames[i].check_interval >= 100 {
|
||||
self.item_frames[i].check_interval = 0;
|
||||
|
||||
@@ -232,8 +232,16 @@ impl Game<'_> {
|
||||
}
|
||||
/// BlockAttachedEntity.tick: check survival every 100 ticks.
|
||||
pub(super) fn tick_paintings(&mut self) {
|
||||
// ServerLevel.tick: only entities in entity-ticking chunks tick.
|
||||
let ticking = self.entity_ticking_area();
|
||||
let mut i = 0;
|
||||
while i < self.paintings.len() {
|
||||
let (lo, hi) = self.paintings[i].bounds();
|
||||
let centre = [0, 2].map(|k| ((lo[k] + hi[k]) / 2.0).floor() as i32);
|
||||
if !ticking(centre[0], centre[1]) {
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
self.paintings[i].check_interval += 1;
|
||||
if self.paintings[i].check_interval >= 100 {
|
||||
self.paintings[i].check_interval = 0;
|
||||
|
||||
@@ -156,8 +156,14 @@ impl Game<'_> {
|
||||
pub(super) fn tick_tnt(&mut self) -> Result<()> {
|
||||
let mut count = self.tnts.len();
|
||||
let mut i = 0;
|
||||
// ServerLevel.tick: only entities in entity-ticking chunks tick.
|
||||
let ticking = self.entity_ticking_area();
|
||||
while i < count {
|
||||
let t = &mut self.tnts[i];
|
||||
if !ticking(t.position.x.floor() as i32, t.position.z.floor() as i32) {
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
t.tick(
|
||||
&self.world,
|
||||
self.collision,
|
||||
|
||||
Reference in New Issue
Block a user