9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-29 03:49:21 +00:00
Files
Leaf/patches/server/0008-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch

63 lines
3.0 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 43beb25bb42f19832da83f6f7f022cb5c85830c1..1c729ea3e40b12ddb95294c666f1568bd69ce4c0 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -224,11 +224,13 @@ public abstract class Mob extends LivingEntity implements Targeting {
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..ad6354ca7c7f8c96831fe4ef8fc624b4bcb90af5
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleInactiveGoalSelectorTick.java
@@ -0,0 +1,29 @@
+package org.dreeam.leaf.config.modules.opt;
+
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+import org.dreeam.leaf.config.ConfigInfo;
+import org.dreeam.leaf.config.EnumConfigCategory;
+import org.dreeam.leaf.config.IConfigModule;
+
+public class ThrottleInactiveGoalSelectorTick implements IConfigModule {
+
+ @Override
+ public EnumConfigCategory getCategory() {
+ return EnumConfigCategory.PERFORMANCE;
+ }
+
+ @Override
+ public String getBaseName() {
+ return "inactive_goal_selector_throttle";
+ }
+
+ @ConfigInfo(baseName = "enabled")
+ public static boolean enabled = true;
+
+ @Override
+ public void onLoaded(CommentedFileConfig config) {
+ config.setComment("performance.inactive_goal_selector_throttle", """
+ Throttles the AI goal selector in entity inactive ticks.
+ This can improve performance by a few percent, but has minor gameplay implications.""");
+ }
+}