2023-06-24 17:19:51 +10:00
|
|
|
From f2a9cd376636209d6f4384798f3aded96bcc5e9b 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.
|
|
|
|
|
2021-03-16 09:00:00 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java b/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
2023-06-24 17:19:51 +10:00
|
|
|
index 1bae42cf5..9cf5994f7 100644
|
2021-03-16 09:00:00 +11:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
2023-06-24 17:19:51 +10:00
|
|
|
@@ -64,6 +64,7 @@ public class EntityTNTPrimed extends Entity implements TraceableEntity {
|
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() {
|
2023-06-08 01:30:00 +10:00
|
|
|
+ if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot
|
2019-12-11 09:00:00 +11:00
|
|
|
if (!this.isNoGravity()) {
|
2021-11-22 09:00:00 +11:00
|
|
|
this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D));
|
2019-12-11 09:00:00 +11:00
|
|
|
}
|
2021-03-16 09:00:00 +11:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
|
2023-06-08 01:30:00 +10:00
|
|
|
index c33143811..15e63dbfa 100644
|
2021-03-16 09:00:00 +11:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/World.java
|
2023-06-08 01:30:00 +10:00
|
|
|
@@ -660,6 +660,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2021-06-11 15:00:00 +10:00
|
|
|
timings.tileEntityTick.stopTiming(); // Spigot
|
|
|
|
this.tickingBlockEntities = false;
|
2021-11-22 09:00:00 +11:00
|
|
|
gameprofilerfiller.pop();
|
2014-08-20 19:15:59 -04:00
|
|
|
+ spigotConfig.currentPrimedTnt = 0; // Spigot
|
|
|
|
}
|
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
public <T extends Entity> void guardEntityTick(Consumer<T> consumer, T t0) {
|
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
|
2023-04-15 09:51:47 +10:00
|
|
|
index 1b5d1e283..8411f9e57 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
|
2023-04-15 09:51:47 +10:00
|
|
|
@@ -356,4 +356,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 );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2023-06-24 17:19:51 +10:00
|
|
|
2.41.0
|
2014-08-20 19:15:59 -04:00
|
|
|
|