Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
66 Zeilen
2.6 KiB
Diff
66 Zeilen
2.6 KiB
Diff
From 3e7278e88a5c4dcaf66e2ee6d4ed3358e761bab9 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 027b1f1..e69b028 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1053,6 +1053,7 @@ public abstract class Entity implements ICommandListener {
|
|
|
|
public void d(EntityHuman entityhuman) {}
|
|
|
|
+ int numCollisions = 0; // Spigot
|
|
public void collide(Entity entity) {
|
|
if (entity.passenger != this && entity.vehicle != this) {
|
|
if (!entity.noclip && !this.noclip) {
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index 6d1a743..3c852fd 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -1676,7 +1676,9 @@ public abstract class EntityLiving extends Entity {
|
|
}));
|
|
|
|
if (this.ad() && !list.isEmpty()) { // Spigot: Add this.ad() 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?
|
|
@@ -1686,8 +1688,11 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
// CraftBukkit end
|
|
|
|
+ entity.numCollisions++; // Spigot
|
|
+ numCollisions++; // Spigot
|
|
this.s(entity);
|
|
}
|
|
+ numCollisions = 0; // Spigot
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
index ede9250..c652cc5 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
@@ -275,4 +275,11 @@ public class SpigotWorldConfig
|
|
maxBulkChunk = getInt( "max-bulk-chunks", 10 );
|
|
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 );
|
|
+ }
|
|
}
|
|
--
|
|
2.1.4
|
|
|