9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2026-01-06 15:51:33 +00:00
Files
LeavesMC/patches/server/0022-Only-check-for-spooky-season-once-an-hour.patch
violetc 4a69af351b 1.21 (#238)
---------

Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
Co-authored-by: LittleChest <81231195+LittleChest@users.noreply.github.com>
2024-07-05 01:30:46 +08:00

47 lines
2.2 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 dc27ddf5131e7398a5390a5187261d4c7fb6ccaa..601072324b54d062bd4cceb821ae187d904ad49b 100644
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
@@ -239,13 +239,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 (org.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
private void setupAnimationStates() {
if (this.isResting()) {