mirror of
https://github.com/LeavesMC/Leaves.git
synced 2026-01-04 15:41:31 +00:00
--------- Co-authored-by: MC_XiaoHei <xiaohei.xor7studio@foxmail.com> Co-authored-by: Bluemangoo <chenfy2006@qq.com>
53 lines
2.4 KiB
Diff
53 lines
2.4 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..8237f252cf60cb0ed85f6eb61e2bdb5f8e3cefef 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
|
@@ -215,6 +215,7 @@ public class Bat extends AmbientCreature {
|
|
super.readAdditionalSaveData(nbt);
|
|
this.entityData.set(Bat.DATA_ID_FLAGS, nbt.getByte("BatFlags"));
|
|
}
|
|
+ // Leaves end - only check for spooky season once an hour
|
|
|
|
@Override
|
|
public void addAdditionalSaveData(CompoundTag nbt) {
|
|
@@ -239,12 +240,28 @@ 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;
|
|
+ }
|
|
}
|
|
|
|
private void setupAnimationStates() {
|