diff --git a/patches/server/0031-Cache-minecart-vehicle-collide-results.patch b/patches/server/0031-Cache-minecart-vehicle-collision-results.patch similarity index 56% rename from patches/server/0031-Cache-minecart-vehicle-collide-results.patch rename to patches/server/0031-Cache-minecart-vehicle-collision-results.patch index 9c038f7f3..eb980fc36 100644 --- a/patches/server/0031-Cache-minecart-vehicle-collide-results.patch +++ b/patches/server/0031-Cache-minecart-vehicle-collision-results.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 Date: Wed, 23 Aug 2023 14:21:16 -0400 -Subject: [PATCH] Cache minecart vehicle collide results +Subject: [PATCH] Cache minecart vehicle collision results Co-authored-by: MrHua269 -Cache minecart vehicle collide results to prevent lag causing by massive stacked minecart +Cache minecart vehicle collision results to prevent lag causing by massive stacked minecart diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java -index faf449dfb4f95a300796db46833f3b6a51cb961b..67f93b1d915f709364125ae6db3e1148b31ae575 100644 +index faf449dfb4f95a300796db46833f3b6a51cb961b..847bf9edd3f3dbd5c9fd4de4973ac066bbcc1f45 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java @@ -5,6 +5,8 @@ import com.google.common.collect.ImmutableMap; @@ -24,7 +24,7 @@ index faf449dfb4f95a300796db46833f3b6a51cb961b..67f93b1d915f709364125ae6db3e1148 return this.flipped ? this.getDirection().getOpposite().getClockWise() : this.getDirection().getClockWise(); } -+ // Leaf start - Cache minecart vehicle collide results ++ // Leaf start - Cache minecart vehicle collision results + private List lastCollideCache = new ArrayList<>(); + private List lastCollideCache2 = new ArrayList<>(); + @@ -46,10 +46,10 @@ index faf449dfb4f95a300796db46833f3b6a51cb961b..67f93b1d915f709364125ae6db3e1148 this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); } // CraftBukkit end -+ this.checkAndUpdateCache(); // Leaf - Cache minecart vehicle collide results ++ if (org.dreeam.leaf.LeafConfig.cacheMinecartCollision) this.checkAndUpdateCache(); // Leaf - Cache minecart vehicle collision results if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { - List list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this)); -+ List list = this.lastCollideCache; // Leaf - Cache minecart vehicle collide results ++ List list = org.dreeam.leaf.LeafConfig.cacheMinecartCollision ? this.lastCollideCache : this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this));; // Leaf - Cache minecart vehicle collcollisionide results if (!list.isEmpty()) { Iterator iterator = list.iterator(); @@ -58,7 +58,27 @@ index faf449dfb4f95a300796db46833f3b6a51cb961b..67f93b1d915f709364125ae6db3e1148 } } else { - Iterator iterator1 = this.level().getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator(); -+ Iterator iterator1 = this.lastCollideCache2.iterator(); // Leaf - Cache minecart vehicle collide results ++ Iterator iterator1 = org.dreeam.leaf.LeafConfig.cacheMinecartCollision ? this.lastCollideCache2.iterator() : this.level().getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator();; // Leaf - Cache minecart vehicle collision results while (iterator1.hasNext()) { Entity entity1 = (Entity) iterator1.next(); +diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java +index 839b4dba682b67f4ea291717d45d973c84cd3612..2253c44a8532fbc984d97a0067267580788d5d5f 100644 +--- a/src/main/java/org/dreeam/leaf/LeafConfig.java ++++ b/src/main/java/org/dreeam/leaf/LeafConfig.java +@@ -188,6 +188,7 @@ public class LeafConfig { + public static boolean asyncPathfinding = false; + public static int asyncPathfindingMaxThreads = 0; + public static int asyncPathfindingKeepalive = 60; ++ public static boolean cacheMinecartCollision = false; + private static void performance() { + useSpigotItemMergingMechanism = getBoolean("performance.use-spigot-item-merging-mechanism", useSpigotItemMergingMechanism); + asyncPathfinding = getBoolean("performance.async-pathfinding.enable", asyncPathfinding); +@@ -201,6 +202,7 @@ public class LeafConfig { + asyncPathfindingMaxThreads = 0; + else + Bukkit.getLogger().log(Level.INFO, "Using " + asyncPathfindingMaxThreads + " threads for Async Pathfinding"); ++ cacheMinecartCollision = getBoolean("performance.cache-minecart-collision", cacheMinecartCollision); + } + + public static boolean jadeProtocol = false; diff --git a/patches/server/0034-Faster-Random-for-xaeroMapServerID-generation.patch b/patches/server/0034-Faster-Random-for-xaeroMapServerID-generation.patch index 4c7dceacd..65b0d356e 100644 --- a/patches/server/0034-Faster-Random-for-xaeroMapServerID-generation.patch +++ b/patches/server/0034-Faster-Random-for-xaeroMapServerID-generation.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Faster Random for xaeroMapServerID generation diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index 839b4dba682b67f4ea291717d45d973c84cd3612..3935afc36528c1d9bb2d38e60e98999cb8301be4 100644 +index 2253c44a8532fbc984d97a0067267580788d5d5f..3b2ed47f3ad717817afbd7d24f0d926a7396337e 100644 --- a/src/main/java/org/dreeam/leaf/LeafConfig.java +++ b/src/main/java/org/dreeam/leaf/LeafConfig.java @@ -1,7 +1,7 @@ @@ -17,7 +17,7 @@ index 839b4dba682b67f4ea291717d45d973c84cd3612..3935afc36528c1d9bb2d38e60e98999c import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; -@@ -206,7 +206,7 @@ public class LeafConfig { +@@ -208,7 +208,7 @@ public class LeafConfig { public static boolean jadeProtocol = false; public static boolean appleskinProtocol = false; public static boolean xaeroMapProtocol = false;