2014-04-30 14:13:37 +00:00
|
|
|
From d5d17c04b5a9c0f672c267ab36b7dc15eb1dcd2d Mon Sep 17 00:00:00 2001
|
2014-04-12 04:18:37 +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-04-18 17:08:19 +00:00
|
|
|
index c4bdccf..c542460 100644
|
2014-04-12 04:18:37 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2014-04-18 17:08:19 +00:00
|
|
|
@@ -1023,6 +1023,7 @@ public abstract class Entity {
|
2014-04-12 04:18:37 +00:00
|
|
|
|
|
|
|
public void b_(EntityHuman entityhuman) {}
|
|
|
|
|
|
|
|
+ int numCollisions = 0; // Spigot
|
|
|
|
public void collide(Entity entity) {
|
|
|
|
if (entity.passenger != this && entity.vehicle != this) {
|
|
|
|
double d0 = entity.locX - this.locX;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
2014-04-30 14:13:37 +00:00
|
|
|
index dad8964..234d7db 100644
|
2014-04-12 04:18:37 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2014-04-30 14:13:37 +00:00
|
|
|
@@ -1495,7 +1495,9 @@ public abstract class EntityLiving extends Entity {
|
2014-04-12 04:18:37 +00:00
|
|
|
List list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
|
|
|
|
|
|
|
|
if (this.R() && list != null && !list.isEmpty()) { // Spigot: Add this.R() condition
|
|
|
|
+ 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);
|
|
|
|
|
|
|
|
// TODO better check now?
|
2014-04-30 14:13:37 +00:00
|
|
|
@@ -1506,9 +1508,12 @@ public abstract class EntityLiving extends Entity {
|
2014-04-12 04:18:37 +00:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
if (entity.R()) {
|
|
|
|
+ entity.numCollisions++; // Spigot
|
|
|
|
+ numCollisions++; // Spigot
|
|
|
|
this.o(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ numCollisions = 0; // Spigot
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2014-04-18 23:22:44 +00:00
|
|
|
index 744e1be..9745982 100644
|
2014-04-12 04:18:37 +00:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2014-04-18 23:22:44 +00:00
|
|
|
@@ -273,4 +273,11 @@ public class SpigotWorldConfig
|
2014-04-12 04:18:37 +00:00
|
|
|
maxBulkChunk = getInt( "max-bulk-chunks", 5 );
|
|
|
|
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-04-18 17:08:19 +00:00
|
|
|
1.9.1
|
2014-04-12 04:18:37 +00:00
|
|
|
|