Paper/patches/server/0126-Cap-Entity-Collisions.patch

43 lines
2.1 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 22 Jan 2017 18:07:56 -0500
Subject: [PATCH] Cap Entity Collisions
Limit a single entity to colliding a max of configurable times per tick.
This will alleviate issues where living entities are hoarded in 1x1 pens
This is not tied to the maxEntityCramming rule. Cramming will still apply
just as it does in Vanilla, but entity pushing logic will be capped.
You can set this to 0 to disable collisions.
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 25fb1785e76aa72eb59565dd51f9fc65b0509869..bfc7736bfe538b615343b6f41f2a670493e2c701 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -373,6 +373,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
2021-06-11 14:02:28 +02:00
public void inactiveTick() { }
// Spigot end
// Paper start
+ protected int numCollisions = 0; // Paper
@javax.annotation.Nullable
private org.bukkit.util.Vector origin;
@javax.annotation.Nullable
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 86a624e505db71241e3acb0b9269372ea693031d..7c50e9c28f9f26b42d2baa51d8fa735bb182ffa5 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2022-06-07 22:12:48 +02:00
@@ -3261,8 +3261,11 @@ public abstract class LivingEntity extends Entity {
2021-06-11 14:02:28 +02:00
}
}
- for (j = 0; j < list.size(); ++j) {
+ this.numCollisions = Math.max(0, this.numCollisions - this.level.paperConfig().collisions.maxEntityCollisions); // Paper
+ for (j = 0; j < list.size() && this.numCollisions < this.level.paperConfig().collisions.maxEntityCollisions; ++j) { // Paper
2021-06-11 14:02:28 +02:00
Entity entity = (Entity) list.get(j);
+ entity.numCollisions++; // Paper
+ this.numCollisions++; // Paper
2021-06-11 14:02:28 +02:00
this.doPush(entity);
}