2021-03-09 08:47:45 +11:00
|
|
|
From c6272bc65162e0d80af742d30f22b65d1f0ecf92 Mon Sep 17 00:00:00 2001
|
2014-08-20 19:15:59 -04:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Wed, 20 Aug 2014 18:12:32 -0400
|
|
|
|
Subject: [PATCH] Limit TNT Detonations per tick
|
|
|
|
|
|
|
|
This gives a per-world control on how much TNT will be processed per-tick,
|
|
|
|
preventing a massive TNT detonation from lagging out the server.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
2021-03-09 08:47:45 +11:00
|
|
|
index 5d254dff9..7064fd8e8 100644
|
2014-08-20 19:15:59 -04:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
2021-03-09 08:47:45 +11:00
|
|
|
@@ -49,6 +49,7 @@ public class EntityTNTPrimed extends Entity {
|
2014-08-20 19:15:59 -04:00
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
@Override
|
2018-07-15 10:00:00 +10:00
|
|
|
public void tick() {
|
2014-08-20 19:15:59 -04:00
|
|
|
+ if (world.spigotConfig.currentPrimedTnt++ > world.spigotConfig.maxTntTicksPerTick) { return; } // Spigot
|
2019-12-11 09:00:00 +11:00
|
|
|
if (!this.isNoGravity()) {
|
|
|
|
this.setMot(this.getMot().add(0.0D, -0.04D, 0.0D));
|
|
|
|
}
|
2019-04-23 12:00:00 +10:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2021-01-31 10:08:46 +11:00
|
|
|
index da0c3ed28..b87b7de2e 100644
|
2019-04-23 12:00:00 +10:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2021-01-31 10:08:46 +11:00
|
|
|
@@ -695,6 +695,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2014-08-20 19:15:59 -04:00
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
timings.tileEntityPending.stopTiming(); // Spigot
|
|
|
|
gameprofilerfiller.exit();
|
2014-08-20 19:15:59 -04:00
|
|
|
+ spigotConfig.currentPrimedTnt = 0; // Spigot
|
|
|
|
}
|
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
public void a(Consumer<Entity> consumer, Entity entity) {
|
2014-08-20 19:15:59 -04:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2021-01-31 10:08:46 +11:00
|
|
|
index 848a06605..0043a13a0 100644
|
2014-08-20 19:15:59 -04:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2020-06-25 10:00:00 +10:00
|
|
|
@@ -333,4 +333,15 @@ public class SpigotWorldConfig
|
2016-11-26 11:51:14 +11:00
|
|
|
sprintMultiplier = (float) getDouble( "hunger.sprint-multiplier", 0.1 );
|
|
|
|
otherMultiplier = (float) getDouble( "hunger.other-multiplier", 0.0 );
|
2014-08-20 19:15:59 -04:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public int currentPrimedTnt = 0;
|
|
|
|
+ public int maxTntTicksPerTick;
|
|
|
|
+ private void maxTntPerTick() {
|
2014-08-24 14:25:58 +10:00
|
|
|
+ if ( SpigotConfig.version < 7 )
|
|
|
|
+ {
|
|
|
|
+ set( "max-tnt-per-tick", 100 );
|
|
|
|
+ }
|
|
|
|
+ maxTntTicksPerTick = getInt( "max-tnt-per-tick", 100 );
|
2014-08-20 19:15:59 -04:00
|
|
|
+ log( "Max TNT Explosions: " + maxTntTicksPerTick );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2020-05-09 18:48:11 +10:00
|
|
|
2.25.1
|
2014-08-20 19:15:59 -04:00
|
|
|
|