mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-30 12:29:18 +00:00
43 lines
2.2 KiB
Diff
43 lines
2.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Mon, 15 Aug 2022 10:45:13 +0800
|
|
Subject: [PATCH] Throttle goal selector during inactive ticking
|
|
|
|
This patch is Powered by Pufferfish(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 fffa6ba329b38433a1df51df339df652d3fda828..f65bdf9a94db15b8b82a6f8dd729fb435610defa 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -210,11 +210,13 @@ public abstract class Mob extends LivingEntity {
|
|
return this.lookControl;
|
|
}
|
|
|
|
+ int inactiveTickDisableCounter = 0; // Leaves - throttle inactive goal selector ticking
|
|
// Paper start
|
|
@Override
|
|
public void inactiveTick() {
|
|
super.inactiveTick();
|
|
- if (this.goalSelector.inactiveTick()) {
|
|
+ boolean isThrottled = top.leavesmc.leaves.LeavesConfig.throttleInactiveGoalSelectorTick && inactiveTickDisableCounter++ % 20 != 0; // Leaves - throttle inactive goal selector ticking
|
|
+ if (this.goalSelector.inactiveTick() && !isThrottled) { // Leaves - throttle inactive goal selector ticking
|
|
this.goalSelector.tick();
|
|
}
|
|
if (this.targetSelector.inactiveTick()) {
|
|
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
index 89ec4bd328fe08407552f4e26d6ac4586fd1d697..c21ba7b31a6ee4599f0e7e0b2dbf4a5e46a53a19 100644
|
|
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
@@ -305,6 +305,11 @@ public final class LeavesConfig {
|
|
disableMethodProfiler = getBoolean("settings.misc.disable-method-profiler", disableMethodProfiler);
|
|
}
|
|
|
|
+ public static boolean throttleInactiveGoalSelectorTick = false;
|
|
+ private static void throttleInactiveGoalSelectorTick() {
|
|
+ throttleInactiveGoalSelectorTick = getBoolean("settings.performance.inactive-goal-selector-disable", throttleInactiveGoalSelectorTick);
|
|
+ }
|
|
+
|
|
public static final class WorldConfig {
|
|
|
|
public final String worldName;
|