77 lines
4.6 KiB
Diff
77 lines
4.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: AlphaKR93 <dev@alpha93.kr>
|
|
Date: Mon, 4 Dec 2023 23:01:32 +0900
|
|
Subject: [PATCH] Variable entity wakeup duration
|
|
|
|
|
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
index eff241544ba009f62179fb1668bd9d78795e7002..8690dc9d818d7991c7b05d471c547b4cb1713bbe 100644
|
|
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
@@ -37,6 +37,20 @@ public class WorldConfigurations extends ConfigurationPart {
|
|
|
|
}
|
|
|
|
+ public WakeUpDurationVariance wakeUpDurationVariance;
|
|
+ public class WakeUpDurationVariance extends ConfigurationPart {
|
|
+
|
|
+ private double defaultValue() {
|
|
+ return OPTIMIZE ? 0.2 : 0.0;
|
|
+ }
|
|
+
|
|
+ double animal = defaultValue(); public double animal() { return Math.max(this.animal, 0.0); }
|
|
+ double monster = defaultValue(); public double monster() { return Math.max(this.monster, 0.0); }
|
|
+ double flying = defaultValue(); public double flying() { return Math.max(this.flying, 0.0); }
|
|
+ double villager = defaultValue(); public double villager() { return Math.max(this.villager, 0.0); }
|
|
+
|
|
+ }
|
|
+
|
|
}
|
|
|
|
public Structure structure;
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index ed1cdea66dd117ecafd14a52727f094430f39b60..2c30e659d0ec28c0ec4f8ccb0fa29de5a31d3881 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -67,29 +67,36 @@ public class ActivationRange
|
|
Activity.PANIC
|
|
};
|
|
|
|
+ // Plazma start - Variable entity wakeup duration
|
|
+ private static int getWakeupDuration(net.minecraft.util.RandomSource random, int duration, double deviation) {
|
|
+ if (deviation == 0) return duration;
|
|
+ return (int) Math.min(Integer.MAX_VALUE, Math.max(1, Math.round(duration * (1 + deviation * random.nextGaussian()))));
|
|
+ }
|
|
+ // Plazma end - Variable entity wakeup duration
|
|
private static int checkInactiveWakeup(Entity entity) {
|
|
Level world = entity.level();
|
|
SpigotWorldConfig config = world.spigotConfig;
|
|
+ org.plazmamc.plazma.configurations.WorldConfigurations plazmaConfig = world.plazmaConfig(); // Plazma - Variable entity wakeup duration
|
|
long inactiveFor = MinecraftServer.currentTick - entity.activatedTick;
|
|
if (entity.activationType == ActivationType.VILLAGER) {
|
|
if (inactiveFor > config.wakeUpInactiveVillagersEvery && world.wakeupInactiveRemainingVillagers > 0) {
|
|
world.wakeupInactiveRemainingVillagers--;
|
|
- return config.wakeUpInactiveVillagersFor;
|
|
+ return getWakeupDuration(world.getRandom(), config.wakeUpInactiveVillagersFor, plazmaConfig.entity.wakeUpDurationVariance.villager()); // Plazma - Variable entity wakeup duration
|
|
}
|
|
} else if (entity.activationType == ActivationType.ANIMAL) {
|
|
if (inactiveFor > config.wakeUpInactiveAnimalsEvery && world.wakeupInactiveRemainingAnimals > 0) {
|
|
world.wakeupInactiveRemainingAnimals--;
|
|
- return config.wakeUpInactiveAnimalsFor;
|
|
+ return getWakeupDuration(world.getRandom(), config.wakeUpInactiveAnimalsFor, plazmaConfig.entity.wakeUpDurationVariance.animal()); // Plazma - Variable entity wakeup duration
|
|
}
|
|
} else if (entity.activationType == ActivationType.FLYING_MONSTER) {
|
|
if (inactiveFor > config.wakeUpInactiveFlyingEvery && world.wakeupInactiveRemainingFlying > 0) {
|
|
world.wakeupInactiveRemainingFlying--;
|
|
- return config.wakeUpInactiveFlyingFor;
|
|
+ return getWakeupDuration(world.getRandom(), config.wakeUpInactiveFlyingFor, plazmaConfig.entity.wakeUpDurationVariance.flying()); // Plazma - Variable entity wakeup duration
|
|
}
|
|
} else if (entity.activationType == ActivationType.MONSTER || entity.activationType == ActivationType.RAIDER) {
|
|
if (inactiveFor > config.wakeUpInactiveMonstersEvery && world.wakeupInactiveRemainingMonsters > 0) {
|
|
world.wakeupInactiveRemainingMonsters--;
|
|
- return config.wakeUpInactiveMonstersFor;
|
|
+ return getWakeupDuration(world.getRandom(), config.wakeUpInactiveMonstersFor, plazmaConfig.entity.wakeUpDurationVariance.monster()); // Plazma - Variable entity wakeup duration
|
|
}
|
|
}
|
|
return -1;
|