mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-12-01 15:13:24 +01:00
d059af01b6
* Updated Upstream and Sidestream(s) (Paper/Purpur/AirplaneLite) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: fc4c0bc42 Reset shield blocking on dimension change 1c8b6065e Skip distance map update when spawning is disabled 091e6700f Added PlayerStonecutterRecipeSelectEvent fc885f966 Add toggle for always placing the dragon egg b3a6da3a7 Updated Upstream (Bukkit/CraftBukkit) 18ccc062d [Auto] Updated Upstream (Spigot) Purpur Changes: df9bd08 Config to use infinity bows without arrows (#149) 9d537bc Fix PlayerEditBookEvent not saving new book 3f8816d [ci-skip] Oops 5508728 [ci-skip] Add granny to funding 4c7ab70 Updated Upstream (Paper) 5eefb52 [ci-skip] Update Gradle to 6.8.1 AirplaneLite Changes: 459bb20 Remove patch 515fec7 Remove streams fc94d7b Correct launcher name 0b153bd Update gradle version * add Remove-streams.patch from AirplaneLite
145 lines
6.5 KiB
Diff
145 lines
6.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Ivan Pekov <ivan@mrivanplays.com>
|
|
Date: Mon, 4 Jan 2021 20:12:36 +0200
|
|
Subject: [PATCH] Optimised hallowen checker
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityBat.java b/src/main/java/net/minecraft/server/EntityBat.java
|
|
index 7718ec8ad3c1833e0bcc713c2e96e054e87453ad..778cd2d0e091b455fddf05d9c07605a6c305de94 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityBat.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityBat.java
|
|
@@ -280,11 +280,16 @@ public class EntityBat extends EntityAmbient {
|
|
}
|
|
|
|
private static boolean eJ() {
|
|
+ // Yatopia start - optimised halloween checker
|
|
+ /*
|
|
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 org.yatopiamc.yatopia.server.entity.HalloweenChecker.isHalloweenSeason();
|
|
+ // Yatopia end
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java b/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
|
|
index ee4c26de15a5c304889f38f49f4584e8d4ccc5fe..ca9075d6bae36c29d9eb4727321afcbced5f3db4 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
|
|
@@ -111,11 +111,15 @@ public abstract class EntitySkeletonAbstract extends EntityMonster implements IR
|
|
this.eL();
|
|
this.setCanPickupLoot(this.world.paperConfig.skeletonsAlwaysCanPickUpLoot || this.random.nextFloat() < 0.55F * difficultydamagescaler.d()); // Paper
|
|
if (this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
|
|
+ /* // Yatopia start - optimised halloween checker
|
|
LocalDate localdate = LocalDate.now();
|
|
int i = localdate.get(ChronoField.DAY_OF_MONTH);
|
|
int j = localdate.get(ChronoField.MONTH_OF_YEAR);
|
|
|
|
if (j == 10 && i == 31 && this.random.nextFloat() < 0.25F) {
|
|
+ */
|
|
+ if (org.yatopiamc.yatopia.server.entity.HalloweenChecker.isHalloweenDay() && this.random.nextFloat() < 0.25F) {
|
|
+ // Yatopia end
|
|
this.setSlot(EnumItemSlot.HEAD, new ItemStack(this.random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN));
|
|
this.dropChanceArmor[EnumItemSlot.HEAD.b()] = 0.0F;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
|
|
index a5699314be3f47ed9b27a5d21a396c5282592c7b..16d73dc50b76523dd03e12d566646874e86fabca 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityZombie.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
|
|
@@ -520,11 +520,15 @@ public class EntityZombie extends EntityMonster {
|
|
}
|
|
|
|
if (this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
|
|
+ /* // Yatopia start - optimised halloween checker
|
|
LocalDate localdate = LocalDate.now();
|
|
int i = localdate.get(ChronoField.DAY_OF_MONTH);
|
|
int j = localdate.get(ChronoField.MONTH_OF_YEAR);
|
|
|
|
if (j == 10 && i == 31 && this.random.nextFloat() < 0.25F) {
|
|
+ */
|
|
+ if (org.yatopiamc.yatopia.server.entity.HalloweenChecker.isHalloweenDay() && this.random.nextFloat() < 0.25F) {
|
|
+ // Yatopia end
|
|
this.setSlot(EnumItemSlot.HEAD, new ItemStack(this.random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN));
|
|
this.dropChanceArmor[EnumItemSlot.HEAD.b()] = 0.0F;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 954462353d35c06b0568c56669e31d0ad15bcf67..87cf9cd88d1fb5ae70d19e5618ebfb67d281304a 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1345,6 +1345,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
// Paper end
|
|
|
|
com.tuinity.tuinity.util.CachedLists.reset(); // Tuinity
|
|
+ org.yatopiamc.yatopia.server.entity.HalloweenChecker.tick(); // Yatopia
|
|
|
|
// Paper start
|
|
long endTime = System.nanoTime();
|
|
diff --git a/src/main/java/org/yatopiamc/yatopia/server/entity/HalloweenChecker.java b/src/main/java/org/yatopiamc/yatopia/server/entity/HalloweenChecker.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..b9e8c25fa4c4cc088a12c2b865887751c8cdbcd8
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/yatopiamc/yatopia/server/entity/HalloweenChecker.java
|
|
@@ -0,0 +1,59 @@
|
|
+package org.yatopiamc.yatopia.server.entity;
|
|
+
|
|
+import java.time.LocalDate;
|
|
+import java.time.temporal.ChronoField;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+
|
|
+/**
|
|
+ * Entity halloween checker
|
|
+ * <p>
|
|
+ * Checks whether or not it is halloween at a specific rate rather than every time when
|
|
+ * a entity is being spawned.
|
|
+ * <p>
|
|
+ * The rate changes depending on how much TPS the server has. By default, the rate is every
|
|
+ * 2 hours, or every 144k ticks (if the server has _that_ much uptime)
|
|
+ *
|
|
+ * @author MrIvanPlays
|
|
+ */
|
|
+public class HalloweenChecker {
|
|
+
|
|
+ private static boolean halloweenSeason = false;
|
|
+ private static boolean halloweenDay = false;
|
|
+
|
|
+ private static int delay = (20 * 60 * 60) * 2;
|
|
+ private static int lastCheckTick = -delay;
|
|
+
|
|
+ public static void tick() {
|
|
+ if (MinecraftServer.currentTick % 100 == 0) {
|
|
+ // update the delay every 100 ticks
|
|
+ if (MinecraftServer.TPS >= 20) {
|
|
+ delay = (20 * 60 * 60) * 2;
|
|
+ }
|
|
+ if (MinecraftServer.TPS < 15) {
|
|
+ delay = delay + (20 * 60 * 15);
|
|
+ }
|
|
+ if (MinecraftServer.TPS < 10) {
|
|
+ delay = delay + (20 * 60 * 30);
|
|
+ }
|
|
+ }
|
|
+ if (MinecraftServer.currentTick - lastCheckTick > delay) {
|
|
+ LocalDate now = LocalDate.now();
|
|
+ int day = now.getDayOfMonth();
|
|
+ int month = now.get(ChronoField.MONTH_OF_YEAR);
|
|
+
|
|
+ halloweenDay = (month == 10) && (day == 31);
|
|
+ halloweenSeason = ((month == 10) && (day >= 20)) || ((month == 11) && (day <= 3));
|
|
+
|
|
+ lastCheckTick = MinecraftServer.currentTick;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public static boolean isHalloweenSeason() {
|
|
+ return halloweenSeason;
|
|
+ }
|
|
+
|
|
+ public static boolean isHalloweenDay() {
|
|
+ return halloweenDay;
|
|
+ }
|
|
+
|
|
+}
|