testserver/Spigot-Server-Patches/0197-Cap-Entity-Collisions....

61 lines
2.7 KiB
Diff
Raw Normal View History

2018-03-26 00:06:44 +00:00
From 27376f342b71acfc59a880589e60757726ac340d 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/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 7871406e4..3ba465305 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -408,4 +408,10 @@ public class PaperWorldConfig {
private void armorStandEntityLookups() {
armorStandEntityLookups = getBoolean("armor-stands-do-collision-entity-lookups", true);
}
+
+ public int maxCollisionsPerEntity;
+ private void maxEntityCollision() {
+ maxCollisionsPerEntity = getInt( "max-entity-collisions", this.spigotConfig.getInt("max-entity-collisions", 8) );
+ log( "Max Entity Collisions: " + maxCollisionsPerEntity );
+ }
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
2018-03-26 00:06:44 +00:00
index 546059414..a5ed651dd 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2017-11-08 16:13:57 +00:00
@@ -170,6 +170,7 @@ public abstract class Entity implements ICommandListener {
public final boolean defaultActivationState;
public long activatedTick = Integer.MIN_VALUE;
2017-06-11 17:03:07 +00:00
public boolean fromMobSpawner;
+ protected int numCollisions = 0; // Paper
public void inactiveTick() { }
// Spigot end
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
2018-03-26 00:06:44 +00:00
index 91e8c1d75..adb045937 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2018-03-26 00:06:44 +00:00
@@ -2191,8 +2191,11 @@ public abstract class EntityLiving extends Entity {
}
}
- for (j = 0; j < list.size(); ++j) {
+ numCollisions = Math.max(0, numCollisions - world.paperConfig.maxCollisionsPerEntity); // Paper
+ for (j = 0; j < list.size() && numCollisions < world.paperConfig.maxCollisionsPerEntity; ++j) { // Paper
Entity entity = (Entity) list.get(j);
+ entity.numCollisions++; // Paper
+ numCollisions++; // Paper
this.C(entity);
}
--
2018-03-26 00:06:44 +00:00
2.16.2