9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-19 14:59:29 +00:00
Files
Gale/gale-archived-patches/removed/legacy/server/0028-Remove-streams-and-iterators-from-range-check.patch
2025-01-07 18:39:31 -05:00

80 lines
3.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 22:53:39 +0100
Subject: [PATCH] Remove streams and iterators from range check
Removed since 1.21.3, replaced by Moonrise optimisation
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 <paul@technove.co>
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 <http://www.gnu.org/licenses/>.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 62bd7523e0d7d2dfdce1ee9edb2249c755f1ade3..a9b6f3ceb45ecd6bcc6d6acc097a5d12aeaae620 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1275,8 +1275,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<Entity> 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()) {
@@ -1288,6 +1310,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);
}