mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-31 04:46:38 +00:00
50 lines
3.1 KiB
Diff
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 979b76d58d05c9d83dfae45d3052eea9431dfc65..20e0e03efc8bc878bc4a1fe66d2d4027b381d7c4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -220,11 +220,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 47c7b75b721bb2210eded56a7590612fbc3a395c..9a11228726c9a489181fc8a0c511ea83cdcf0f6e 100644
|
|
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
|
|
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
|
|
@@ -173,6 +173,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() {
|
|
boolean asyncMobSpawning = getBoolean("performance.enable-async-mob-spawning", enableAsyncMobSpawning,
|
|
"Whether or not asynchronous mob spawning should be enabled.",
|
|
@@ -206,6 +207,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() {
|