9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-22 00:19:20 +00:00
Files
Leaf/patches/server/0095-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch
2024-08-23 20:24:06 -04:00

63 lines
3.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: froobynooby <froobynooby@froobworld.com>
Date: Mon, 5 Aug 2024 20:33:57 +0800
Subject: [PATCH] Paper PR: Skip AI during inactive ticks for non-aware mobs
Original license: GPLv3
Original project: https://github.com/PaperMC/Paper
Paper pull request: https://github.com/PaperMC/Paper/pull/10990
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 96a165dc8a0ec8cb0e7828d2169b2efc51c638c7..41e1df6e4d7e859285ce482df841b0ac07338272 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -239,6 +239,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
@Override
public void inactiveTick() {
super.inactiveTick();
+ // Paper start - Skip AI during inactive ticks for non-aware mobs
+ if (org.dreeam.leaf.config.modules.opt.SkipAIForNonAwareMob.enabled && !(this.isEffectiveAi() && this.aware)) {
+ return;
+ }
+ // Paper end - Skip AI during inactive ticks for non-aware mobs
boolean isThrottled = org.dreeam.leaf.config.modules.opt.ThrottleInactiveGoalSelectorTick.enabled && _pufferfish_inactiveTickDisableCounter++ % 20 != 0; // Pufferfish - throttle inactive goal selector ticking
if (this.goalSelector.inactiveTick(this.activatedPriority, true) && !isThrottled) { // Pufferfish - pass activated priroity // Pufferfish - throttle inactive goal selector ticking
this.goalSelector.tick();
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index 77363d072d48313fe6c0d00dc720813a88997ab1..a6ba083b39c95dfbbd15e668032350fcb02cd256 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -324,7 +324,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
if (this.getUnhappyCounter() > 0) {
this.setUnhappyCounter(this.getUnhappyCounter() - 1);
}
- if (this.isEffectiveAi()) {
+ if (this.isEffectiveAi() && (!org.dreeam.leaf.config.modules.opt.SkipAIForNonAwareMob.enabled || this.aware)) { // Paper - Skip AI during inactive ticks for non-aware mobs
if (this.level().spigotConfig.tickInactiveVillagers) {
this.customServerAiStep();
} else {
diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/SkipAIForNonAwareMob.java b/src/main/java/org/dreeam/leaf/config/modules/opt/SkipAIForNonAwareMob.java
new file mode 100644
index 0000000000000000000000000000000000000000..f97ca316694e850e1626e223fb7c6da3f8ea9ca5
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/SkipAIForNonAwareMob.java
@@ -0,0 +1,18 @@
+package org.dreeam.leaf.config.modules.opt;
+
+import org.dreeam.leaf.config.ConfigModules;
+import org.dreeam.leaf.config.EnumConfigCategory;
+
+public class SkipAIForNonAwareMob extends ConfigModules {
+
+ public String getBasePath() {
+ return EnumConfigCategory.PERF.getBaseKeyName();
+ }
+
+ public static boolean enabled = true;
+
+ @Override
+ public void onLoaded() {
+ enabled = config().getBoolean(getBasePath() + ".skip-ai-for-non-aware-mob", enabled);
+ }
+}