0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/spigot.git synced 2024-11-21 22:06:13 +00:00
spigot/CraftBukkit-Patches/0063-Limit-TNT-Detonations-per-tick.patch
2024-10-23 02:15:00 +11:00

56 lines
2.5 KiB
Diff

From ef218d51b31e6499b46d5802513105ae009965e1 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/world/entity/item/EntityTNTPrimed.java b/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
index 819a6013ba..7eda81dd3b 100644
--- a/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
@@ -101,6 +101,7 @@ public class EntityTNTPrimed extends Entity implements TraceableEntity {
@Override
public void tick() {
+ if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot
this.handlePortal();
this.applyGravity();
this.move(EnumMoveType.SELF, this.getDeltaMovement());
diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
index a9dc7b9f1d..dd710c0635 100644
--- a/src/main/java/net/minecraft/world/level/World.java
+++ b/src/main/java/net/minecraft/world/level/World.java
@@ -663,6 +663,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
timings.tileEntityTick.stopTiming(); // Spigot
this.tickingBlockEntities = false;
gameprofilerfiller.pop();
+ spigotConfig.currentPrimedTnt = 0; // Spigot
}
public <T extends Entity> void guardEntityTick(Consumer<T> consumer, T t0) {
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 1b5d1e2837..8411f9e573 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -356,4 +356,15 @@ public class SpigotWorldConfig
sprintMultiplier = (float) getDouble( "hunger.sprint-multiplier", 0.1 );
otherMultiplier = (float) getDouble( "hunger.other-multiplier", 0.0 );
}
+
+ 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.47.0