2017-10-05 21:38:21 +08:00
|
|
|
From e94fb300d55b5e6c5fc12301b1d9833c1251a593 Mon Sep 17 00:00:00 2001
|
2017-01-23 07:24:14 +08: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
|
2017-06-26 07:00:32 +08:00
|
|
|
index 70af657f5..af953dda4 100644
|
2017-01-23 07:24:14 +08:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2017-05-15 02:05:01 +08:00
|
|
|
@@ -410,4 +410,10 @@ public class PaperWorldConfig {
|
2017-01-23 07:24:14 +08:00
|
|
|
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
|
2017-10-05 21:38:21 +08:00
|
|
|
index b4318e4f7..d744477c9 100644
|
2017-01-23 07:24:14 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2017-05-15 02:05:01 +08:00
|
|
|
@@ -169,6 +169,7 @@ public abstract class Entity implements ICommandListener {
|
2017-01-23 07:24:14 +08:00
|
|
|
public final boolean defaultActivationState;
|
|
|
|
public long activatedTick = Integer.MIN_VALUE;
|
2017-06-12 01:03:07 +08:00
|
|
|
public boolean fromMobSpawner;
|
2017-01-23 07:24:14 +08: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
|
2017-06-26 07:00:32 +08:00
|
|
|
index b437ebf26..35e473a26 100644
|
2017-01-23 07:24:14 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2017-06-26 07:00:32 +08:00
|
|
|
@@ -2183,8 +2183,11 @@ public abstract class EntityLiving extends Entity {
|
2017-01-23 07:24:14 +08: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);
|
|
|
|
}
|
|
|
|
--
|
2017-10-05 21:38:21 +08:00
|
|
|
2.14.2
|
2017-01-23 07:24:14 +08:00
|
|
|
|