From 5f6696885dc2acba7590aad4f09b171a099d88e0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 10 Apr 2023 21:15:09 +0200 Subject: [PATCH] Add 400 tnt test Signed-off-by: yoyosource --- .../features/simulator/Simulator19.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/Simulator19.java b/BauSystem_19/src/de/steamwar/bausystem/features/simulator/Simulator19.java index 96a8d382..2c0bb8eb 100644 --- a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/Simulator19.java +++ b/BauSystem_19/src/de/steamwar/bausystem/features/simulator/Simulator19.java @@ -27,10 +27,7 @@ import org.bukkit.util.BoundingBox; import org.bukkit.util.Vector; import org.bukkit.util.VoxelShape; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; +import java.util.*; public class Simulator19 implements Simulator { @@ -42,11 +39,23 @@ public class Simulator19 implements Simulator { @Override public synchronized void run() { - TNT tnt = new TNT(0, 120, 0); - do { - System.out.println(tnt); - } while (!tnt.tick()); - System.out.println(tnt); + List tntList = new ArrayList<>(); + for (int i = 0; i < 400; i++) { + tntList.add(new TNT(0, 120, 0)); + } + long time = System.currentTimeMillis(); + while (!tntList.isEmpty()) { + List remove = new ArrayList<>(); + for (TNT tnt : tntList) { + if (tnt.getFuse() == 0) { + remove.add(tnt); + continue; + } + tnt.tick(); + } + tntList.removeAll(remove); + } + System.out.println("Time: " + (System.currentTimeMillis() - time) + "ms"); BLOCK_TYPES_MAP.clear(); BLOCK_DATA_MAP.clear();