9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-04 15:41:40 +00:00
Files
Leaf/patches/unapplied/server/0006-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch

50 lines
3.1 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 bb32b2d71b65254ccfa6a73e7debc63f801e7dc5..db0fb4cd2041b456269479bd97751bd78d9593e9 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -222,11 +222,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.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 7aa266b6cecb7e8d2bed41ec2e68f057deb99d05..9cfa1d626c83a5c2fb1ae7db4746a4cb07262778 100644
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
@@ -171,6 +171,7 @@ public class LeafConfig {
public static int startDistanceSquared;
public static int maximumActivationPrio = 20;
public static int activationDistanceMod = 8;
+ public static boolean throttleInactiveGoalSelectorTick = true;
private static void performance() {
dabEnabled = getBoolean("performance.dab.enabled", "dab.enabled", dabEnabled);
startDistance = getInt("performance.dab.start-distance", "dab.start-distance", startDistance,
@@ -193,6 +194,9 @@ public class LeafConfig {
entityType.dabEnabled = false;
}, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\"")));
setComment("performance.dab", "Optimizes entity brains when", "they're far away from the player");
+ throttleInactiveGoalSelectorTick = getBoolean("performance.inactive-goal-selector-throttle", "inactive-goal-selector-throttle", throttleInactiveGoalSelectorTick,
+ "Throttles the AI goal selector in entity inactive ticks.",
+ "This can improve performance by a few percent, but has minor gameplay implications.");
}
private static void network() {