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 eb9fb57440f498079182030a46034008d3f6b5e8..5f0ddf96e8ca1bb32c773f11232dedd1a981fde9 100644 --- a/net/minecraft/world/entity/ambient/Bat.java +++ b/net/minecraft/world/entity/ambient/Bat.java @@ -244,12 +244,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()) {