From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Martijn Muijsers Date: Wed, 23 Nov 2022 22:53:39 +0100 Subject: [PATCH] Remove streams and iterators from range check License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org This patch is based on the following patch: "Remove streams and iterators from range check" By: Paul Sauve As part of: Airplane (https://github.com/TECHNOVE/Airplane) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) * Airplane copyright * Airplane Copyright (C) 2020 Technove LLC This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java index 67d778ef115fc1e09fc8fa9c21d17613a11ca17f..eb12a3c0aefb3d6a42f08439db1ca51e3db65241 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -1549,8 +1549,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return ChunkMap.this.level.getServer().getScaledTrackingDistance(initialDistance); } + // Gale start - Airplane - remove streams and iterators from range check + private static int getHighestRange(Entity parent, int highest) { + List passengers = parent.getPassengers(); + + for (int i = 0, size = passengers.size(); i < size; i++) { + Entity entity = passengers.get(i); + int range = entity.getType().clientTrackingRange() * 16; + range = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, range); // Paper + + if (range > highest) { // Paper - we need the lowest range thanks to the fact that our tracker doesn't account for passenger logic // Tuinity - not anymore! + highest = range; + } + + highest = getHighestRange(entity, highest); + } + + return highest; + } + // Gale end - Airplane - remove streams and iterators from range check + private int getEffectiveRange() { int i = this.range; + // Gale start - Airplane - remove streams and iterators from range check + /* Iterator iterator = this.entity.getIndirectPassengers().iterator(); while (iterator.hasNext()) { @@ -1562,6 +1584,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider i = j; } } + */ + i = getHighestRange(this.entity, i); + // Gale end - Airplane - remove streams and iterators from range check return this.scaledRange(i); }