9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2026-01-04 15:41:31 +00:00
Files
LeavesMC/patches/server/0025-Only-check-for-spooky-season-once-an-hour.patch
2022-08-17 10:31:39 +08:00

63 lines
3.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <58360096+s-yh-china@users.noreply.github.com>
Date: Sun, 14 Aug 2022 10:35:42 +0800
Subject: [PATCH] Only check for spooky season once an hour
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
index 50d4595b81f24949011c7565c5e3fc8c26c86019..8de1653e3fbf29e9de550a1976344bd8967485e3 100644
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
@@ -253,13 +253,30 @@ public class Bat extends AmbientCreature {
}
}
+ // Leaves start - only check for spooky season once an hour
+ private static boolean isSpookySeason = false;
+ private static final int ONE_HOUR = 20 * 60 * 60;
+ private static int lastSpookyCheck = -ONE_HOUR;
private static boolean isHalloween() {
- LocalDate localdate = LocalDate.now();
- int i = localdate.get(ChronoField.DAY_OF_MONTH);
- int j = localdate.get(ChronoField.MONTH_OF_YEAR);
+ if (top.leavesmc.leaves.LeavesConfig.checkSpookySeasonOnceAnHour) {
+ if (net.minecraft.server.MinecraftServer.currentTick - lastSpookyCheck > ONE_HOUR) {
+ LocalDate localdate = LocalDate.now();
+ int i = localdate.get(ChronoField.DAY_OF_MONTH);
+ int j = localdate.get(ChronoField.MONTH_OF_YEAR);
+
+ isSpookySeason = j == 10 && i >= 20 || j == 11 && i <= 3;
+ lastSpookyCheck = net.minecraft.server.MinecraftServer.currentTick;
+ }
+ return isSpookySeason;
+ } else {
+ LocalDate localdate = LocalDate.now();
+ int i = localdate.get(ChronoField.DAY_OF_MONTH);
+ int j = localdate.get(ChronoField.MONTH_OF_YEAR);
- return j == 10 && i >= 20 || j == 11 && i <= 3;
+ return j == 10 && i >= 20 || j == 11 && i <= 3;
+ }
}
+ // Leaves end - only check for spooky season once an hour
@Override
protected float getStandingEyeHeight(Pose pose, EntityDimensions dimensions) {
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 76c4110c54c8a883fd015a434c7b101fa3fbb18b..a675e5ebf5d8ee2ff7dfc86fe93293f1366b886a 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -258,6 +258,11 @@ public final class LeavesConfig {
entityStripRaytracing = getBoolean("settings.performance.strip-raytracing-for-entity", entityStripRaytracing);
}
+ public static boolean checkSpookySeasonOnceAnHour = true;
+ private static void checkSpookySeasonOnceAnHour() {
+ checkSpookySeasonOnceAnHour = getBoolean("settings.performance.check-spooky-season-once-an-hour", checkSpookySeasonOnceAnHour);
+ }
+
public static final class WorldConfig {
public final String worldName;