9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-04 15:41:40 +00:00
Files
Leaf/patches/server/0009-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch
Dreeam d4fcc796c6 Add Leaf Bootstrap
Also fixed Ignore terminal provider warning not working
2024-07-31 22:24:37 +08:00

54 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kevin Raneri <kevin.raneri@gmail.com>
Date: Sat, 11 Dec 2021 22:20:45 -0500
Subject: [PATCH] Pufferfish: Throttle goal selector during inactive ticking
Original license: GPL v3
Original project: https://github.com/pufferfish-gg/Pufferfish
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 96e7e9ef8bf9ab6902638ac4ba270a1f98a36cdf..6d88b2888d2028cb88e34dce3d7963dd818b58d7 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -233,11 +233,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
return this.lookControl;
}
+ int _pufferfish_inactiveTickDisableCounter = 0; // Pufferfish - throttle inactive goal selector ticking
// Paper start
@Override
public void inactiveTick() {
super.inactiveTick();
- if (this.goalSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priroity
+ 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();
}
if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priority
diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleInactiveGoalSelectorTick.java b/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleInactiveGoalSelectorTick.java
new file mode 100644
index 0000000000000000000000000000000000000000..3e2b97faa4fddcd0dfbfedc8e7515f89b7cdb3bb
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleInactiveGoalSelectorTick.java
@@ -0,0 +1,20 @@
+package org.dreeam.leaf.config.modules.opt;
+
+import org.dreeam.leaf.config.ConfigModules;
+import org.dreeam.leaf.config.EnumConfigCategory;
+
+public class ThrottleInactiveGoalSelectorTick extends ConfigModules {
+
+ public String getBasePath() {
+ return EnumConfigCategory.PERF.getBaseKeyName();
+ }
+
+ public static boolean enabled = true;
+
+ @Override
+ public void onLoaded() {
+ enabled = config.getBoolean(getBasePath() + ".inactive-goal-selector-throttle", enabled, """
+ Throttles the AI goal selector in entity inactive ticks.
+ This can improve performance by a few percent, but has minor gameplay implications.""");
+ }
+}