2015-05-09 22:23:26 +02:00
|
|
|
From 886fe319aa0b17ffea9899275c07889b3346919e Mon Sep 17 00:00:00 2001
|
2014-07-21 22:46:54 +02: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
|
2015-02-28 12:36:22 +01:00
|
|
|
index b930c0d..82accf4 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2015-02-28 12:36:22 +01:00
|
|
|
@@ -1052,6 +1052,7 @@ public abstract class Entity implements ICommandListener {
|
2014-07-21 22:46:54 +02:00
|
|
|
|
2014-11-28 02:17:45 +01:00
|
|
|
public void d(EntityHuman entityhuman) {}
|
2014-07-21 22:46:54 +02:00
|
|
|
|
|
|
|
+ int numCollisions = 0; // Spigot
|
|
|
|
public void collide(Entity entity) {
|
|
|
|
if (entity.passenger != this && entity.vehicle != this) {
|
2015-02-28 12:36:22 +01:00
|
|
|
if (!entity.noclip && !this.noclip) {
|
2014-07-21 22:46:54 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
2015-05-09 22:23:26 +02:00
|
|
|
index 9cd8e9b..0e2f64f 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2015-04-09 05:45:13 +02:00
|
|
|
@@ -1675,7 +1675,9 @@ public abstract class EntityLiving extends Entity {
|
2015-02-28 12:36:22 +01:00
|
|
|
}));
|
2014-07-21 22:46:54 +02:00
|
|
|
|
2015-02-28 12:36:22 +01:00
|
|
|
if (this.ad() && !list.isEmpty()) { // Spigot: Add this.ad() condition
|
2014-07-21 22:46:54 +02: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);
|
2015-02-28 12:36:22 +01:00
|
|
|
|
2014-07-21 22:46:54 +02:00
|
|
|
// TODO better check now?
|
2015-04-09 05:45:13 +02:00
|
|
|
@@ -1685,8 +1687,11 @@ public abstract class EntityLiving extends Entity {
|
2015-02-28 12:36:22 +01:00
|
|
|
}
|
2014-07-21 22:46:54 +02:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2015-02-28 12:36:22 +01:00
|
|
|
+ entity.numCollisions++; // Spigot
|
|
|
|
+ numCollisions++; // Spigot
|
|
|
|
this.s(entity);
|
2014-07-21 22:46:54 +02:00
|
|
|
}
|
|
|
|
+ numCollisions = 0; // Spigot
|
|
|
|
}
|
|
|
|
|
2014-11-28 02:17:45 +01:00
|
|
|
}
|
2014-07-21 22:46:54 +02:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2015-02-12 15:25:18 +01:00
|
|
|
index c7cb20c..76ded26 100644
|
2014-07-21 22:46:54 +02: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 02:17:45 +01:00
|
|
|
maxBulkChunk = getInt( "max-bulk-chunks", 10 );
|
2014-07-21 22:46:54 +02: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 );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2015-05-09 22:23:26 +02:00
|
|
|
2.1.4
|
2014-07-21 22:46:54 +02:00
|
|
|
|