testserver/patches/server/0130-Cap-Entity-Collisions....

58 lines
3.0 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 22 Jan 2017 18:07:56 -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
This is not tied to the maxEntityCramming rule. Cramming will still apply
just as it does in Vanilla, but entity pushing logic will be capped.
You can set this to 0 to disable collisions.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2021-11-24 17:58:26 +00:00
index f383f30b9dd1a7c6cf69d342f99118beec70b206..7cd6a36e000d9e1958d260739e6fcfb064402b4d 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2021-11-24 17:58:26 +00:00
@@ -370,4 +370,10 @@ public class PaperWorldConfig {
2021-06-11 12:02:28 +00:00
log("Treasure Maps will return already discovered locations");
}
}
+
+ public int maxCollisionsPerEntity;
+ private void maxEntityCollision() {
+ maxCollisionsPerEntity = getInt( "max-entity-collisions", this.spigotConfig.getInt("max-entity-collisions", 8) );
+ log( "Max Entity Collisions: " + maxCollisionsPerEntity );
+ }
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
2021-11-23 13:22:49 +00:00
index 819fbb2e786cc4546a981b34ff55a6241c72b5a3..4f1add992cef7bfa194a9e464ae9ea56eab1f191 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
2021-11-23 13:22:49 +00:00
@@ -326,6 +326,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
2021-06-11 12:02:28 +00:00
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState;
public long activatedTick = Integer.MIN_VALUE;
+ protected int numCollisions = 0; // Paper
public void inactiveTick() { }
// Spigot end
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2021-11-23 13:22:49 +00:00
index a11ee8a247affeb97de4c3152ea1449e8bc5b223..77b96f632342026fcd2c37e34e63db3e11396c34 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2021-11-23 13:22:49 +00:00
@@ -3227,8 +3227,11 @@ public abstract class LivingEntity extends Entity {
2021-06-11 12:02:28 +00:00
}
}
- for (j = 0; j < list.size(); ++j) {
+ this.numCollisions = Math.max(0, this.numCollisions - this.level.paperConfig.maxCollisionsPerEntity); // Paper
+ for (j = 0; j < list.size() && this.numCollisions < this.level.paperConfig.maxCollisionsPerEntity; ++j) { // Paper
2021-06-11 12:02:28 +00:00
Entity entity = (Entity) list.get(j);
+ entity.numCollisions++; // Paper
+ this.numCollisions++; // Paper
2021-06-11 12:02:28 +00:00
this.doPush(entity);
}