mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-12-02 23:53:50 +01:00
daedcdd003
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: b94a99b03 Updated Upstream (CraftBukkit) (#5762) f5cb169e0 [Auto] Updated Upstream (CraftBukkit) 407ad043c Add ElderGuardianAppearanceEvent (#5394) a04ad7bfb Fix invulnerable end crystals: MC-108513 (#5734) c894e8bbb Fix issue with soft despawn distance (#5755) 302e5101a Add BellRevealRaiderEvent (#5729) 34e6b2dc3 editMeta: tighten contract via docs (#5714) db2d501ba Do not print spawn loaded chunks 86ffde038 Add getHandRaised to LivingEntity (#5752) 9072c349a Fix broadcast event and add Adventure broadcast (#5477) Tuinity Changes: f7c4249 Fix dangerous end portal logic 3eda860 Updated Upstream (Paper) Airplane Changes: 3e07ea8 Patch container checks for WildChests compat d04adc9 Updated Upstream (Tuinity) 489bb76 Update gradle 0d5670e Merge pull request #24 from HexedHero/spelling-mistake-lightning c605be6 Fix typo Purpur Changes: d2204a3d Updated Upstream (Paper, Tuinity & Airplane) 2b35782c Fix #364 - isCritical always false 6ab78311 Fix empty shulker boxes disappearing when broken afaf8b4f Updated Upstream (Paper) b97feb78 [ci-skip] readme eb77666a Updated Upstream (Paper) Empirecraft Changes: 105217a9 Move more files out of nms package 548a13f4 Move some server patches out nms package f24d7b4c Updated Paper 99745711 Updated Paper deb9886e Add a fix for piglins picking up too much - SPIGOT-6482 8c662d78 Add javadoc description to reload api 1af9bbc8 Adjust comments on vehicle event patch 2aa479b8 cleanup ItemStack isSimilar api patches f344cb62 Updated Paper dbb49189 Re-add EMC User API a6c40eb2 Updated Paper a57940b2 Remove EMC specific User API patches Origami Changes: d0cdf96 Fix issues with disabling the chunk loading of the feature search 529f5b6 Fix creature type despawn distances not applying 1af8601 Fix Endermen being able to load chunks on teleport
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 8697608a076eab1c0e92587110c8465d636e6be9..d74caaaa1064e86ebc69a64ac8fb77414fdf30d3 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1478,6 +1478,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 5c9e4724d46b6864cdb85f7d3c8fb0fe37032444..b8ff1af80e87d0715d71d62256f78f1646d82e01 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 1676fbb80e5573c2591c1de7a6a858cf4824b48f..9b4ec2ae5df12fc605770ad6243970a7753dd8dc 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java
|
|
@@ -163,11 +163,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 bce7b674ef4450c1f6e932cba1b06ae8730cedfe..446d967f87ce252f62e568c18af54c50d63cb586 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
|
|
@@ -590,11 +590,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;
|
|
+ }
|
|
+
|
|
+}
|