mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
55 lines
2.4 KiB
Diff
55 lines
2.4 KiB
Diff
From c3b4c3f991c5005efd9fc21cc2d568d597ec5252 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 dce854ccc..a3ced6037 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
|
@@ -63,6 +63,7 @@ public class EntityTNTPrimed extends Entity {
|
|
|
|
@Override
|
|
public void tick() {
|
|
+ if (level.spigotConfig.currentPrimedTnt++ > level.spigotConfig.maxTntTicksPerTick) { return; } // Spigot
|
|
if (!this.isNoGravity()) {
|
|
this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
|
|
index a9a545d61..d8ed48c9c 100644
|
|
--- a/src/main/java/net/minecraft/world/level/World.java
|
|
+++ b/src/main/java/net/minecraft/world/level/World.java
|
|
@@ -680,6 +680,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 044f54992..ac05bf0fe 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
@@ -346,4 +346,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.25.1
|
|
|