3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 21:10:17 +01:00
Paper/CraftBukkit-Patches/0154-Limit-TNT-Detonations-per-tick.patch

56 Zeilen
2.2 KiB
Diff

From ff0f3082ea5c282ddcaa8411a95b5e4d4e813154 Mon Sep 17 00:00:00 2001
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
2014-11-28 02:17:45 +01:00
index 98c8d26..3621faf 100644
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
2014-11-28 02:17:45 +01:00
@@ -41,6 +41,7 @@ public class EntityTNTPrimed extends Entity {
}
2014-11-28 02:17:45 +01:00
public void s_() {
+ 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 8b4278f..c6e8321 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
2014-11-28 02:17:45 +01:00
@@ -575,6 +575,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
}
super.tickEntities();
+ spigotConfig.currentPrimedTnt = 0; // Spigot
}
2014-11-28 02:17:45 +01:00
public void j() {
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
2014-11-28 02:17:45 +01:00
index 3f145b3..46377ab 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -338,4 +338,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 );
+ }
}
--
2014-11-28 02:17:45 +01:00
2.1.0