mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-12-01 23:23:27 +01:00
e01705826c
* Updated Upstream and Sidestream(s) (Paper/Purpur/Empirecraft) 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: 2a67a9e51 Fix missing CraftMetaBook#toBuilder override 48aa06106 Add more Wandering Trader API (#5020) 8cec462a5 [CI-SKIP] Remove Astei from the MIT list (#5577) 21fbc3196 [CI-SKIP] Add Other textarea to issue templates (#5562) 453e983e4 fix isProxyOnlineMode coverage, don't lookup UUIDs in offline mode (Fixes #2011) 81cc4f928 Send empty commands if tab completion is disabled (Closes #5519) 9ed3e470d Keep moveToWorld with old method signature 99a66a583 [Auto] Updated Upstream (CraftBukkit) 976c6d425 [CI-SKIP] [Auto] Rebuild Patches 51deec726 Drop unneeded portal patch (#5566) 07a18c457 [Auto] Updated Upstream (CraftBukkit) 6733d7875 [Auto] Updated Upstream (Bukkit) 9958447cb [Auto] Updated Upstream (Bukkit) 840e72091 [CI-SKIP] [Auto] Rebuild Patches a33232d4a Add beacon activation and deactivation events (#5121) Purpur Changes: ebc0765 Updated Upstream (Paper) 5bc5dfd Fix #318 - Stonecutter does not damage when sneaking 8366582 Resolve #286 - Add config and API for item immunity to lightning a86555b Updated Upstream (Paper) 8b2607c Config for only sending advancements to affected players (#312) 7ee3393 Add config for the piston push limit (#311) a30e5ac Add config for void damage dealt 786382b Updated Upstream (Paper) 60d8411 [ci-skip] fix patch name b64f536 Config for changing the blocks that turn into paths (#303) 1d3f710 Updated Upstream (Paper) 3af86ad Oopsie 4b0342a Gamemode extra permissions 17c8573 [CI-SKIP] Don't pass ping to demo command output c3481c0 Initialize the credits command output in config a176fe6 Add credits command Empirecraft Changes: b2879a24 Updated Paper * Updated Upstream and Sidestream(s) (Paper/Tuinity/Airplane/Purpur/Empirecraft) 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: b3cc88799 Add the ability to clear entities from block storage (#5598) f50171f3b Add missing rarity method on ItemStack (#5594) aeb6e7dd2 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5601) b0a4f353b fix cancelling block falling causing client desync (fixes #5386) (#5419) 8ed45920c Don't annotate type parameters using JetBrains annotations (#5600) d7625d926 Add new methods from PlayerMoveEvent to EntityMoveEvent (#5591) 29785297b Allow for Component suggestion tooltips in AsyncTabCompleteEvent (#5504) 0aea6c2ff Use JsonSerializationContext#serialize instead of recursion for AdventureComponents - fixes #5580 and #5371 8fcef3c1f Return after sending empty commands (#5586) Tuinity Changes: 3350246 Updated Upstream (Paper) f773caf Fix rare ticket level recursion crash 0fa8a0e Starlight Handle concurrent chunk generation and lighting better Airplane Changes: fad74c2 Fix JB annotations for gradle (credit jpenilla) d02f034 Updated Upstream (Tuinity) Purpur Changes: adfe5d3 Updated Upstream (Paper) 7a728f8 Fix #325 - Fix SPIGOT-6278 f5c3dae Updated Upstream (Paper) a80e5b6 Dont create item meta when checking if meta properties exist 90339c5 Add missing netherite from Material#isArmor bedac18 Updated Upstream (Paper, Tuinity, & Airplane) 3b1531a [ci-skip] Add wrapper validation step to actions 73ab4e6 Update the "changing the blocks that turn into paths" defaults to reflect the vanilla defaults. (#322) a24b31b Updated Upstream (Paper) Empirecraft Changes: 87ceb204 Updated Paper a3497a7e Fix some patches 2ed9e7fa Updated Paper d5a47a3d Updated Paper * Updated Upstream and Sidestream(s) (Tuinity) 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. Tuinity Changes: 1382473 Null check chunk in block changes for Starlight
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;
|
|
+ }
|
|
+
|
|
+}
|