Paper/patches/server/0130-Cap-Entity-Collisions.patch

58 Zeilen
2.9 KiB
Diff

2021-06-11 14:02:28 +02: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
index f383f30b9dd1a7c6cf69d342f99118beec70b206..47b717e8741bb2b8f3aa776dcdc73a3e7dbb5960 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2021-11-24 18:58:26 +01:00
@@ -370,4 +370,10 @@ public class PaperWorldConfig {
2021-06-11 14:02:28 +02:00
log("Treasure Maps will return already discovered locations");
}
}
+
+ public int maxCollisionsPerEntity = 8;
2021-06-11 14:02:28 +02:00
+ private void maxEntityCollision() {
+ maxCollisionsPerEntity = getInt( "max-entity-collisions", this.spigotConfig.getInt("max-entity-collisions", this.maxCollisionsPerEntity, false) );
2021-06-11 14:02:28 +02:00
+ 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
index ebf9e06b4fdd64d22ad2b56c26b4c994c1a84833..fb7487b52af00ae44e669242a4182a49e9b00428 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -314,6 +314,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
2021-06-11 14:02:28 +02:00
public void inactiveTick() { }
// Spigot end
// Paper start
+ protected int numCollisions = 0; // Paper
@javax.annotation.Nullable
private org.bukkit.util.Vector origin;
@javax.annotation.Nullable
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 3490b9f1803ea852ad0682e22524b58c3b050510..9c175c28d152d4a6af9a720cfd95df7fdcc1be81 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3225,8 +3225,11 @@ public abstract class LivingEntity extends Entity {
2021-06-11 14:02:28 +02: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 14:02:28 +02:00
Entity entity = (Entity) list.get(j);
+ entity.numCollisions++; // Paper
+ this.numCollisions++; // Paper
2021-06-11 14:02:28 +02:00
this.doPush(entity);
}