(Lithium) entity.fast_retrieval
This commit is contained in:
@@ -1,109 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Etil <81570777+etil2jz@users.noreply.github.com>
|
||||
Date: Sat, 18 Sep 2021 18:48:42 +0200
|
||||
Subject: [PATCH] Add nspt command
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index edb0bcfed9d83c4d7624a28f343dd614e5ab3b3b..70f022bc9cc834f84304b731b131f4df19aa0ef5 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -942,6 +942,7 @@ public final class CraftServer implements Server {
|
||||
this.reloadData();
|
||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||
com.destroystokyo.paper.PaperConfig.registerCommands(); // Paper
|
||||
+ xyz.arthurb.mirai.MiraiConfig.registerCommands(); // Mirai
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
|
||||
diff --git a/src/main/java/xyz/arthurb/mirai/MiraiConfig.java b/src/main/java/xyz/arthurb/mirai/MiraiConfig.java
|
||||
index 50392b3056d1cc10d9c59353bfa8edda3bab85f4..dbc91e0f22114860b453f0fce805c84587f46f63 100644
|
||||
--- a/src/main/java/xyz/arthurb/mirai/MiraiConfig.java
|
||||
+++ b/src/main/java/xyz/arthurb/mirai/MiraiConfig.java
|
||||
@@ -72,7 +72,7 @@ public class MiraiConfig {
|
||||
|
||||
public static void registerCommands() {
|
||||
for (Map.Entry<String, Command> entry : commands.entrySet()) {
|
||||
- MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Paper", entry.getValue());
|
||||
+ MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Mirai", entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,5 +204,10 @@ public class MiraiConfig {
|
||||
private static void protocolLib() {
|
||||
fixProtocolLib = getBoolean("settings.fix-protocollib", fixProtocolLib);
|
||||
}
|
||||
+
|
||||
+ static {
|
||||
+ commands = new HashMap<>();
|
||||
+ commands.put("nspt", new NSPTCommand("nspt"));
|
||||
+ }
|
||||
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/xyz/arthurb/mirai/server/NSPTCommand.java b/src/main/java/xyz/arthurb/mirai/server/NSPTCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1ef61928596a2486e614019b3b0e751796878fac
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/xyz/arthurb/mirai/server/NSPTCommand.java
|
||||
@@ -0,0 +1,59 @@
|
||||
+package xyz.arthurb.mirai.server;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.ChatColor;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+
|
||||
+public class NSPTCommand extends Command {
|
||||
+
|
||||
+ public NSPTCommand(String name) {
|
||||
+ super(name);
|
||||
+ this.description = "View server tick times in nanoseconds";
|
||||
+ this.usageMessage = "/nspt";
|
||||
+ this.setPermission("bukkit.command.nspt");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||
+ if (!testPermission(sender)) return true;
|
||||
+
|
||||
+ MinecraftServer server = MinecraftServer.getServer();
|
||||
+
|
||||
+ List<String> times = new ArrayList<>();
|
||||
+ times.addAll(eval(server.tickTimes5s.getTimes()));
|
||||
+ times.addAll(eval(server.tickTimes10s.getTimes()));
|
||||
+ times.addAll(eval(server.tickTimes60s.getTimes()));
|
||||
+
|
||||
+ sender.sendMessage("§6Server tick NS times §e(§7avg§e/§7min§e/§7max§e)§6 from last 5s§7,§6 10s§7,§6 1m§e:");
|
||||
+ sender.sendMessage(String.format("§6◴ %s§7/%s§7/%s§e, %s§7/%s§7/%s§e, %s§7/%s§7/%s", times.toArray()));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ private static List<String> eval(long[] times) {
|
||||
+ long min = Integer.MAX_VALUE;
|
||||
+ long max = 0L;
|
||||
+ long total = 0L;
|
||||
+ for (long value : times) {
|
||||
+ if (value > 0L && value < min) min = value;
|
||||
+ if (value > max) max = value;
|
||||
+ total += value;
|
||||
+ }
|
||||
+ double avgD = ((double) total / (double) times.length);
|
||||
+ return Arrays.asList(getColor(avgD), getColor(min), getColor(max));
|
||||
+ }
|
||||
+
|
||||
+ private static String getColor(double avg) {
|
||||
+ return ChatColor.COLOR_CHAR + (avg >= 5E+7 ? "c" : avg >= (4E+7) ? "e" : "a") + avg;
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
57
patches/server/0013-Lithium-entity.fast_retrieval.patch
Normal file
57
patches/server/0013-Lithium-entity.fast_retrieval.patch
Normal file
@@ -0,0 +1,57 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Etil <81570777+etil2jz@users.noreply.github.com>
|
||||
Date: Sat, 18 Sep 2021 19:01:26 +0200
|
||||
Subject: [PATCH] (Lithium) entity.fast_retrieval
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java b/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java
|
||||
index 24552500307c42f9f3dc5c4d9ba73a84a787423a..fb572ccd5f2058e1e6ccb6e745e9ad71025c8998 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java
|
||||
@@ -34,31 +34,26 @@ public class EntitySectionStorage<T extends EntityAccess> {
|
||||
}
|
||||
|
||||
public void forEachAccessibleSection(AABB box, Consumer<EntitySection<T>> action) {
|
||||
- int i = SectionPos.posToSectionCoord(box.minX - 2.0D);
|
||||
- int j = SectionPos.posToSectionCoord(box.minY - 2.0D);
|
||||
- int k = SectionPos.posToSectionCoord(box.minZ - 2.0D);
|
||||
- int l = SectionPos.posToSectionCoord(box.maxX + 2.0D);
|
||||
- int m = SectionPos.posToSectionCoord(box.maxY + 2.0D);
|
||||
- int n = SectionPos.posToSectionCoord(box.maxZ + 2.0D);
|
||||
-
|
||||
- for(int o = i; o <= l; ++o) {
|
||||
- long p = SectionPos.asLong(o, 0, 0);
|
||||
- long q = SectionPos.asLong(o, -1, -1);
|
||||
- LongIterator longIterator = this.sectionIds.subSet(p, q + 1L).iterator();
|
||||
-
|
||||
- while(longIterator.hasNext()) {
|
||||
- long r = longIterator.nextLong();
|
||||
- int s = SectionPos.y(r);
|
||||
- int t = SectionPos.z(r);
|
||||
- if (s >= j && s <= m && t >= k && t <= n) {
|
||||
- EntitySection<T> entitySection = this.sections.get(r);
|
||||
- if (entitySection != null && entitySection.getStatus().isAccessible()) {
|
||||
- action.accept(entitySection);
|
||||
+ // Yatopia start - port lithium
|
||||
+ int minX = SectionPos.posToSectionCoord(box.minX - 2.0D);
|
||||
+ int minY = SectionPos.posToSectionCoord(box.minY - 2.0D);
|
||||
+ int minZ = SectionPos.posToSectionCoord(box.minZ - 2.0D);
|
||||
+ int maxX = SectionPos.posToSectionCoord(box.maxX + 2.0D);
|
||||
+ int maxY = SectionPos.posToSectionCoord(box.maxY + 2.0D);
|
||||
+ int maxZ = SectionPos.posToSectionCoord(box.maxZ + 2.0D);
|
||||
+
|
||||
+ for (int x = minX; x <= maxX; x++) {
|
||||
+ for (int z = minZ; z <= maxZ; z++) {
|
||||
+ for (int y = minY; y <= maxY; y++) {
|
||||
+ EntitySection<T> section = this.getSection(SectionPos.asLong(x, y, z));
|
||||
+ if (section != null && section.getStatus().isAccessible()) {
|
||||
+ action.accept(section);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ // Yatopia end
|
||||
}
|
||||
|
||||
public LongStream getExistingSectionPositionsInChunk(long chunkPos) {
|
||||
Reference in New Issue
Block a user