Paper/Spigot-Server-Patches/0141-Cap-Entity-Collisions.patch

61 lines
2.6 KiB
Diff
Raw Normal View History

2019-12-12 00:43:22 +01:00
From c667019226f7a78de46e1e18cdc92176f0b1044c 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
2019-12-12 00:43:22 +01:00
index bf11448bc..e00e1e8f6 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -320,4 +320,10 @@ public class PaperWorldConfig {
log("Treasure Maps will return already discovered locations");
}
}
+
+ 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
2019-12-12 00:43:22 +01:00
index 1619d9f41..fcfe8f550 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2019-12-12 00:43:22 +01:00
@@ -189,6 +189,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
public final boolean defaultActivationState;
public long activatedTick = Integer.MIN_VALUE;
2017-06-11 19:03:07 +02: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
2019-12-12 00:43:22 +01:00
index be85a76ac..6379b361a 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2019-12-12 00:43:22 +01:00
@@ -2621,8 +2621,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
2019-12-12 00:43:22 +01:00
this.C(entity);
}
--
2019-12-12 00:43:22 +01:00
2.17.1