From d966cfec69e14adf9c0cfb56f49bce731977ef8f Mon Sep 17 00:00:00 2001 From: Aikar 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 index 10f6e47..2d22327 100644 --- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java +++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java @@ -41,6 +41,7 @@ public class EntityTNTPrimed extends Entity { } public void t_() { + if (world.spigotConfig.currentPrimedTnt++ > world.spigotConfig.maxTntTicksPerTick) { return; } // Spigot this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 65f13be..d76b965 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -595,6 +595,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { } super.tickEntities(); + spigotConfig.currentPrimedTnt = 0; // Spigot } public void j() { diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java index 0f9b67c..e2d673f 100644 --- a/src/main/java/org/spigotmc/SpigotWorldConfig.java +++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java @@ -315,4 +315,15 @@ public class SpigotWorldConfig combatExhaustion = (float) getDouble( "hunger.combat-exhaustion", 0.3 ); regenExhaustion = (float) getDouble( "hunger.regen-exhaustion", 3 ); } + + public int currentPrimedTnt = 0; + public int maxTntTicksPerTick; + private void maxTntPerTick() { + if ( SpigotConfig.version < 7 ) + { + set( "max-tnt-per-tick", 100 ); + } + maxTntTicksPerTick = getInt( "max-tnt-per-tick", 100 ); + log( "Max TNT Explosions: " + maxTntTicksPerTick ); + } } -- 2.1.4