9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-22 16:39:22 +00:00
Files
Leaf/patches/server/0120-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch
Dreeam 27134f699a Added some optimizations (#164)
* uwu

* reorder

* Change author

* Sync upstream

* Lithium: equipment tracking

* Faster CraftServer#getworlds list creation

Co-Authored-By: Kobe ⑧ <102713261+HaHaWTH@users.noreply.github.com>
2024-11-14 06:50:59 -05: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 02d7180e5b932dd8c7e8867f1334cbc47e26f5bd..9d196c8a8a0dc49a54264471429b6ff6da8c2b06 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 92e81a7092e594d1fbe2b239af363739fbba881a..0dc4491799806dc53da0c3815a02c082409ec988 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -323,7 +323,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);
+ }
+}