mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-12 01:41:05 +01:00
63 lines
2.8 KiB
Diff
63 lines
2.8 KiB
Diff
From c055436cae43c418f24f4238d0faa39e761c0de2 Mon Sep 17 00:00:00 2001
|
|
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
|
|
index eb552e2..5702cb0 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -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
|
|
|
|
public Entity(World world) {
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index c2f5ee1..b410f3b 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -1967,7 +1967,8 @@ public abstract class EntityLiving extends Entity {
|
|
List list = this.world.a((Entity) this, this.getBoundingBox(), IEntitySelector.a(this));
|
|
|
|
if (this.isInteractable() && !list.isEmpty()) { // Spigot: Add isInteractable() condition
|
|
- for (int i = 0; i < list.size(); ++i) {
|
|
+ numCollisions -= world.spigotConfig.maxCollisionsPerEntity; // Spigot
|
|
+ for (int i = 0; i < list.size() && numCollisions < world.spigotConfig.maxCollisionsPerEntity; ++i) {
|
|
Entity entity = (Entity) list.get(i);
|
|
// TODO better check now?
|
|
// CraftBukkit start - Only handle mob (non-player) collisions every other tick
|
|
@@ -1976,7 +1977,8 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
// CraftBukkit end
|
|
|
|
-
|
|
+ entity.numCollisions++; // Spigot
|
|
+ numCollisions++; // Spigot
|
|
this.C(entity);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
index 4cca76a..19525eb 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
@@ -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 );
|
|
}
|
|
+
|
|
+ public int maxCollisionsPerEntity;
|
|
+ private void maxEntityCollision()
|
|
+ {
|
|
+ maxCollisionsPerEntity = getInt( "max-entity-collisions", 8 );
|
|
+ log( "Max Entity Collisions: " + maxCollisionsPerEntity );
|
|
+ }
|
|
}
|
|
--
|
|
2.5.0
|
|
|