diff --git a/PATCHES.md b/PATCHES.md index 303f3e4c..39b8a3b8 100644 --- a/PATCHES.md +++ b/PATCHES.md @@ -93,6 +93,7 @@ # Patches | server | Nuke streams off BlockPosition | Ivan Pekov | | | server | Nuke streams off SectionPosition | Ivan Pekov | | | server | Optimise portals | Ivan Pekov | | +| server | Optimised hallowen checker | Ivan Pekov | | | server | Optimize BehaviorController | MrIvanPlays | | | server | Optimize TileEntity load/unload | tr7zw | | | server | Optimize Villagers | Ivan Pekov | | @@ -123,6 +124,7 @@ # Patches | server | Simpler ShapelessRecipes comparison for Vanilla | Paul Sauve | | | server | Skip events if there's no listeners | William Blake Galbreath | | | server | Smarter statistics ticking | Mykyta Komarnytskyy | | +| server | Smol entity optimisations | Ivan Pekov | | | server | Snowman drop and put back pumpkin | William Blake Galbreath | | | server | Spread out and optimise player list ticks | James Lyne | | | server | Squid EAR immunity | William Blake Galbreath | | diff --git a/patches/server/0066-Optimised-hallowen-checker.patch b/patches/server/0066-Optimised-hallowen-checker.patch new file mode 100644 index 00000000..dea2715a --- /dev/null +++ b/patches/server/0066-Optimised-hallowen-checker.patch @@ -0,0 +1,144 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ivan Pekov +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 0a59e02d762a096cb3de62e0f8105cc5a5fab8d4..bdcbdc21f986852277dcc41a2b0f385f8caeb9f7 100644 +--- a/src/main/java/net/minecraft/server/EntityBat.java ++++ b/src/main/java/net/minecraft/server/EntityBat.java +@@ -222,11 +222,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 f73304240a626f3f7d9355e6e5f2963a06c4bb7d..3ca3280d4a4d3cd8e0b4aff8431d8fe5904d23a4 100644 +--- a/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java ++++ b/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java +@@ -109,11 +109,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 62d202ff871cf3f3deea69931fbee84131bdda8b..0475feb6e50c6d4a1f2813b028bbaef4ed710a7d 100644 +--- a/src/main/java/net/minecraft/server/EntityZombie.java ++++ b/src/main/java/net/minecraft/server/EntityZombie.java +@@ -471,11 +471,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 0d23591fffcda1f8121e7bc7a6aa00d088b6e80b..7b326635aac5b1e7fb6e3933d133d7e181b7541c 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -1335,6 +1335,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant ++ * Checks whether or not it is halloween at a specific rate rather than every time when ++ * a entity is being spawned. ++ *

++ * 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 * 20) * 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; ++ } ++ ++} diff --git a/patches/server/0067-Smol-entity-optimisations.patch b/patches/server/0067-Smol-entity-optimisations.patch new file mode 100644 index 00000000..7bc586f5 --- /dev/null +++ b/patches/server/0067-Smol-entity-optimisations.patch @@ -0,0 +1,48 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ivan Pekov +Date: Mon, 4 Jan 2021 20:32:06 +0200 +Subject: [PATCH] Smol entity optimisations + + +diff --git a/src/main/java/net/minecraft/server/EntityBat.java b/src/main/java/net/minecraft/server/EntityBat.java +index bdcbdc21f986852277dcc41a2b0f385f8caeb9f7..dff2dc82c2a6b26c6e41b3949953abcaf379b20a 100644 +--- a/src/main/java/net/minecraft/server/EntityBat.java ++++ b/src/main/java/net/minecraft/server/EntityBat.java +@@ -208,7 +208,7 @@ public class EntityBat extends EntityAmbient { + if (blockposition.getY() >= generatoraccess.getSeaLevel()) { + return false; + } else { +- int i = generatoraccess.getLightLevel(blockposition); ++ //int i = generatoraccess.getLightLevel(blockposition); // Yatopia - moved down + byte b0 = 4; + + if (eJ()) { +@@ -217,6 +217,7 @@ public class EntityBat extends EntityAmbient { + return false; + } + ++ int i = generatoraccess.getLightLevel(blockposition); // Yatopia - moved from above + return i > random.nextInt(b0) ? false : a(entitytypes, generatoraccess, enummobspawn, blockposition, random); + } + } +diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java +index 228236bce14bfdf930570b453862dcfaae9e4823..e278681892d8cc6fe704f32f9d892b3186435ce4 100644 +--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java ++++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java +@@ -2,6 +2,7 @@ package net.minecraft.server; + + import com.google.common.collect.Lists; + import com.mojang.datafixers.util.Pair; ++import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; // Yatopia + import java.util.Collection; + import java.util.Collections; + import java.util.HashSet; +@@ -56,7 +57,7 @@ public class EntityTrackerEntry { + + public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer, Set trackedPlayers) { + // Paper end +- this.trackedPlayers = trackedPlayers; ++ this.trackedPlayers = new ObjectOpenHashSet<>(trackedPlayers); // Yatopia - uses less memory + // CraftBukkit end + this.m = Vec3D.ORIGIN; + this.p = Collections.emptyList();