9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-21 07:49:29 +00:00
Files
SakuraMC/sakura-server/minecraft-patches/features/0014-Use-maxEntityCollision-limit-for-entity-retrieval.patch
2025-09-29 01:59:24 +01:00

30 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Thu, 23 Sep 2021 18:50:13 +0100
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 4b913275566d3010a7ba8bf5d7f47e2a16abf61d..362f14c37fc9ab2f4a23aa7ac07a596022ee3bc0 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3783,7 +3783,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
return;
}
// Paper end - don't run getEntities if we're not going to use its result
- List<Entity> pushableEntities = this.level().getPushableEntities(this, this.getBoundingBox());
+ // Sakura start - use maxEntityCollision limit for entity retrieval
+ //List<Entity> pushableEntities = this.level().getPushableEntities(this, this.getBoundingBox());
+ final int limit = Math.max(_int, this.level().paperConfig().collisions.maxEntityCollisions);
+ final int search = limit * limit;
+ final List<Entity> pushableEntities = new java.util.ArrayList<>(4);
+ this.level().getEntities(
+ net.minecraft.world.level.entity.EntityTypeTest.forClass(Entity.class),
+ this.getBoundingBox(), EntitySelector.pushableBy(this),
+ pushableEntities, limit, search
+ );
+ // Sakura end - use maxEntityCollision limit for entity retrieval
if (!pushableEntities.isEmpty()) {
if (this.level() instanceof ServerLevel serverLevel) {
// Paper - don't run getEntities if we're not going to use its result; moved up