-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make cache minecart collision configurable
- Loading branch information
1 parent
cb51f2c
commit 7c1e327
Showing
2 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: MrHua269 <[email protected]> | ||
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 <[email protected]> | ||
|
||
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<Entity> lastCollideCache = new ArrayList<>(); | ||
+ private List<Entity> 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<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this)); | ||
+ List<Entity> list = this.lastCollideCache; // Leaf - Cache minecart vehicle collide results | ||
+ List<Entity> 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters