mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-06 15:51:31 +00:00
58 lines
3.4 KiB
Diff
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 979b76d58d05c9d83dfae45d3052eea9431dfc65..1674f9accbbbb9ecdd99f05da6032398c4d82b38 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -83,6 +83,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 {
|
|
@@ -220,11 +221,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 173c9d76c478a078b235e71707904ba58e0ec4f3..beb548a047b7dedabbd5a720102b7e0400cea6d8 100644
|
|
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
|
|
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
|
|
@@ -174,6 +174,7 @@ public class LeafConfig {
|
|
public static int startDistanceSquared;
|
|
public static int maximumActivationPrio;
|
|
public static int activationDistanceMod;
|
|
+ public static boolean throttleInactiveGoalSelectorTick;
|
|
private static void performance() {
|
|
String sentryEnvironment = System.getenv("SENTRY_DSN");
|
|
String sentryConfig = getString("performance.sentry-dsn", sentryDsn, "Sentry DSN for improved error logging, leave blank to disable", "Obtain from https://sentry.io/");
|
|
@@ -214,6 +215,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", true,
|
|
+ "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() {
|