mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-13 22:25:45 +01:00
61f261ee2a
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: b8020379c Extract Adventure Version into a variable, add reminder to update the linked JD on the homepage (#5422) 809466f2e Fix anchor respawn acting as a bed respawn when using the end portal (#5540) d219fd642 [Auto] Updated Upstream (Bukkit/CraftBukkit) db464b099 Implement methods to convert between Component and Brigadier's Message (#5542) 4047cffca Add PlayerBedFailEnterEvent (#4935) 70d697e6e Update Paperpclip 5ed771591 [CI-SKIP] Remove bad null annotation (#5538) 454a4c78e More World API (#3850) 869e02304 Add PlayerDeepSleepEvent (#5525) fb56fc35e fix non-dummy objectives not updating dc859a61f [CI-SKIP] [Auto] Rebuild Patches 7d1689f1a Add missing checkReachable check for shulker boxes (#5453) ba8eb3d4b Add missing Javadoc for COLORABLE MaterialTag (#5376) db801cbf3 Fix PlayerItemHeldEvent firing twice (#5534) 14de2b795 fix PigZombieAngerEvent cancellation (fixes #5319) (v2) (#5329) 86d684ad1 Add get-set drop chance to EntityEquipment (#5528) 33fb8cf63 Add consumeFuel to FurnaceBurnEvent (#5532) 9957f4630 Fix duplicating /give items on item drop cancel (#5536) d94882043 Fix legacyComposer not using AsyncChatEvent messages (#5509) 053bd82cc Don't print spawn load time when not loading spawn (#5467) a6d78caae Add isDeeplySleeping to HumanEntity (#5470) 711b7a80b Expose more Adventure serializers through PaperComponents (#5443) 3f63bde0c Set Area Effect Cloud Rotation (#5462) 3523f0fda Remove useless check on player interact cancellation (#5448) 6574d1aa8 fix #5526 - use correct type when sending message to clients dbfa833ec don't throw when loading TE with invalid keys a9525a6f7 Do not schedule poi task for each block write on chunk gen Airplane Changes: f5fb024 Temporarily revert patch 3c728a7 Oops, these 2 too 37a93e5 Your daily dose of 1-3% optimization patches bbd689a Remove useless check d8bdbc5 Reduce allocations for fire spreading 41051fd Redo reduction of entity chunk ticking check patch 31272d8 Flare Update 8f32713 Remove criterion patch 0fed2df Various patches that need to be reorganized later f78856b Updated Upstream (Tuinity) f7d6382 Flare Update 71d0799 Update gradle configuration 0f79774 Updated Upstream (Tuinity) Purpur Changes: 3dce975 Updated Upstream (Paper & Airplane) (#298) eb07368 Run GitHub Actions for pull requests e97d062 Updated Upstream (Paper, Tuinity, & Airplane) Empirecraft Changes: 2a021ede Updated Paper e963bb2c Add Paper MojangAPI to pom 6f5bf24e Updated Paper Origami Changes: 73ecdf1 Update Paper 73a3735 Item and exp merge improvements
145 lines
6.7 KiB
Diff
145 lines
6.7 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/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index a0298d1a6d08b915ea5a9d85f3e33f33d6e682fd..43de296558a54657efa6b34e34bdaaeccaef8ed1 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1474,6 +1474,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/net/minecraft/world/entity/ambient/EntityBat.java b/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java
|
|
index e6c5d21da445c9b66dcca33d9029d1768bbe046a..56dbac9b4d97bf012a99e138add98fcc8ae453e4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java
|
|
@@ -307,11 +307,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/world/entity/monster/EntitySkeletonAbstract.java b/src/main/java/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java
|
|
index 7ec60987229927e5fe7164f1d4eae8222832e920..faae6cdd816c86b3c7b86104a2017974c05e3452 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java
|
|
@@ -154,11 +154,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/world/entity/monster/EntityZombie.java b/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
|
|
index 7112db516e62ca75a445482005c524129b84f54c..5060c8c32ceb13475c60f831e0f4fd132cf952b3 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
|
|
@@ -585,11 +585,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/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;
|
|
+ }
|
|
+
|
|
+}
|