2014-12-21 01:09:49 +00:00
|
|
|
From 4ad5a056b57e8fc8ca2244c79d38adfa1912dbc3 Mon Sep 17 00:00:00 2001
|
2014-07-21 20:46:54 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Fri, 31 Jan 2014 11:18:34 -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.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
2014-12-21 01:09:49 +00:00
|
|
|
index 8537222..887db67 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2014-12-13 04:47:57 +00:00
|
|
|
@@ -1059,6 +1059,7 @@ public abstract class Entity implements ICommandListener {
|
2014-07-21 20:46:54 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
public void d(EntityHuman entityhuman) {}
|
2014-07-21 20:46:54 +00:00
|
|
|
|
|
|
|
+ int numCollisions = 0; // Spigot
|
|
|
|
public void collide(Entity entity) {
|
|
|
|
if (entity.passenger != this && entity.vehicle != this) {
|
2014-11-28 01:17:45 +00:00
|
|
|
if (!entity.T && !this.T) {
|
2014-07-21 20:46:54 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
2014-12-11 04:21:51 +00:00
|
|
|
index 2d14a0d..807d5fa 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2014-12-11 04:21:51 +00:00
|
|
|
@@ -1626,7 +1626,9 @@ public abstract class EntityLiving extends Entity {
|
2014-11-28 01:17:45 +00:00
|
|
|
List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
|
2014-07-21 20:46:54 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
if (this.ad() && list != null && !list.isEmpty()) { // Spigot: Add this.ad() condition
|
2014-07-21 20:46:54 +00:00
|
|
|
+ numCollisions -= world.spigotConfig.maxCollisionsPerEntity; // Spigot
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
+ if (numCollisions > world.spigotConfig.maxCollisionsPerEntity) { break; } // Spigot
|
|
|
|
Entity entity = (Entity) list.get(i);
|
2014-11-28 01:17:45 +00:00
|
|
|
|
2014-07-21 20:46:54 +00:00
|
|
|
// TODO better check now?
|
2014-12-11 04:21:51 +00:00
|
|
|
@@ -1637,9 +1639,12 @@ public abstract class EntityLiving extends Entity {
|
2014-07-21 20:46:54 +00:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
if (entity.ae()) {
|
2014-07-21 20:46:54 +00:00
|
|
|
+ entity.numCollisions++; // Spigot
|
|
|
|
+ numCollisions++; // Spigot
|
2014-11-28 01:17:45 +00:00
|
|
|
this.s(entity);
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
+ numCollisions = 0; // Spigot
|
|
|
|
}
|
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
}
|
2014-07-21 20:46:54 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2014-11-28 01:17:45 +00:00
|
|
|
index 93ab1c1..71f772c 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
@@ -273,4 +273,11 @@ public class SpigotWorldConfig
|
2014-11-28 01:17:45 +00:00
|
|
|
maxBulkChunk = getInt( "max-bulk-chunks", 10 );
|
2014-07-21 20:46:54 +00:00
|
|
|
log( "Sending up to " + maxBulkChunk + " chunks per packet" );
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public int maxCollisionsPerEntity;
|
|
|
|
+ private void maxEntityCollision()
|
|
|
|
+ {
|
|
|
|
+ maxCollisionsPerEntity = getInt( "max-entity-collisions", 8 );
|
|
|
|
+ log( "Max Entity Collisions: " + maxCollisionsPerEntity );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2014-11-28 01:17:45 +00:00
|
|
|
2.1.0
|
2014-07-21 20:46:54 +00:00
|
|
|
|