77 lines
4.7 KiB
Diff
77 lines
4.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <novau233@163.com>
|
|
Date: Tue, 6 Feb 2024 03:52:35 +0000
|
|
Subject: [PATCH] Gale Variable entity wake-up duration
|
|
|
|
|
|
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
index fead5b1be39083f3fe28be8c41dc78dcac4b59da..aed42e6fa85c8ab5b57e1d09dd840bb49ffe0006 100644
|
|
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
@@ -56,6 +56,7 @@ public class LuminolConfig {
|
|
public static int startDistanceSquared;
|
|
public static int maximumActivationPrio;
|
|
public static int activationDistanceMod;
|
|
+ public static double entityWakeUpDurationRatioStandardDeviation = 0.2;
|
|
|
|
|
|
public static void init() throws IOException {
|
|
@@ -167,6 +168,7 @@ public class LuminolConfig {
|
|
maxProjectileLoadsPerTick = get("optimizations.projectile.max-loads-per-tick", maxProjectileLoadsPerTick, "Controls how many chunks are allowed \nto be sync loaded by projectiles in a tick.");
|
|
maxProjectileLoadsPerProjectile = get("optimizations.projectile.max-loads-per-projectile", maxProjectileLoadsPerProjectile, "Controls how many chunks a projectile \n can load in its lifetime before it gets \nautomatically removed.");
|
|
initDAB();
|
|
+ entityWakeUpDurationRatioStandardDeviation = get("optimizations.entity_wakeup_duration_ratio_standard_deviation",entityWakeUpDurationRatioStandardDeviation);
|
|
}
|
|
|
|
public static <T> T get(String key,T def){
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index bcb21ed7f9d425d94d62822c32ec77a197ce3dd6..9cde36cb62b73b96467033901172b22a3c373081 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -76,28 +76,41 @@ public class ActivationRange
|
|
if (entity.activationType == ActivationType.VILLAGER) {
|
|
if (inactiveFor > config.wakeUpInactiveVillagersEvery && worldData.wakeupInactiveRemainingVillagers > 0) { // Folia - threaded regions
|
|
worldData.wakeupInactiveRemainingVillagers--; // Folia - threaded regions
|
|
- return config.wakeUpInactiveVillagersFor;
|
|
+ return getWakeUpDurationWithVariance(entity, config.wakeUpInactiveVillagersFor); // Gale - variable entity wake-up duration
|
|
}
|
|
} else if (entity.activationType == ActivationType.ANIMAL) {
|
|
if (inactiveFor > config.wakeUpInactiveAnimalsEvery && worldData.wakeupInactiveRemainingAnimals > 0) { // Folia - threaded regions
|
|
worldData.wakeupInactiveRemainingAnimals--; // Folia - threaded regions
|
|
- return config.wakeUpInactiveAnimalsFor;
|
|
+ return getWakeUpDurationWithVariance(entity, config.wakeUpInactiveAnimalsFor); // Gale - variable entity wake-up duration
|
|
}
|
|
} else if (entity.activationType == ActivationType.FLYING_MONSTER) {
|
|
if (inactiveFor > config.wakeUpInactiveFlyingEvery && worldData.wakeupInactiveRemainingFlying > 0) { // Folia - threaded regions
|
|
worldData.wakeupInactiveRemainingFlying--; // Folia - threaded regions
|
|
- return config.wakeUpInactiveFlyingFor;
|
|
+ return getWakeUpDurationWithVariance(entity, config.wakeUpInactiveFlyingFor); // Gale - variable entity wake-up duration
|
|
}
|
|
} else if (entity.activationType == ActivationType.MONSTER || entity.activationType == ActivationType.RAIDER) {
|
|
if (inactiveFor > config.wakeUpInactiveMonstersEvery && worldData.wakeupInactiveRemainingMonsters > 0) { // Folia - threaded regions
|
|
worldData.wakeupInactiveRemainingMonsters--; // Folia - threaded regions
|
|
- return config.wakeUpInactiveMonstersFor;
|
|
+ return getWakeUpDurationWithVariance(entity, config.wakeUpInactiveMonstersFor); // Gale - variable entity wake-up duration
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
// Paper end
|
|
|
|
+ // Gale start - variable entity wake-up duration
|
|
+ private static final java.util.concurrent.ThreadLocalRandom wakeUpDurationRandom = java.util.concurrent.ThreadLocalRandom.current();
|
|
+
|
|
+ private static int getWakeUpDurationWithVariance(Entity entity, int wakeUpDuration) {
|
|
+ double deviation = LuminolConfig.entityWakeUpDurationRatioStandardDeviation;
|
|
+ if (deviation <= 0) {
|
|
+ return wakeUpDuration;
|
|
+ }
|
|
+ return (int) Math.min(Integer.MAX_VALUE, Math.max(1, Math.round(wakeUpDuration * wakeUpDurationRandom.nextGaussian(1, deviation))));
|
|
+ }
|
|
+ // Gale end - variable entity wake-up duration
|
|
+
|
|
+
|
|
// Folia - threaded regions - replaced by local variable
|
|
|
|
/**
|