mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 20:46:59 +01:00
Cap Entity Collisions - Resolves #577
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.
This commit is contained in:
parent
1928933a96
commit
c9759766a3
@ -1,4 +1,4 @@
|
||||
From 1d7689f18f46242f411ada922d7c4feddf599ec1 Mon Sep 17 00:00:00 2001
|
||||
From 20b7319640b3687ea5e7b422e478eb1576ff10a7 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Mon, 29 Feb 2016 21:02:09 -0600
|
||||
Subject: [PATCH] Paper config files
|
||||
@ -6,7 +6,7 @@ Subject: [PATCH] Paper config files
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
new file mode 100644
|
||||
index 0000000..c009c5f
|
||||
index 000000000..c009c5f12
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -0,0 +1,164 @@
|
||||
@ -176,7 +176,7 @@ index 0000000..c009c5f
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
new file mode 100644
|
||||
index 0000000..dae60dc
|
||||
index 000000000..dae60dcce
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -0,0 +1,72 @@
|
||||
@ -253,7 +253,7 @@ index 0000000..dae60dc
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
|
||||
index 31756b8..cb83e4f 100644
|
||||
index 31756b80d..cb83e4f56 100644
|
||||
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
|
||||
@@ -183,6 +183,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
||||
@ -268,7 +268,7 @@ index 31756b8..cb83e4f 100644
|
||||
DedicatedServer.LOGGER.info("Generating keypair");
|
||||
this.a(MinecraftEncryption.b());
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 80a8c55..09ca809 100644
|
||||
index d7cc8b60f..b29375a0c 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -125,6 +125,8 @@ public abstract class World implements IBlockAccess {
|
||||
@ -289,7 +289,7 @@ index 80a8c55..09ca809 100644
|
||||
this.world = new CraftWorld((WorldServer) this, gen, env);
|
||||
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 3122607..791383f 100644
|
||||
index 312260764..791383fb3 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -697,6 +697,7 @@ public final class CraftServer implements Server {
|
||||
@ -316,7 +316,7 @@ index 3122607..791383f 100644
|
||||
overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index 8f301b9..2cafdb8 100644
|
||||
index b931cd5c3..788bf6617 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -126,6 +126,14 @@ public class Main {
|
||||
@ -334,6 +334,47 @@ index 8f301b9..2cafdb8 100644
|
||||
}
|
||||
};
|
||||
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index fd859f1a6..be003ce65 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -39,31 +39,31 @@ public class SpigotWorldConfig
|
||||
config.set( "world-settings.default." + path, val );
|
||||
}
|
||||
|
||||
- private boolean getBoolean(String path, boolean def)
|
||||
+ public boolean getBoolean(String path, boolean def)
|
||||
{
|
||||
config.addDefault( "world-settings.default." + path, def );
|
||||
return config.getBoolean( "world-settings." + worldName + "." + path, config.getBoolean( "world-settings.default." + path ) );
|
||||
}
|
||||
|
||||
- private double getDouble(String path, double def)
|
||||
+ public double getDouble(String path, double def)
|
||||
{
|
||||
config.addDefault( "world-settings.default." + path, def );
|
||||
return config.getDouble( "world-settings." + worldName + "." + path, config.getDouble( "world-settings.default." + path ) );
|
||||
}
|
||||
|
||||
- private int getInt(String path, int def)
|
||||
+ public int getInt(String path, int def)
|
||||
{
|
||||
config.addDefault( "world-settings.default." + path, def );
|
||||
return config.getInt( "world-settings." + worldName + "." + path, config.getInt( "world-settings.default." + path ) );
|
||||
}
|
||||
|
||||
- private <T> List getList(String path, T def)
|
||||
+ public <T> List getList(String path, T def)
|
||||
{
|
||||
config.addDefault( "world-settings.default." + path, def );
|
||||
return (List<T>) config.getList( "world-settings." + worldName + "." + path, config.getList( "world-settings.default." + path ) );
|
||||
}
|
||||
|
||||
- private String getString(String path, String def)
|
||||
+ public String getString(String path, String def)
|
||||
{
|
||||
config.addDefault( "world-settings.default." + path, def );
|
||||
return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) );
|
||||
--
|
||||
2.9.3
|
||||
2.11.0
|
||||
|
||||
|
60
Spigot-Server-Patches/0209-Cap-Entity-Collisions.patch
Normal file
60
Spigot-Server-Patches/0209-Cap-Entity-Collisions.patch
Normal file
@ -0,0 +1,60 @@
|
||||
From 0c2554509dd07cb7f7218cbbbd604c320fd5fba8 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 e8762c487..dba1c477e 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -414,4 +414,10 @@ public class PaperWorldConfig {
|
||||
private void armorStandEntityLookups() {
|
||||
armorStandEntityLookups = getBoolean("armor-stands-do-collision-entity-lookups", true);
|
||||
}
|
||||
+
|
||||
+ 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/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index a1d2233ba..37dc29f63 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -168,6 +168,7 @@ public abstract class Entity implements ICommandListener {
|
||||
public final boolean defaultActivationState;
|
||||
public long activatedTick = Integer.MIN_VALUE;
|
||||
public boolean fromMobSpawner;
|
||||
+ protected int numCollisions = 0; // Paper
|
||||
public void inactiveTick() { }
|
||||
// Spigot end
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index 07688b1ce..6ac6a4062 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -2132,8 +2132,11 @@ public abstract class EntityLiving extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
- for (j = 0; j < list.size(); ++j) {
|
||||
+ numCollisions = Math.max(0, numCollisions - world.paperConfig.maxCollisionsPerEntity); // Paper
|
||||
+ for (j = 0; j < list.size() && numCollisions < world.paperConfig.maxCollisionsPerEntity; ++j) { // Paper
|
||||
Entity entity = (Entity) list.get(j);
|
||||
+ entity.numCollisions++; // Paper
|
||||
+ numCollisions++; // Paper
|
||||
|
||||
this.C(entity);
|
||||
}
|
||||
--
|
||||
2.11.0
|
||||
|
Loading…
Reference in New Issue
Block a user