Upstream has released updates that appear to apply and compile correctly. [Purpur Changes] PurpurMC/Purpur@e86a1b6: Updated Upstream (Paper) [Paper Changes] PaperMC/Paper@a6df4c8: Handle corrupt light data gracefully PaperMC/Paper@ce0a041: [ci skip] Rebuild patches [Paper Changes] PaperMC/Paper@c6aa61e: Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11561) PaperMC/Paper@93b435d: [ci skip] better instructions for patch apply conflict (#11568) PaperMC/Paper@42a1901: Correctly adopt upstream item EAR fix (#11582) PaperMC/Paper@fcb6c72: Correctly pass velocity native compressor (#11509) PaperMC/Paper@99f4bb2: Fix infinite fireworks (#11592) (#11594)
78 lines
4.7 KiB
Diff
78 lines
4.7 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 33bcfec86f83ce6e0ec17436ad38da8aeced48be..b047af738236be3400d07d46c663017ed39b6f96 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 Block block;
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index e047c0a4a8638588b4ac0d47c4c96899fac4abb7..14e62940aec1fe4c70b128f2811df6c09c701718 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -62,29 +62,37 @@ public class ActivationRange
|
|
net.minecraft.world.entity.schedule.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;
|