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
|
2024-11-04 18:42:38 +01:00
|
|
|
index 27a0f0651ac961c06626df1e4beb5525b4dacd48..2b5d1bc6d3b3fd04bcbf4984035a00b9151cf2ee 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
|
2024-11-04 18:42:38 +01:00
|
|
|
@@ -405,6 +405,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
2024-01-24 11:45:17 +01:00
|
|
|
public long activatedTick = Integer.MIN_VALUE;
|
2021-06-11 14:02:28 +02:00
|
|
|
public void inactiveTick() { }
|
|
|
|
// Spigot end
|
2024-01-22 19:01:10 +01:00
|
|
|
+ protected int numCollisions = 0; // Paper - Cap entity collisions
|
2024-01-24 11:45:17 +01:00
|
|
|
// Paper start - Entity origin API
|
2021-12-03 22:28:15 +01:00
|
|
|
@javax.annotation.Nullable
|
|
|
|
private org.bukkit.util.Vector origin;
|
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
|
2024-11-04 18:42:38 +01:00
|
|
|
index 6c29a05e91a6bac634ca3e5394b90112b65cdbd6..009539fa39c81c610ac34747cc09082a0756c79d 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
|
2024-11-04 18:42:38 +01:00
|
|
|
@@ -3641,10 +3641,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2023-09-21 22:35:39 +02:00
|
|
|
Iterator iterator1 = list.iterator();
|
2024-01-22 19:01:10 +01:00
|
|
|
+ this.numCollisions = Math.max(0, this.numCollisions - this.level().paperConfig().collisions.maxEntityCollisions); // Paper - Cap entity collisions
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2023-09-21 22:35:39 +02:00
|
|
|
- while (iterator1.hasNext()) {
|
2024-01-22 19:01:10 +01:00
|
|
|
+ while (iterator1.hasNext() && this.numCollisions < this.level().paperConfig().collisions.maxEntityCollisions) { // Paper - Cap entity collisions
|
2023-09-21 22:35:39 +02:00
|
|
|
Entity entity1 = (Entity) iterator1.next();
|
|
|
|
-
|
2024-01-22 19:01:10 +01:00
|
|
|
+ entity1.numCollisions++; // Paper - Cap entity collisions
|
|
|
|
+ this.numCollisions++; // Paper - Cap entity collisions
|
2023-09-21 22:35:39 +02:00
|
|
|
this.doPush(entity1);
|
2022-12-07 19:52:24 +01:00
|
|
|
}
|
2023-09-21 22:35:39 +02:00
|
|
|
}
|