9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/leaves-server/minecraft-patches/features/0018-Only-check-for-spooky-season-once-an-hour.patch
MC_XiaoHei 90080d238e 1.21.10 (#752)
---------

Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com>
Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
2025-11-28 03:15:54 +08:00

47 lines
2.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/net/minecraft/world/entity/ambient/Bat.java b/net/minecraft/world/entity/ambient/Bat.java
index c0198c0b6d00667c9591a5cd254b0bfedc3fb627..ec713dd16a842119c02b760ed45f7de2a839cb3b 100644
--- a/net/minecraft/world/entity/ambient/Bat.java
+++ b/net/minecraft/world/entity/ambient/Bat.java
@@ -246,12 +246,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 i1 = localDate.get(ChronoField.MONTH_OF_YEAR);
- return i1 == 10 && i >= 20 || i1 == 11 && i <= 3;
+ if (org.leavesmc.leaves.LeavesConfig.performance.checkSpookySeasonOnceAnHour) {
+ if (net.minecraft.server.MinecraftServer.currentTick - lastSpookyCheck > ONE_HOUR) {
+ LocalDate localdate = LocalDate.now();
+ int i = localdate.getDayOfMonth();
+ int j = localdate.getMonth().getValue();
+
+ 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 i1 = localDate.get(ChronoField.MONTH_OF_YEAR);
+ return i1 == 10 && i >= 20 || i1 == 11 && i <= 3;
+ }
}
+ // Leaves end - only check for spooky season once an hour
private void setupAnimationStates() {
if (this.isResting()) {