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
|
2022-06-06 02:17:27 +02:00
|
|
|
index 8451982ba4fc9522f2d77f68fc63a0e12558955f..ee8ce0e5bdb0acb7d6ef3439a388e108ea1807de 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
|
2022-06-06 02:17:27 +02:00
|
|
|
@@ -391,4 +391,10 @@ public class PaperWorldConfig {
|
|
|
|
treasureMapsAlreadyDiscoveredVillager = getBoolean("treasure-maps-find-already-discovered.villager-trade", treasureMapsAlreadyDiscoveredVillager);
|
|
|
|
treasureMapsAlreadyDiscoveredLootTable = getBooleanOrNull("treasure-maps-find-already-discovered.loot-tables", treasureMapsAlreadyDiscoveredLootTable);
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
+
|
2021-12-01 19:03:46 +01:00
|
|
|
+ public int maxCollisionsPerEntity = 8;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ private void maxEntityCollision() {
|
2021-12-01 19:03:46 +01:00
|
|
|
+ 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
|
2022-06-03 06:26:56 +02:00
|
|
|
index 74a5b29ee48964aef9587939ecb3a66f52f658b5..336f6209089d3f076bfdd332bfc80d69509ca209 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
|
2022-03-30 22:28:38 +02:00
|
|
|
@@ -317,6 +317,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
2021-06-11 14:02:28 +02:00
|
|
|
public void inactiveTick() { }
|
|
|
|
// Spigot end
|
2021-12-03 22:28:15 +01:00
|
|
|
// 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
|
2022-06-03 06:26:56 +02:00
|
|
|
index 27ba3a28c18b0af18eb20a7441f361a46700a4bd..a7e09145160f9c26b19a8d61564bf9c04e2616b1 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
|
2022-03-01 06:43:03 +01:00
|
|
|
@@ -3228,8 +3228,11 @@ public abstract class LivingEntity extends Entity {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- for (j = 0; j < list.size(); ++j) {
|
2021-06-12 11:01:04 +02: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 14:02:28 +02:00
|
|
|
Entity entity = (Entity) list.get(j);
|
|
|
|
+ entity.numCollisions++; // Paper
|
2021-06-12 11:01:04 +02:00
|
|
|
+ this.numCollisions++; // Paper
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
this.doPush(entity);
|
|
|
|
}
|