9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-06 15:51:31 +00:00
Files
Leaf/patches/server/0036-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch
2023-04-30 06:40:14 -04:00

58 lines
3.4 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 7123da061c8d66710f2bf73d1b0ac2995ee4df71..87ca33ae5c283aa17174f3e4511687fe5d5fd53b 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -84,6 +84,7 @@ import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTransformEvent;
import org.bukkit.event.entity.EntityUnleashEvent;
import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason;
+import org.dreeam.leaf.LeafConfig;
// CraftBukkit end
public abstract class Mob extends LivingEntity implements Targeting {
@@ -217,11 +218,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 = LeafConfig.throttleInactiveGoalSelectorTick && _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/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java
index 64c3cf708c17b664d2c6615abfa30ec0e54835f8..671826af1dcacc67f87e9f08fb36eb86a281e334 100644
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
@@ -202,6 +202,7 @@ public class LeafConfig {
public static int startDistanceSquared;
public static int maximumActivationPrio;
public static int activationDistanceMod;
+ public static boolean throttleInactiveGoalSelectorTick;
private static void performance() {
laggingThreshold = getDouble("performance.lagging-threshold", laggingThreshold);
tpsCatchup = getBoolean("performance.tps-catchup", tpsCatchup);
@@ -250,6 +251,9 @@ public class LeafConfig {
entityType.dabEnabled = false;
}, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\"")));
setComment("dab", "Optimizes entity brains when", "they're far away from the player");
+ throttleInactiveGoalSelectorTick = getBoolean("inactive-goal-selector-throttle", "inactive-goal-selector-disable", true,
+ "Throttles the AI goal selector in entity inactive ticks.",
+ "This can improve performance by a few percent, but has minor gameplay implications.");
}
public static String commandTPSBarOutput = "<green>Tpsbar toggled <onoff> for <target>";