mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-06 15:51:31 +00:00
Fix predict Halloween date check
This commit is contained in:
@@ -629,7 +629,7 @@ index a78213464c5c365c6395fdf1295cb406c618d33b..fcc19c00b913d0a864f54f3833dac47f
|
||||
|
||||
static class TraceCustomExecutor
|
||||
diff --git a/net/minecraft/server/commands/PerfCommand.java b/net/minecraft/server/commands/PerfCommand.java
|
||||
index b10cb4a73df58a5fe64e88868733ba41616f59e4..1987afa2b3c0b9bdf5022629455bc2129831ba16 100644
|
||||
index b10cb4a73df58a5fe64e88868733ba41616f59e4..ffbbd3c766046405b279692e5db83ce502c3d779 100644
|
||||
--- a/net/minecraft/server/commands/PerfCommand.java
|
||||
+++ b/net/minecraft/server/commands/PerfCommand.java
|
||||
@@ -42,6 +42,9 @@ public class PerfCommand {
|
||||
@@ -669,7 +669,7 @@ index b10cb4a73df58a5fe64e88868733ba41616f59e4..1987afa2b3c0b9bdf5022629455bc212
|
||||
+ private static int removedMessage(CommandSourceStack source) {
|
||||
+ net.kyori.adventure.text.minimessage.MiniMessage mm = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage();
|
||||
+
|
||||
+ source.getSender().sendMessage(mm.deserialize("<gold>Gale has removed Mojang's Profiler to save your performance. Please use <click:suggest_command:'/spark'><grey>/spark</grey></click> instead"));
|
||||
+ source.getSender().sendMessage(mm.deserialize("<gold>Leaf has removed Mojang's Profiler to save your performance. Please use <click:suggest_command:'/spark'><grey>/spark</grey></click> instead"));
|
||||
+ source.getSender().sendMessage(mm.deserialize("<gold>For more information, view its documentation at"));
|
||||
+ source.getSender().sendMessage(mm.deserialize("<gold><click:open_url:'https://spark.lucko.me/docs/Command-Usage'>https://spark.lucko.me/docs/Command-Usage</click>"));
|
||||
+
|
||||
@@ -1613,7 +1613,7 @@ index 859b859d29b637200cf7c9a0bd52d9f712413e3d..653c58c7637c46c8b46a5082f671324a
|
||||
|
||||
public Set<WrappedGoal> getAvailableGoals() {
|
||||
diff --git a/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
index 3b29cc4e11efe6f27023f52cfde16fd118c310ad..c8e4ccb96a0f162c780066cf4f61b970b49b7703 100644
|
||||
index dd1a95111d965bcd7f53be9d4224dd213e4e0705..24dd92449f70144c79f25bf24942ebd666655ed2 100644
|
||||
--- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
+++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
@@ -10,8 +10,6 @@ import net.minecraft.core.Vec3i;
|
||||
|
||||
@@ -6,6 +6,8 @@ Subject: [PATCH] Faster floating-point positive modulo
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
The JMH benchmark of this patch can be found in SunBox's `FasterFloatingPointPositiveModulo`
|
||||
|
||||
diff --git a/net/minecraft/util/Mth.java b/net/minecraft/util/Mth.java
|
||||
index 75da3011058918e1da6936522f19a2ccdb843d73..1b60fa34e4d6a5c00a983bf94e4d16d1eb46c665 100644
|
||||
--- a/net/minecraft/util/Mth.java
|
||||
|
||||
@@ -6,11 +6,16 @@ Subject: [PATCH] Predict Halloween
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
The Halloween begins at 10/20 0:00 a.m., and end with 11/04 0:00 a.m.
|
||||
Cache the date result to prevent calculate in every call
|
||||
|
||||
The JMH benchmark of this patch can be found in SunBox's `PredictHalloween`
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ambient/Bat.java b/net/minecraft/world/entity/ambient/Bat.java
|
||||
index 912b099a51269f92f250c7d6094ad41817749f93..5dadb42fd2d2d03ef366ca83c9c4aae6c288aaa4 100644
|
||||
index 912b099a51269f92f250c7d6094ad41817749f93..a6487b63a277f7ca9681924850718f1dced746b1 100644
|
||||
--- a/net/minecraft/world/entity/ambient/Bat.java
|
||||
+++ b/net/minecraft/world/entity/ambient/Bat.java
|
||||
@@ -245,11 +245,66 @@ public class Bat extends AmbientCreature {
|
||||
@@ -245,11 +245,62 @@ public class Bat extends AmbientCreature {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +52,6 @@ index 912b099a51269f92f250c7d6094ad41817749f93..5dadb42fd2d2d03ef366ca83c9c4aae6
|
||||
+ */
|
||||
+ private static long nextHalloweenEnd = 0;
|
||||
+
|
||||
+ // The Halloween begins at 10/20 0:00, and end with 11/04 0:00
|
||||
+ // Only when the current Halloween period ends, the `nextHalloweenStart`
|
||||
+ // and `nextHalloweenEnd` will adjust to the epoch ms of date of next year
|
||||
+ // These two fields will not change during current Halloween period.
|
||||
private static boolean isHalloween() {
|
||||
- LocalDate localDate = LocalDate.now();
|
||||
- int i = localDate.get(ChronoField.DAY_OF_MONTH);
|
||||
@@ -58,25 +59,25 @@ index 912b099a51269f92f250c7d6094ad41817749f93..5dadb42fd2d2d03ef366ca83c9c4aae6
|
||||
- return i1 == 10 && i >= 20 || i1 == 11 && i <= 3;
|
||||
+ long currentEpochMillis = System.currentTimeMillis();
|
||||
+
|
||||
+ if (currentEpochMillis > nextHalloweenEnd) {
|
||||
+ // Update prediction
|
||||
+
|
||||
+ java.time.OffsetDateTime currentDate = java.time.OffsetDateTime.now();
|
||||
+ int currentMonthOfYear = currentDate.getMonth().getValue();
|
||||
+ int currentDayOfMonth = currentDate.getDayOfMonth();
|
||||
+
|
||||
+ java.time.OffsetDateTime nextHalloweenStartDate = currentDate.withMonth(halloweenStartMonthOfYear).withDayOfMonth(halloweenStartDayOfMonth)
|
||||
+ // Update predicate
|
||||
+ if (nextHalloweenEnd == 0 || currentEpochMillis >= nextHalloweenEnd) {
|
||||
+ java.time.OffsetDateTime currentDate = java.time.OffsetDateTime.ofInstant(java.time.Instant.ofEpochMilli(currentEpochMillis), java.time.ZoneId.systemDefault())
|
||||
+ .withHour(0).withMinute(0).withSecond(0).withNano(0); // Adjust to directly start or end at zero o'clock
|
||||
+
|
||||
+ if (currentMonthOfYear >= halloweenEndMonthOfYear && currentDayOfMonth >= halloweenEndDayOfMonth) {
|
||||
+ nextHalloweenStartDate = nextHalloweenStartDate.plusYears(1);
|
||||
+ java.time.OffsetDateTime thisHalloweenStart = currentDate.withMonth(halloweenStartMonthOfYear).withDayOfMonth(halloweenStartDayOfMonth);
|
||||
+ java.time.OffsetDateTime thisHalloweenEnd = currentDate.withMonth(halloweenEndMonthOfYear).withDayOfMonth(halloweenEndDayOfMonth);
|
||||
+
|
||||
+ // Move to next year date if current passed
|
||||
+ if (currentDate.isAfter(thisHalloweenEnd)) {
|
||||
+ thisHalloweenStart = thisHalloweenStart.plusYears(1);
|
||||
+ thisHalloweenEnd = thisHalloweenEnd.plusYears(1);
|
||||
+ }
|
||||
+
|
||||
+ nextHalloweenStart = nextHalloweenStartDate.toInstant().toEpochMilli();
|
||||
+ nextHalloweenEnd = nextHalloweenStartDate.withMonth(halloweenEndMonthOfYear).withDayOfMonth(halloweenEndDayOfMonth).toInstant().toEpochMilli();
|
||||
+ nextHalloweenStart = thisHalloweenStart.toInstant().toEpochMilli();
|
||||
+ nextHalloweenEnd = thisHalloweenEnd.toInstant().toEpochMilli();
|
||||
+ }
|
||||
+
|
||||
+ return currentEpochMillis >= nextHalloweenStart;
|
||||
+ return currentEpochMillis >= nextHalloweenStart && currentEpochMillis < nextHalloweenEnd;
|
||||
+ // Gale end - predict Halloween
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ Patches listed below are removed in this patch, They exists in Gale or Leaf:
|
||||
- Rebrand
|
||||
|
||||
diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java
|
||||
index 3c3fe6d2e46a811932143a782bb50f9a7c87c4d2..b866bef893dfb4e65a6c4c48125e6d8a1c3ede64 100644
|
||||
index c9de5fbb56b7b455b4c8bc59539695fd58a32566..ea01daf583ddd110f153304a6a65ac2d765b9d31 100644
|
||||
--- a/io/papermc/paper/entity/activation/ActivationRange.java
|
||||
+++ b/io/papermc/paper/entity/activation/ActivationRange.java
|
||||
@@ -161,6 +161,8 @@ public final class ActivationRange {
|
||||
@@ -3324,7 +3324,7 @@ index 17a08a3af468093668a41f154c2beb69c6617efa..398a97a72dca785204f6b7b8fc4abe5c
|
||||
if (entity == null) {
|
||||
if (this.isCombat && (!target.canBeSeenAsEnemy() || level.getDifficulty() == Difficulty.PEACEFUL)) {
|
||||
diff --git a/net/minecraft/world/entity/ambient/Bat.java b/net/minecraft/world/entity/ambient/Bat.java
|
||||
index 5dadb42fd2d2d03ef366ca83c9c4aae6c288aaa4..6aae3634d69edcda7aff326dcea6f87668db4835 100644
|
||||
index a6487b63a277f7ca9681924850718f1dced746b1..59a849f5471a94bfbf364fe169d1a27a402629bd 100644
|
||||
--- a/net/minecraft/world/entity/ambient/Bat.java
|
||||
+++ b/net/minecraft/world/entity/ambient/Bat.java
|
||||
@@ -44,11 +44,87 @@ public class Bat extends AmbientCreature {
|
||||
@@ -3453,9 +3453,9 @@ index 5dadb42fd2d2d03ef366ca83c9c4aae6c288aaa4..6aae3634d69edcda7aff326dcea6f876
|
||||
private static long nextHalloweenEnd = 0;
|
||||
|
||||
+ public static boolean isHalloweenSeason(Level level) { return level.purpurConfig.forceHalloweenSeason || isHalloween(); } // Purpur - Halloween options and optimizations
|
||||
// The Halloween begins at 10/20 0:00, and end with 11/04 0:00
|
||||
// Only when the current Halloween period ends, the `nextHalloweenStart`
|
||||
// and `nextHalloweenEnd` will adjust to the epoch ms of date of next year
|
||||
private static boolean isHalloween() {
|
||||
long currentEpochMillis = System.currentTimeMillis();
|
||||
|
||||
diff --git a/net/minecraft/world/entity/animal/AbstractCow.java b/net/minecraft/world/entity/animal/AbstractCow.java
|
||||
index dd8ea03ba823996a5c97562e357650ab34d0e32e..61e7300bbf272398b2faebf5e537d9c2ddedc6d6 100644
|
||||
--- a/net/minecraft/world/entity/animal/AbstractCow.java
|
||||
|
||||
Reference in New Issue
Block a user