mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-23 08:49:28 +00:00
92 lines
5.1 KiB
Diff
92 lines
5.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Wed, 23 Nov 2022 20:12:48 +0100
|
|
Subject: [PATCH] Reduce acquire POI for stuck entities
|
|
|
|
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:
|
|
"Skip POI finding if stuck in vehicle"
|
|
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/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
|
index e8aa27547e3fa1a42720889c7038d4fb0273e7b5..f053ee19875e6c1586ffe4ebb0284172af5fbb23 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
|
@@ -13,6 +13,7 @@ import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.GlobalPos;
|
|
import net.minecraft.core.Holder;
|
|
import net.minecraft.network.protocol.game.DebugPackets;
|
|
+import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.world.entity.Mob;
|
|
import net.minecraft.world.entity.PathfinderMob;
|
|
@@ -26,6 +27,13 @@ import org.apache.commons.lang3.mutable.MutableLong;
|
|
public class AcquirePoi {
|
|
public static final int SCAN_RANGE = 48;
|
|
|
|
+ // Gale start - Airplane - reduce acquire POI for stuck entities
|
|
+ public static void addAdditionalTimeToMutableLongIfEntityIsStuck(MutableLong mutableLong, ServerLevel world, PathfinderMob entity) {
|
|
+ long stuckEntityAdditionalWaitTime = world.galeConfig().smallOptimizations.reducedIntervals.acquirePoiForStuckEntity;
|
|
+ mutableLong.add(stuckEntityAdditionalWaitTime <= 0L ? 0L : entity.getNavigation().isStuck() ? stuckEntityAdditionalWaitTime : 0L);
|
|
+ }
|
|
+ // Gale end - Airplane - reduce acquire POI for stuck entities
|
|
+
|
|
public static BehaviorControl<PathfinderMob> create(
|
|
Predicate<Holder<PoiType>> poiPredicate, MemoryModuleType<GlobalPos> poiPosModule, boolean onlyRunIfChild, Optional<Byte> entityStatus
|
|
) {
|
|
@@ -52,12 +60,13 @@ public class AcquirePoi {
|
|
return false;
|
|
} else if (mutableLong.getValue() == 0L) {
|
|
mutableLong.setValue(world.getGameTime() + (long)world.random.nextInt(20));
|
|
+ addAdditionalTimeToMutableLongIfEntityIsStuck(mutableLong, world, entity); // Gale - Airplane - reduce acquire POI for stuck entities
|
|
return false;
|
|
} else if (world.getGameTime() < mutableLong.getValue()) {
|
|
return false;
|
|
} else {
|
|
mutableLong.setValue(time + 20L + (long)world.getRandom().nextInt(20));
|
|
- if (entity.getNavigation().isStuck()) mutableLong.add(200); // Paper - Perf: Wait an additional 10s to check again if they're stuck
|
|
+ addAdditionalTimeToMutableLongIfEntityIsStuck(mutableLong, world, entity); // Paper - Perf: Wait an additional 10s to check again if they're stuck // Gale - Airplane - reduce acquire POI for stuck entities
|
|
PoiManager poiManager = world.getPoiManager();
|
|
long2ObjectMap.long2ObjectEntrySet().removeIf(entry -> !entry.getValue().isStillValid(time));
|
|
Predicate<BlockPos> predicate2 = pos -> {
|
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
index eabe9e6a7f99a7ad1f2a9f210f8a7489a89dc4cc..8a0416775d00148bf3478b51d92b00d9d485c667 100644
|
|
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
@@ -49,6 +49,13 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
|
}
|
|
// Gale end - Airplane - reduce projectile chunk loading
|
|
|
|
+ public ReducedIntervals reducedIntervals;
|
|
+ public class ReducedIntervals extends ConfigurationPart {
|
|
+
|
|
+ public int acquirePoiForStuckEntity = 60; // Gale - Airplane - reduce acquire POI for stuck entities
|
|
+
|
|
+ }
|
|
+
|
|
}
|
|
|
|
}
|