9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-23 00:39:22 +00:00
Files
Gale/patches/server/0012-Reduce-spooky-season-checks.patch
2022-11-29 15:20:19 +01:00

100 lines
4.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MartijnMuijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 16:29:01 +0100
Subject: [PATCH] Reduce spooky season checks
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
This patch is based on the following patch:
"Only check for spooky season once an hour"
By: Paul Sauve <paul@technove.co>
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
* Airplane copyright *
Airplane
Copyright (C) 2020 Technove LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 def01d221f36d71640bf4ef982a984909aacc6da..2180277e77311a0bf087186d3fca8f67052af121 100644
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
@@ -28,6 +28,7 @@ import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
public class Bat extends AmbientCreature {
@@ -253,12 +254,25 @@ public class Bat extends AmbientCreature {
}
}
+ // Gale start - Airplane - reduced spooky season checks
+ private static boolean isSpookySeason = false;
+ private static int lastSpookyCheck = -((1 << 30) - 1);
+ // Gale end - Airplane - reduced spooky season checks
private static boolean isHalloween() {
+ // Gale start - Airplane - reduced spooky season checks
+ int checkSpookySeasonInterval = GaleGlobalConfiguration.get().smallOptimizations.reducedIntervals.checkSpookySeason;
+ if (checkSpookySeasonInterval <= 1 || net.minecraft.server.MinecraftServer.currentTick - lastSpookyCheck > checkSpookySeasonInterval) {
+ // Gale end - Airplane - reduced spooky season checks
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;
+ // Gale start - Airplane - reduced spooky season checks
+ isSpookySeason = j == 10 && i >= 20 || j == 11 && i <= 3;
+ lastSpookyCheck = net.minecraft.server.MinecraftServer.currentTick;
+ }
+ return isSpookySeason;
+ // Gale end - Airplane - reduced spooky season checks
}
@Override
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
index 8f8fd98f96cd390ba43033521982a13044df91cf..af4883f8939d017866a9b057491a8400b11fe009 100644
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
@@ -23,7 +23,23 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
public SmallOptimizations smallOptimizations;
public class SmallOptimizations extends ConfigurationPart {
- public int dummyValue = 0;
+ public ReducedIntervals reducedIntervals;
+ public class ReducedIntervals extends ConfigurationPart {
+
+ // Gale start - Airplane - reduced spooky season checks
+ /**
+ * The interval at which to check for the spooky season for bats.
+ * Given in ticks.
+ * Any value <= 0 behaves like 1.
+ * <ul>
+ * <li><i>Default</i>: 72000 (1 hour)</li>
+ * <li><i>Vanilla</i>: 1</li>
+ * </ul>
+ */
+ public int checkSpookySeason = 20 * 60 * 60;
+ // Gale end - Airplane - reduced spooky season checks
+
+ }
}