Browse Source

block set speed test command

Kajetan Johannes Hammerle 3 years ago
parent
commit
6d9f2a525c
1 changed files with 40 additions and 0 deletions
  1. 40 0
      src/me/hammerle/kp/snuviscript/CommandTest.java

+ 40 - 0
src/me/hammerle/kp/snuviscript/CommandTest.java

@@ -1,7 +1,13 @@
 package me.hammerle.kp.snuviscript;
 
 import java.util.List;
+import org.bukkit.Location;
+import org.bukkit.Material;
 import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import me.hammerle.kp.NMS;
+import net.minecraft.core.BlockPosition;
+import net.minecraft.world.level.block.Blocks;
 
 public class CommandTest extends KajetanCommand {
     public static boolean noEvents = false;
@@ -17,6 +23,7 @@ public class CommandTest extends KajetanCommand {
         sendListMessage(cs, "event", "toggle the usage of events");
         sendListMessage(cs, "tick", "toggle the usage of the tick");
         sendListMessage(cs, "status", "see the status");
+        sendListMessage(cs, "block", "tests block sets");
     }
 
     @Override
@@ -60,6 +67,39 @@ public class CommandTest extends KajetanCommand {
                 sendMessage(cs, "Tick: " + !noTick);
                 return;
             }
+            case "block": {
+                if(!(cs instanceof Player)) {
+                    sendMessage(cs, "Must be performed by a player.");
+                    return;
+                }
+                Player p = (Player) cs;
+                Location l = p.getLocation();
+                Location l2 = l.clone().add(1, 0, 0);
+                Location l3 = l.clone().add(-1, 0, 0);
+
+                long time = -System.nanoTime();
+                l.getBlock().setType(Material.STONE);
+                l2.getBlock().setType(Material.STONE);
+                l3.getBlock().setType(Material.STONE);
+                time += System.nanoTime();
+
+                sendMessage(cs, String.format("Paper: %.4f ms per set", time / 3_000_000.0));
+
+
+
+                time = -System.nanoTime();
+                var w = NMS.map(p.getWorld());
+                int x = l.getBlockX();
+                int y = l.getBlockY();
+                int z = l.getBlockZ();
+                w.a(new BlockPosition(x + 1, y, z + 2), Blocks.b.n(), 3);
+                w.a(new BlockPosition(x, y, z + 2), Blocks.b.n(), 3);
+                w.a(new BlockPosition(x - 1, y, z + 2), Blocks.b.n(), 3);
+                time += System.nanoTime();
+
+                sendMessage(cs, String.format("NMS: %.4f ms per set", time / 3_000_000.0));
+                return;
+            }
         }
         printHelp(cs);
     }