mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
55 lines
2.5 KiB
Diff
55 lines
2.5 KiB
Diff
From b13c291847ac1dea1bc32a3892541b0d367512cb 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 44d2d9a9e..b251099c0 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
|
@@ -104,6 +104,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 2c19f8801..891bb1ab3 100644
|
|
--- a/src/main/java/net/minecraft/world/level/World.java
|
|
+++ b/src/main/java/net/minecraft/world/level/World.java
|
|
@@ -666,6 +666,7 @@ public abstract class World implements GeneratorAccess, UUIDLookup<Entity>, Auto
|
|
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 1b5d1e283..8411f9e57 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.49.0
|
|
|