From 9ad005f3a2f35b8f09cf96bb81009556d3ffa54a Mon Sep 17 00:00:00 2001 From: Samsuik Date: Sun, 9 Feb 2025 18:05:25 +0000 Subject: [PATCH] Fix pushEntities causing a crash when there's an enderdragon in the world --- .../features/0011-Add-maxSearch-to-getEntities.patch | 4 ++-- ...maxEntityCollision-limit-for-entity-retrieval.patch | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sakura-server/minecraft-patches/features/0011-Add-maxSearch-to-getEntities.patch b/sakura-server/minecraft-patches/features/0011-Add-maxSearch-to-getEntities.patch index 958f3b5..cd89284 100644 --- a/sakura-server/minecraft-patches/features/0011-Add-maxSearch-to-getEntities.patch +++ b/sakura-server/minecraft-patches/features/0011-Add-maxSearch-to-getEntities.patch @@ -83,7 +83,7 @@ index 7554c109c35397bc1a43dd80e87764fd78645bbf..d60f30f7afb15cc90c1bd4b816136d00 } } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 4dd2c4110d85bb7e6575b325196329900d719c64..b4a8a81f1fa091e45f1f39fdb69c61871d7dc6b9 100644 +index 9217983e973fb522776babe0588dd419653e3b39..e0341e79c87fe115732aab1aa0bd1d8c514ba7b8 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -1791,10 +1791,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -91,10 +91,10 @@ index 4dd2c4110d85bb7e6575b325196329900d719c64..b4a8a81f1fa091e45f1f39fdb69c6187 } - // Paper start - rewrite chunk system -+ // Sakura start - add maxSearch to getEntities public void getEntities(final EntityTypeTest entityTypeTest, final AABB boundingBox, final Predicate predicate, final List into, final int maxCount) { ++ // Sakura start - add maxSearch to getEntities + this.getEntities(entityTypeTest, boundingBox, predicate, into, maxCount, Integer.MAX_VALUE); + } + diff --git a/sakura-server/minecraft-patches/features/0012-Use-maxEntityCollision-limit-for-entity-retrieval.patch b/sakura-server/minecraft-patches/features/0012-Use-maxEntityCollision-limit-for-entity-retrieval.patch index ebcb988..ed45770 100644 --- a/sakura-server/minecraft-patches/features/0012-Use-maxEntityCollision-limit-for-entity-retrieval.patch +++ b/sakura-server/minecraft-patches/features/0012-Use-maxEntityCollision-limit-for-entity-retrieval.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Use maxEntityCollision limit for entity retrieval diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 7ed355448ff6fbcf585d82a88d456908f9eb3ae6..e7b92681e5d65892da00699cc29c713219c9db8c 100644 +index 7ed355448ff6fbcf585d82a88d456908f9eb3ae6..d0c013df89bb18ce0267b62461c69aaaec44e8c3 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3640,7 +3640,12 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3640,7 +3640,16 @@ public abstract class LivingEntity extends Entity implements Attackable { return; } // Paper end - don't run getEntities if we're not going to use its result @@ -17,7 +17,11 @@ index 7ed355448ff6fbcf585d82a88d456908f9eb3ae6..e7b92681e5d65892da00699cc29c7132 + int limit = Math.max(_int, this.level().paperConfig().collisions.maxEntityCollisions); + int search = limit * limit; + List entities = new ArrayList<>(); -+ this.level().getEntities(null, this.getBoundingBox(), EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule), entities, limit, search); // Paper - Climbing should not bypass cramming gamerule ++ this.level().getEntities( ++ EntityTypeTest.forClass(Entity.class), this.getBoundingBox(), ++ EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule), // Paper - Climbing should not bypass cramming gamerule ++ entities, limit, search ++ ); + // Sakura end - use maxEntityCollision limit for entity retrieval if (!entities.isEmpty()) { // Paper - don't run getEntities if we're not going to use its result; moved up