2018-07-23 08:39:55 +00:00
|
|
|
From b2a476a7e2062d113de8a10658ce6b40b2bad9ee Mon Sep 17 00:00:00 2001
|
2017-01-22 23:24:14 +00:00
|
|
|
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
|
2018-07-23 08:39:55 +00:00
|
|
|
index 5df8b1143f..0b748d402b 100644
|
2017-01-22 23:24:14 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2018-07-18 00:08:13 +00:00
|
|
|
@@ -343,4 +343,10 @@ public class PaperWorldConfig {
|
|
|
|
log("Treasure Maps will return already discovered locations");
|
|
|
|
}
|
2017-01-22 23:24:14 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ 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-07-23 08:39:55 +00:00
|
|
|
index 78b7b8be99..6db20aa75c 100644
|
2017-01-22 23:24:14 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2018-07-21 20:43:00 +00:00
|
|
|
@@ -181,6 +181,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2017-01-22 23:24:14 +00:00
|
|
|
public final boolean defaultActivationState;
|
|
|
|
public long activatedTick = Integer.MIN_VALUE;
|
2017-06-11 17:03:07 +00:00
|
|
|
public boolean fromMobSpawner;
|
2017-01-22 23:24:14 +00:00
|
|
|
+ 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-07-23 08:39:55 +00:00
|
|
|
index f9a76ce27c..3b4867bfc9 100644
|
2017-01-22 23:24:14 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2018-07-21 20:03:10 +00:00
|
|
|
@@ -2318,8 +2318,11 @@ public abstract class EntityLiving extends Entity {
|
2017-01-22 23:24:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- 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-07-20 19:57:43 +00:00
|
|
|
2.18.0
|
2017-01-22 23:24:14 +00:00
|
|
|
|