Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
45 Zeilen
2.4 KiB
Diff
45 Zeilen
2.4 KiB
Diff
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/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index a914d2906ae7433164d7f439a0f2f0d781b14747..05cb13a5636f82d48bf0bd8b9d27abdd80a8df71 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -393,6 +393,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
public long activatedTick = Integer.MIN_VALUE;
|
|
public void inactiveTick() { }
|
|
// Spigot end
|
|
+ protected int numCollisions = 0; // Paper - Cap entity collisions
|
|
// Paper start - Entity origin API
|
|
@javax.annotation.Nullable
|
|
private org.bukkit.util.Vector origin;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index ed8e0f5ca865dcde73a886e65f0fd1d7d4e7ac05..a799b64e9d655e7eba509e9930e623a88bbb0389 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -3348,10 +3348,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
Iterator iterator1 = list.iterator();
|
|
+ this.numCollisions = Math.max(0, this.numCollisions - this.level().paperConfig().collisions.maxEntityCollisions); // Paper - Cap entity collisions
|
|
|
|
- while (iterator1.hasNext()) {
|
|
+ while (iterator1.hasNext() && this.numCollisions < this.level().paperConfig().collisions.maxEntityCollisions) { // Paper - Cap entity collisions
|
|
Entity entity1 = (Entity) iterator1.next();
|
|
-
|
|
+ entity1.numCollisions++; // Paper - Cap entity collisions
|
|
+ this.numCollisions++; // Paper - Cap entity collisions
|
|
this.doPush(entity1);
|
|
}
|
|
}
|