mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-19 14:59:29 +00:00
66 lines
3.8 KiB
Diff
66 lines
3.8 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/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
|
index b9174ae7e3a3e2de2d570b95ab5012ac3c3a2eda..751e91a922b20c96f27885c3eb085ec4ae39091b 100644
|
|
--- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
|
+++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
|
@@ -28,6 +28,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
|
|
+ private static void addAdditionalTimeToMutableLongIfMobIsStuck(MutableLong mutableLong, net.minecraft.server.level.ServerLevel level, PathfinderMob mob) {
|
|
+ long stuckEntityAdditionalWaitTime = level.galeConfig().smallOptimizations.reducedIntervals.acquirePoiForStuckEntity;
|
|
+ mutableLong.add(stuckEntityAdditionalWaitTime <= 0L ? 0L : mob.getNavigation().isStuck() ? stuckEntityAdditionalWaitTime : 0L);
|
|
+ }
|
|
+ // Gale end - Airplane - reduce acquire POI for stuck entities
|
|
+
|
|
public static BehaviorControl<PathfinderMob> create(
|
|
Predicate<Holder<PoiType>> acquirablePois,
|
|
MemoryModuleType<GlobalPos> acquiringMemory,
|
|
@@ -65,12 +72,13 @@ public class AcquirePoi {
|
|
return false;
|
|
} else if (mutableLong.getValue() == 0L) {
|
|
mutableLong.setValue(level.getGameTime() + level.random.nextInt(20));
|
|
+ addAdditionalTimeToMutableLongIfMobIsStuck(mutableLong, level, mob); // Gale - Airplane - reduce acquire POI for stuck entities
|
|
return false;
|
|
} else if (level.getGameTime() < mutableLong.getValue()) {
|
|
return false;
|
|
} else {
|
|
mutableLong.setValue(time + 20L + level.getRandom().nextInt(20));
|
|
- if (mob.getNavigation().isStuck()) mutableLong.add(200); // Paper - Perf: Wait an additional 10s to check again if they're stuck // TODO Modifies Vanilla behavior, add config option
|
|
+ addAdditionalTimeToMutableLongIfMobIsStuck(mutableLong, level, mob); // Paper - Perf: Wait an additional 10s to check again if they're stuck // TODO Modifies Vanilla behavior, add config option // Gale - Airplane - reduce acquire POI for stuck entities
|
|
PoiManager poiManager = level.getPoiManager();
|
|
map.long2ObjectEntrySet().removeIf(entry -> !entry.getValue().isStillValid(time));
|
|
Predicate<BlockPos> predicate1 = pos -> {
|