mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 15:47:44 +01:00
44 lines
2.2 KiB
Diff
44 lines
2.2 KiB
Diff
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 c85833a54c79b9a6eb18bc22dae67a92dbbad724..bea207f8fc4cd1af06622e10ff904d9459d4bc66 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -387,6 +387,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
public void inactiveTick() { }
|
|
// Spigot end
|
|
// Paper start
|
|
+ protected int numCollisions = 0; // Paper
|
|
@javax.annotation.Nullable
|
|
private org.bukkit.util.Vector origin;
|
|
@javax.annotation.Nullable
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index 59d3ae122239f924d71d4e9d212b3bd343b80609..47726c9d2c5384d31983e53fd17d91cd12da8961 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -3346,10 +3346,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
Iterator iterator1 = list.iterator();
|
|
+ this.numCollisions = Math.max(0, this.numCollisions - this.level().paperConfig().collisions.maxEntityCollisions); // Paper
|
|
|
|
- while (iterator1.hasNext()) {
|
|
+ while (iterator1.hasNext() && this.numCollisions < this.level().paperConfig().collisions.maxEntityCollisions) { // Paper
|
|
Entity entity1 = (Entity) iterator1.next();
|
|
-
|
|
+ entity1.numCollisions++; // Paper
|
|
+ this.numCollisions++; // Paper
|
|
this.doPush(entity1);
|
|
}
|
|
}
|