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
|
2022-03-11 20:13:46 +00:00
|
|
|
index 5183c756289db3600d04d473c20d08768af91ea9..72501b05d1d5d9304e4ac31bbf694f5ca1637c0f 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
|
2022-03-11 20:13:46 +00:00
|
|
|
@@ -365,4 +365,10 @@ public class PaperWorldConfig {
|
2021-06-11 12:02:28 +00:00
|
|
|
log("Treasure Maps will return already discovered locations");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
2021-12-01 18:03:46 +00:00
|
|
|
+ public int maxCollisionsPerEntity = 8;
|
2021-06-11 12:02:28 +00:00
|
|
|
+ private void maxEntityCollision() {
|
2021-12-01 18:03:46 +00:00
|
|
|
+ maxCollisionsPerEntity = getInt( "max-entity-collisions", this.spigotConfig.getInt("max-entity-collisions", this.maxCollisionsPerEntity, false) );
|
2021-06-11 12:02:28 +00: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
|
2022-03-01 03:25:13 +00:00
|
|
|
index d6501d075b090abb8166dfda10c80d63b67d8e42..357f10f8daa93e0222ced3e9b9c5930ad0a5658c 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
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -317,6 +317,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
2021-06-11 12:02:28 +00:00
|
|
|
public void inactiveTick() { }
|
|
|
|
// Spigot end
|
2021-12-03 21:28:15 +00:00
|
|
|
// Paper start
|
|
|
|
+ protected int numCollisions = 0; // Paper
|
|
|
|
@javax.annotation.Nullable
|
|
|
|
private org.bukkit.util.Vector origin;
|
|
|
|
@javax.annotation.Nullable
|
2021-06-11 12:02:28 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2022-03-01 05:43:03 +00:00
|
|
|
index 7df80e251dbdaff32cdc0f3e7dffc9ea6d163b09..f7d100d5fa85cd2e705e78be8dc6373f02d0adc0 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
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -3228,8 +3228,11 @@ public abstract class LivingEntity extends Entity {
|
2021-06-11 12:02:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- for (j = 0; j < list.size(); ++j) {
|
2021-06-12 09:01:04 +00:00
|
|
|
+ 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
|
2021-06-12 09:01:04 +00:00
|
|
|
+ this.numCollisions++; // Paper
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
this.doPush(entity);
|
|
|
|
}
|