83 lines
4.5 KiB
Diff
83 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <wangxyper@163.com>
|
|
Date: Wed, 31 Jul 2024 13:30:56 +0800
|
|
Subject: [PATCH] Gale Variable entity wake-up duration
|
|
|
|
|
|
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/GaleVariableEntityWakeupConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/GaleVariableEntityWakeupConfig.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..fa30e8dc39a2d4bd1399e41230b307b19eeb716a
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/GaleVariableEntityWakeupConfig.java
|
|
@@ -0,0 +1,20 @@
|
|
+package me.earthme.luminol.config.modules.optimizations;
|
|
+
|
|
+import me.earthme.luminol.config.ConfigInfo;
|
|
+import me.earthme.luminol.config.EnumConfigCategory;
|
|
+import me.earthme.luminol.config.IConfigModule;
|
|
+
|
|
+public class GaleVariableEntityWakeupConfig implements IConfigModule {
|
|
+ @ConfigInfo(baseName = "entity_wakeup_duration_ratio_standard_deviation")
|
|
+ public static double entityWakeUpDurationRatioStandardDeviation = 0.2;
|
|
+
|
|
+ @Override
|
|
+ public EnumConfigCategory getCategory() {
|
|
+ return EnumConfigCategory.OPTIMIZATIONS;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getBaseName() {
|
|
+ return "variable_entity_waking_up";
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index c17e9782850fd88b9a46d31bf9075624ffc11709..e1f0aedbc42c6e969ba155c358f4ee30efd8ffe8 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -75,28 +75,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 = me.earthme.luminol.config.modules.optimizations.GaleVariableEntityWakeupConfig.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
|
|
|
|
/**
|