2016-03-12 10:59:15 +01:00
|
|
|
From 27cef0d51daf007d8d142833a8ff15c9c2186581 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
|
2016-03-11 22:16:41 +01:00
|
|
|
index a782867..c982151 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
|
2016-02-29 22:33:06 +01:00
|
|
|
@@ -147,6 +147,7 @@ public abstract class Entity implements ICommandListener {
|
|
|
|
public long activatedTick = Integer.MIN_VALUE;
|
|
|
|
public boolean fromMobSpawner;
|
|
|
|
public void inactiveTick() { }
|
|
|
|
+ protected int numCollisions = 0;
|
|
|
|
// Spigot end
|
2014-07-21 22:46:54 +02:00
|
|
|
|
2016-02-29 22:33:06 +01:00
|
|
|
public Entity(World world) {
|
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
|
2016-03-12 10:59:15 +01:00
|
|
|
index 7a0f06a..89b2eb0 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
|
2016-03-12 10:59:15 +01:00
|
|
|
@@ -1970,7 +1970,8 @@ public abstract class EntityLiving extends Entity {
|
2016-02-29 22:33:06 +01:00
|
|
|
List list = this.world.a((Entity) this, this.getBoundingBox(), IEntitySelector.a(this));
|
2014-07-21 22:46:54 +02:00
|
|
|
|
2016-02-29 22:33:06 +01:00
|
|
|
if (this.isInteractable() && !list.isEmpty()) { // Spigot: Add isInteractable() condition
|
|
|
|
- for (int i = 0; i < list.size(); ++i) {
|
2016-03-10 06:23:26 +01:00
|
|
|
+ numCollisions = Math.max(0, numCollisions - world.spigotConfig.maxCollisionsPerEntity); // Spigot
|
2016-02-29 22:33:06 +01:00
|
|
|
+ for (int i = 0; i < list.size() && numCollisions < world.spigotConfig.maxCollisionsPerEntity; ++i) {
|
2014-07-21 22:46:54 +02:00
|
|
|
Entity entity = (Entity) list.get(i);
|
|
|
|
// TODO better check now?
|
2016-02-29 22:33:06 +01:00
|
|
|
// CraftBukkit start - Only handle mob (non-player) collisions every other tick
|
2016-03-12 10:59:15 +01:00
|
|
|
@@ -1979,7 +1980,8 @@ public abstract class EntityLiving extends Entity {
|
2015-02-28 12:36:22 +01:00
|
|
|
}
|
2014-07-21 22:46:54 +02:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2016-02-29 22:33:06 +01:00
|
|
|
-
|
2015-02-28 12:36:22 +01:00
|
|
|
+ entity.numCollisions++; // Spigot
|
|
|
|
+ numCollisions++; // Spigot
|
2016-02-29 22:33:06 +01:00
|
|
|
this.C(entity);
|
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
|
2016-02-29 22:33:06 +01:00
|
|
|
index 4cca76a..19525eb 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
|
2016-02-29 22:33:06 +01:00
|
|
|
@@ -224,4 +224,11 @@ public class SpigotWorldConfig
|
|
|
|
enableZombiePigmenPortalSpawns = getBoolean( "enable-zombie-pigmen-portal-spawns", true );
|
|
|
|
log( "Allow Zombie Pigmen to spawn from portal blocks: " + enableZombiePigmenPortalSpawns );
|
2014-07-21 22:46:54 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public int maxCollisionsPerEntity;
|
|
|
|
+ private void maxEntityCollision()
|
|
|
|
+ {
|
|
|
|
+ maxCollisionsPerEntity = getInt( "max-entity-collisions", 8 );
|
|
|
|
+ log( "Max Entity Collisions: " + maxCollisionsPerEntity );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2016-02-29 22:33:06 +01:00
|
|
|
2.5.0
|
2014-07-21 22:46:54 +02:00
|
|
|
|