yeet, part 01

This commit is contained in:
Riley Park 2024-07-21 03:26:33 -07:00
parent 38e61d072f
commit c250671fda
17 changed files with 66 additions and 216 deletions

View file

@ -699,20 +699,6 @@ index 0000000000000000000000000000000000000000..2f0d9b953802dee821cfde82d22b0567
+ return Timings.ofSafe(((PrimaryLevelData) worldserver.getLevelData()).getLevelName() + " - Scheduled " + timingsType);
+ }
+}
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
index f7197f1347251a37dd0f6d9ffa2f09bc3a4e1233..d0d36a57ec4896bcb74970f8fb24d8f3e17db133 100644
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
@@ -31,7 +31,8 @@ public class PacketUtils {
engine.executeIfPossible(() -> {
if (listener instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players
if (listener.shouldHandleMessage(packet)) {
- try {
+ co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(packet); // Paper - timings
+ try (co.aikar.timings.Timing ignored = timing.startTiming()) { // Paper - timings
packet.handle(listener);
} catch (Exception exception) {
if (exception instanceof ReportedException) {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 5a4cdbc4b92a48c614564e4e421f05a9eb5b072b..d76dae9ce9022308b316080ac48b7030d674cc6b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
@ -892,7 +878,7 @@ index 5a4cdbc4b92a48c614564e4e421f05a9eb5b072b..d76dae9ce9022308b316080ac48b7030
this.profiler.popPush("send chunks");
iterator = this.playerList.getPlayers().iterator();
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index d38ecbc208c34509eaf77751ac45d9ef51a5dce8..b51c3f8c485496734ea58c15377a1215a334c765 100644
index d38ecbc208c34509eaf77751ac45d9ef51a5dce8..1f8e693673f2579c9f2ca890e56074772377f5f4 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -65,10 +65,11 @@ import org.apache.logging.log4j.Level;
@ -908,76 +894,24 @@ index d38ecbc208c34509eaf77751ac45d9ef51a5dce8..b51c3f8c485496734ea58c15377a1215
import org.bukkit.event.server.RemoteServerCommandEvent;
// CraftBukkit end
@@ -439,7 +440,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -439,7 +440,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
}
public void handleConsoleInputs() {
- SpigotTimings.serverCommandTimer.startTiming(); // Spigot
+ MinecraftTimings.serverCommandTimer.startTiming(); // Spigot
while (!this.consoleInput.isEmpty()) {
ConsoleInput servercommand = (ConsoleInput) this.consoleInput.remove(0);
@@ -454,7 +455,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -454,7 +454,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
// CraftBukkit end
}
- SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
+ MinecraftTimings.serverCommandTimer.stopTiming(); // Spigot
}
@Override
@@ -712,7 +713,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
}
public String runCommand(RconConsoleSource rconConsoleSource, String s) {
+ Waitable[] waitableArray = new Waitable[1]; // Paper
rconConsoleSource.prepareForCommand();
+ final java.util.concurrent.atomic.AtomicReference<String> command = new java.util.concurrent.atomic.AtomicReference<>(s); // Paper
this.executeBlocking(() -> {
CommandSourceStack wrapper = rconConsoleSource.createCommandSourceStack();
RemoteServerCommandEvent event = new RemoteServerCommandEvent(rconConsoleSource.getBukkitSender(wrapper), s);
@@ -720,9 +723,39 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
if (event.isCancelled()) {
return;
}
+ // Paper start
+ command.set(event.getCommand());
+ if (event.getCommand().toLowerCase(java.util.Locale.ROOT).startsWith("timings") && event.getCommand().toLowerCase(java.util.Locale.ROOT).matches("timings (report|paste|get|merged|seperate)")) {
+ org.bukkit.command.BufferedCommandSender sender = new org.bukkit.command.BufferedCommandSender();
+ Waitable<String> waitable = new Waitable<>() {
+ @Override
+ protected String evaluate() {
+ return sender.getBuffer();
+ }
+ };
+ waitableArray[0] = waitable;
+ co.aikar.timings.Timings.generateReport(new co.aikar.timings.TimingsReportListener(sender, waitable));
+ } else {
+ // Paper end
ConsoleInput serverCommand = new ConsoleInput(event.getCommand(), wrapper);
this.server.dispatchServerCommand(event.getSender(), serverCommand);
+ } // Paper
});
+ // Paper start
+ if (waitableArray[0] != null) {
+ //noinspection unchecked
+ Waitable<String> waitable = waitableArray[0];
+ try {
+ return waitable.get();
+ } catch (java.util.concurrent.ExecutionException e) {
+ throw new RuntimeException("Exception processing rcon command " + command.get(), e.getCause());
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt(); // Maintain interrupted state
+ throw new RuntimeException("Interrupted processing rcon command " + command.get(), e);
+ }
+
+ }
+ // Paper end
return rconConsoleSource.getCommandResponse();
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 449608e60f3900778247101581ff598f1637499b..bb5115b3593c314f5edfb5947a3c35a489bf71af 100644
index 449608e60f3900778247101581ff598f1637499b..f774aacc6cae7fb893756b4af02f5b2fa797d850 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1,8 +1,10 @@
@ -991,34 +925,8 @@ index 449608e60f3900778247101581ff598f1637499b..bb5115b3593c314f5edfb5947a3c35a4
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import com.google.common.collect.Sets;
@@ -1296,6 +1298,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
List<ServerPlayer> list = Lists.newArrayList();
List<ServerPlayer> list1 = this.level.players();
ObjectIterator objectiterator = this.entityMap.values().iterator();
+ level.timings.tracker1.startTiming(); // Paper
ChunkMap.TrackedEntity playerchunkmap_entitytracker;
@@ -1320,14 +1323,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
playerchunkmap_entitytracker.serverEntity.sendChanges();
}
}
+ level.timings.tracker1.stopTiming(); // Paper
if (!list.isEmpty()) {
objectiterator = this.entityMap.values().iterator();
+ level.timings.tracker2.startTiming(); // Paper
while (objectiterator.hasNext()) {
playerchunkmap_entitytracker = (ChunkMap.TrackedEntity) objectiterator.next();
playerchunkmap_entitytracker.updatePlayers(list);
}
+ level.timings.tracker2.stopTiming(); // Paper
}
}
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index cf94dd9ddcc1eabcf3fd336e70720f4ed3e52175..e0c8b89767087cba34fc3c3809db4c386dacb193 100644
index cf94dd9ddcc1eabcf3fd336e70720f4ed3e52175..e48452401358996ff558a4788ebee51a1ec3ea13 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -195,13 +195,15 @@ public class ServerChunkCache extends ChunkSource {
@ -1039,49 +947,17 @@ index cf94dd9ddcc1eabcf3fd336e70720f4ed3e52175..e0c8b89767087cba34fc3c3809db4c38
ChunkResult<ChunkAccess> chunkresult = (ChunkResult) completablefuture.join();
ChunkAccess ichunkaccess1 = (ChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error
@@ -366,7 +368,9 @@ public class ServerChunkCache extends ChunkSource {
public void save(boolean flush) {
this.runDistanceManagerUpdates();
+ try (co.aikar.timings.Timing timed = level.timings.chunkSaveData.startTiming()) { // Paper - Timings
this.chunkMap.saveAllChunks(flush);
+ } // Paper - Timings
}
@Override
@@ -408,10 +412,10 @@ public class ServerChunkCache extends ChunkSource {
this.level.timings.doChunkMap.stopTiming(); // Spigot
@@ -409,9 +411,7 @@ public class ServerChunkCache extends ChunkSource {
this.level.getProfiler().popPush("chunks");
if (tickChunks) {
+ this.level.timings.chunks.startTiming(); // Paper - timings
this.tickChunks();
- this.level.timings.tracker.startTiming(); // Spigot
+ this.level.timings.chunks.stopTiming(); // Paper - timings
this.chunkMap.tick();
- this.level.timings.tracker.stopTiming(); // Spigot
}
this.level.timings.doChunkUnload.startTiming(); // Spigot
@@ -434,6 +438,7 @@ public class ServerChunkCache extends ChunkSource {
gameprofilerfiller.push("filteringLoadedChunks");
List<ServerChunkCache.ChunkAndHolder> list = Lists.newArrayListWithCapacity(this.chunkMap.size());
Iterator iterator = this.chunkMap.getChunks().iterator();
+ if (this.level.getServer().tickRateManager().runsNormally()) this.level.timings.chunkTicks.startTiming(); // Paper
while (iterator.hasNext()) {
ChunkHolder playerchunk = (ChunkHolder) iterator.next();
@@ -446,8 +451,10 @@ public class ServerChunkCache extends ChunkSource {
if (this.level.tickRateManager().runsNormally()) {
gameprofilerfiller.popPush("naturalSpawnCount");
+ this.level.timings.countNaturalMobs.startTiming(); // Paper - timings
int k = this.distanceManager.getNaturalSpawnChunkCount();
NaturalSpawner.SpawnState spawnercreature_d = NaturalSpawner.createState(k, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap));
+ this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings
this.lastSpawnState = spawnercreature_d;
gameprofilerfiller.popPush("spawnAndTick");
@@ -470,22 +477,25 @@ public class ServerChunkCache extends ChunkSource {
@@ -470,9 +470,7 @@ public class ServerChunkCache extends ChunkSource {
}
if (this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) {
@ -1091,24 +967,6 @@ index cf94dd9ddcc1eabcf3fd336e70720f4ed3e52175..e0c8b89767087cba34fc3c3809db4c38
}
}
}
+ this.level.timings.chunkTicks.stopTiming(); // Paper
gameprofilerfiller.popPush("customSpawners");
if (flag) {
+ try (co.aikar.timings.Timing ignored = this.level.timings.miscMobSpawning.startTiming()) { // Paper - timings
this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies);
+ } // Paper - timings
}
}
gameprofilerfiller.popPush("broadcast");
list.forEach((chunkproviderserver_a1) -> {
+ this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
chunkproviderserver_a1.holder.broadcastChanges(chunkproviderserver_a1.chunk);
+ this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
});
gameprofilerfiller.pop();
gameprofilerfiller.pop();
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 4c39d9e0466240b5cd459ee649a22fe3a72bf9f0..eb98bb1bd76869fd76b34885223c8e57a04e0c51 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Add setting for proxy online mode status
TODO: Add isProxyOnlineMode check to Metrics
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index c1f41dcf49c75c3d69485c0e1ec821205438ed1e..c466ec011d059b9960606ef2ee51ea3a3a65f8d0 100644
index b7e664a4319c3f0062b0afea38d852b25e19aacd..39533954a361529878cf62db382604d7fb4998d8 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -593,7 +593,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -591,7 +591,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
public boolean enforceSecureProfile() {
DedicatedServerProperties dedicatedserverproperties = this.getProperties();

View file

@ -9,7 +9,7 @@ from triggering monster spawns on a server.
Also a highly more effecient way to blanket block spawns in a world
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d60c70d59d0a6ef21224c597c9015cb3f51dabb8..63bcd7698fdb86366441dacedbb616771f6b1a3d 100644
index f774aacc6cae7fb893756b4af02f5b2fa797d850..e0aa654e8034c21a057140097a34a8b42681b097 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1037,7 +1037,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -40,10 +40,10 @@ index d60c70d59d0a6ef21224c597c9015cb3f51dabb8..63bcd7698fdb86366441dacedbb61677
return true;
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index e0c8b89767087cba34fc3c3809db4c386dacb193..a939bad7da9c852827a2d67d9ace5d0df4911a31 100644
index e48452401358996ff558a4788ebee51a1ec3ea13..aaf5a1683e414437355c990552ebf94e4f8196df 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -461,6 +461,15 @@ public class ServerChunkCache extends ChunkSource {
@@ -454,6 +454,15 @@ public class ServerChunkCache extends ChunkSource {
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
Util.shuffle(list, this.level.random);

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Use a Queue for Queueing Commands
Lists are bad as Queues mmmkay.
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index baf93b5d5883d0a5c360f1a475949804b7907636..b15cee6f21ff300b596922a8eed35a5f8a89fe22 100644
index 4a5c2e7543ece634bd42f6557882004bddc3bbff..77d903d6c91794969c3238bafbedd5bf9a9701a9 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -78,7 +78,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@ -18,7 +18,7 @@ index baf93b5d5883d0a5c360f1a475949804b7907636..b15cee6f21ff300b596922a8eed35a5f
@Nullable
private QueryThreadGs4 queryThreadGs4;
// private final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
@@ -438,13 +438,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -438,12 +438,14 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
}
public void handleConsoleInput(String command, CommandSourceStack commandSource) {
@ -27,7 +27,6 @@ index baf93b5d5883d0a5c360f1a475949804b7907636..b15cee6f21ff300b596922a8eed35a5f
}
public void handleConsoleInputs() {
MinecraftTimings.serverCommandTimer.startTiming(); // Spigot
- while (!this.consoleInput.isEmpty()) {
- ConsoleInput servercommand = (ConsoleInput) this.consoleInput.remove(0);
+ // Paper start - Perf: use proper queue

View file

@ -8,10 +8,10 @@ Sets tracking range of watermobs to animals instead of misc and simplifies code
Also ignores Enderdragon, defaulting it to Mojang's setting
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index a58a68220e077ce23c20cf61d63f51183df1dfc9..6159ab8831a233c21aad48c64ef76b06c1955bb0 100644
index ee8ccf6afef2b2c563ba4f55fa679c4bca48a0f1..4e09c3ae08c6b59c64ce1836653391f7c75e8ee6 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1546,6 +1546,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1542,6 +1542,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
int j = entity.getType().clientTrackingRange() * 16;

View file

@ -7,10 +7,10 @@ Reference2BooleanOpenHashMap is going to have
better lookups than HashMap.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index bac8e53cab360142f224965e68d8f9e6ae0c15f6..b953def299faf1a13e1893d17a476f36e2d6337a 100644
index 86fb188ae93b9ebfea49c4d683ff015a3b42abaa..b0fd8751d0c76ee95b19bf19a7d023a4658b15db 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1462,7 +1462,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1458,7 +1458,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final Entity entity;
private final int range;
SectionPos lastSectionPos;

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Player Entity Tracking Events
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d409791325771909faaef0dffb0f7f02d1bf71af..ca98b4c405afc2d86085759ba50d02eba75784a7 100644
index 182d50c422e506859a6eecdb71d33038142406d9..233bb6263fbae1ba79cecf72c637b0e515b39656 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1534,7 +1534,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1530,7 +1530,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// CraftBukkit end
if (flag) {
if (this.seenBy.add(player.connection)) {
@ -21,7 +21,7 @@ index d409791325771909faaef0dffb0f7f02d1bf71af..ca98b4c405afc2d86085759ba50d02eb
} else if (this.seenBy.remove(player.connection)) {
this.serverEntity.removePairing(player);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 82531bd4ada8373d3c255758382d5850309913e2..f52d394c90bc326c2a58c4f623df632235e0c599 100644
index f73eca786ca0dde5254c5941cf37739dc65ad81c..fe70fec5d2d422ea9be18e6d5af377f13090ff73 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3869,7 +3869,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Configurable entity tracking range by Y coordinate
Options to configure entity tracking by Y coordinate, also for each entity category.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index ca98b4c405afc2d86085759ba50d02eba75784a7..51c6f20a7402ff3809c8b7690fa4651eee0304cd 100644
index 233bb6263fbae1ba79cecf72c637b0e515b39656..6e15348c364dbe90905ae7a7ef8c1107ebaece14 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1526,6 +1526,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1522,6 +1522,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
double d1 = vec3d.x * vec3d.x + vec3d.z * vec3d.z;
double d2 = d0 * d0;
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z);

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Don't check if we can see non-visible entities
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 51c6f20a7402ff3809c8b7690fa4651eee0304cd..d4cc6d189cda03ea8e5d44af0608f914078f7e6e 100644
index 6e15348c364dbe90905ae7a7ef8c1107ebaece14..e153e42ef50ba7c5b5674c3e1524e332425e813a 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1537,7 +1537,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1533,7 +1533,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end - Configurable entity tracking range by Y
// CraftBukkit start - respect vanish API

View file

@ -18,10 +18,10 @@ index a043ac10834562d357ef0b5aded2e916e2a0d056..74276c368016fcc4dbf9579b2ecbadc9
@VisibleForTesting
static long encode(double value) {
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d4cc6d189cda03ea8e5d44af0608f914078f7e6e..7f287127faf1d3a6b4b0f77800964b327ca9123f 100644
index e153e42ef50ba7c5b5674c3e1524e332425e813a..34d7f79237c23111a91f7c5960799e4034de0352 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1520,10 +1520,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1516,10 +1516,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public void updatePlayer(ServerPlayer player) {
org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot
if (player != this.entity) {

View file

@ -22657,7 +22657,7 @@ index c97fb8eec949c693d4e822d8cf2e666a0858f20c..4a4ce372dd105d07f58d7d93d856cb39
public boolean isDebugging() {
return false;
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 0761d5bc5f2813bb4a9f664ac7a05b9744d0a778..7d2896918ff5fed37e5de5a22c37b0c7f32634a8 100644
index 22519b6f5bbf0e29e204b3c8bed5b9f81f44417a..ccfd2c6df3657ff53187a377f573d5f0a182ae4f 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -476,7 +476,33 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@ -23191,7 +23191,7 @@ index d9ad32acdf46a43a649334a3b736aeb7b3af21d1..fae17a075d7efaf24d916877dd5968eb
public static final int RADIUS_AROUND_FULL_CHUNK = FULL_CHUNK_STEP.accumulatedDependencies().getRadius();
public static final int MAX_LEVEL = 33 + RADIUS_AROUND_FULL_CHUNK;
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index ee597f2393c88473a72da941169e0f99c13da6ea..f6c090513f9dcc75e04e8e5b347c27f8d4d713cc 100644
index 34d7f79237c23111a91f7c5960799e4034de0352..9d38391720537fc114a00d5f5c34f734cd8c8fc3 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -122,10 +122,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -24172,7 +24172,7 @@ index ee597f2393c88473a72da941169e0f99c13da6ea..f6c090513f9dcc75e04e8e5b347c27f8
List<ServerPlayer> list = Lists.newArrayList();
List<ServerPlayer> list1 = this.level.players();
@@ -1420,27 +1026,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1416,27 +1022,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
public void waitForLightBeforeSending(ChunkPos centerPos, int radius) {
@ -24210,7 +24210,7 @@ index ee597f2393c88473a72da941169e0f99c13da6ea..f6c090513f9dcc75e04e8e5b347c27f8
}
@Nullable
@@ -1456,7 +1060,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1452,7 +1056,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
}
@ -24219,7 +24219,7 @@ index ee597f2393c88473a72da941169e0f99c13da6ea..f6c090513f9dcc75e04e8e5b347c27f8
public final ServerEntity serverEntity;
final Entity entity;
@@ -1464,6 +1068,84 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1460,6 +1064,84 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
SectionPos lastSectionPos;
public final Set<ServerPlayerConnection> seenBy = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); // Paper - Perf: optimise map impl
@ -25089,7 +25089,7 @@ index 3dc1daa3c6a04d3ff1a2353773b465fc380994a2..3575782f13a7f3c52e64dc5046803305
}
}
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 60f678c26fb5144386d8697ddfd5b6d841563b6f..17fafa62f21e505f9f77cf486f7f766a404f7c31 100644
index 43bee0018fac84e05d4c63dc703cdd09938f0002..564abf2edec3a355070954947d5793575ac3d336 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -46,7 +46,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
@ -25198,14 +25198,14 @@ index 60f678c26fb5144386d8697ddfd5b6d841563b6f..17fafa62f21e505f9f77cf486f7f766a
-
- gameprofilerfiller.incrementCounter("getChunk");
- long k = ChunkPos.asLong(x, z);
-
- for (int l = 0; l < 4; ++l) {
- if (k == this.lastChunkPos[l] && leastStatus == this.lastChunkStatus[l]) {
- ChunkAccess ichunkaccess = this.lastChunk[l];
+ // Paper start - rewrite chunk system
+ if (leastStatus == ChunkStatus.FULL) {
+ final LevelChunk ret = this.fullChunks.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(x, z));
- for (int l = 0; l < 4; ++l) {
- if (k == this.lastChunkPos[l] && leastStatus == this.lastChunkStatus[l]) {
- ChunkAccess ichunkaccess = this.lastChunk[l];
-
- if (ichunkaccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime
- return ichunkaccess;
- }
@ -25383,10 +25383,10 @@ index 60f678c26fb5144386d8697ddfd5b6d841563b6f..17fafa62f21e505f9f77cf486f7f766a
public void save(boolean flush) {
- this.runDistanceManagerUpdates();
+ // Paper - rewrite chunk system
try (co.aikar.timings.Timing timed = level.timings.chunkSaveData.startTiming()) { // Paper - Timings
this.chunkMap.saveAllChunks(flush);
} // Paper - Timings
@@ -361,12 +368,7 @@ public class ServerChunkCache extends ChunkSource {
}
@@ -359,12 +366,7 @@ public class ServerChunkCache extends ChunkSource {
}
public void close(boolean save) throws IOException {
@ -25400,15 +25400,15 @@ index 60f678c26fb5144386d8697ddfd5b6d841563b6f..17fafa62f21e505f9f77cf486f7f766a
}
// CraftBukkit start - modelled on below
@@ -394,6 +396,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -391,6 +393,7 @@ public class ServerChunkCache extends ChunkSource {
this.level.timings.doChunkMap.stopTiming(); // Spigot
this.level.getProfiler().popPush("chunks");
if (tickChunks) {
this.level.timings.chunks.startTiming(); // Paper - timings
+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getPlayerChunkLoader().tick(); // Paper - rewrite chunk system
this.tickChunks();
this.level.timings.chunks.stopTiming(); // Paper - timings
this.chunkMap.tick();
@@ -408,6 +411,7 @@ public class ServerChunkCache extends ChunkSource {
}
@@ -404,6 +407,7 @@ public class ServerChunkCache extends ChunkSource {
}
private void tickChunks() {
@ -25416,13 +25416,12 @@ index 60f678c26fb5144386d8697ddfd5b6d841563b6f..17fafa62f21e505f9f77cf486f7f766a
long i = this.level.getGameTime();
long j = i - this.lastInhabitedUpdate;
@@ -417,18 +421,29 @@ public class ServerChunkCache extends ChunkSource {
@@ -413,17 +417,28 @@ public class ServerChunkCache extends ChunkSource {
gameprofilerfiller.push("pollingChunks");
gameprofilerfiller.push("filteringLoadedChunks");
- List<ServerChunkCache.ChunkAndHolder> list = Lists.newArrayListWithCapacity(this.chunkMap.size());
- Iterator iterator = this.chunkMap.getChunks().iterator();
- if (this.level.getServer().tickRateManager().runsNormally()) this.level.timings.chunkTicks.startTiming(); // Paper
+ // Paper start - chunk tick iteration optimisations
+ List<ServerChunkCache.ChunkAndHolder> list;
+ {
@ -25448,13 +25447,12 @@ index 60f678c26fb5144386d8697ddfd5b6d841563b6f..17fafa62f21e505f9f77cf486f7f766a
}
+ // Paper end - chunk tick iteration optimisations
+ Iterator iterator = null; // Paper - chunk tick iteration optimisations
+ if (this.level.getServer().tickRateManager().runsNormally()) this.level.timings.chunkTicks.startTiming(); // Paper
+
+ // Paper - chunk tick iteration optimisations
if (this.level.tickRateManager().runsNormally()) {
gameprofilerfiller.popPush("naturalSpawnCount");
@@ -460,14 +475,19 @@ public class ServerChunkCache extends ChunkSource {
@@ -453,14 +468,19 @@ public class ServerChunkCache extends ChunkSource {
LevelChunk chunk1 = chunkproviderserver_a.chunk;
ChunkPos chunkcoordintpair = chunk1.getPos();
@ -25476,17 +25474,14 @@ index 60f678c26fb5144386d8697ddfd5b6d841563b6f..17fafa62f21e505f9f77cf486f7f766a
}
}
}
@@ -482,22 +502,35 @@ public class ServerChunkCache extends ChunkSource {
@@ -472,20 +492,33 @@ public class ServerChunkCache extends ChunkSource {
}
gameprofilerfiller.popPush("broadcast");
- list.forEach((chunkproviderserver_a1) -> {
- this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
- chunkproviderserver_a1.holder.broadcastChanges(chunkproviderserver_a1.chunk);
- this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
- });
+ // Paper start - chunk tick iteration optimisations
+ this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
+ {
+ final it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.server.level.ServerChunkCache.ChunkAndHolder> chunks = (it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.server.level.ServerChunkCache.ChunkAndHolder>)list;
+ final ServerChunkCache.ChunkAndHolder[] raw = chunks.elements();
@ -25500,7 +25495,6 @@ index 60f678c26fb5144386d8697ddfd5b6d841563b6f..17fafa62f21e505f9f77cf486f7f766a
+ holder.holder().broadcastChanges(holder.chunk());
+ }
+ }
+ this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
+ // Paper end - chunk tick iteration optimisations
gameprofilerfiller.pop();
gameprofilerfiller.pop();
@ -25521,7 +25515,7 @@ index 60f678c26fb5144386d8697ddfd5b6d841563b6f..17fafa62f21e505f9f77cf486f7f766a
}
@@ -591,6 +624,12 @@ public class ServerChunkCache extends ChunkSource {
@@ -579,6 +612,12 @@ public class ServerChunkCache extends ChunkSource {
this.chunkMap.setServerViewDistance(watchDistance);
}
@ -25534,7 +25528,7 @@ index 60f678c26fb5144386d8697ddfd5b6d841563b6f..17fafa62f21e505f9f77cf486f7f766a
public void setSimulationDistance(int simulationDistance) {
this.distanceManager.updateSimulationDistance(simulationDistance);
}
@@ -669,21 +708,19 @@ public class ServerChunkCache extends ChunkSource {
@@ -657,21 +696,19 @@ public class ServerChunkCache extends ChunkSource {
@Override
// CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
public boolean pollTask() {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Optional per player mob spawns
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index edb36dee707433d4f9419aef6ac6cc0bec5f285e..c282566ee45d79b4fb3297989e054c803873a294 100644
index 9d38391720537fc114a00d5f5c34f734cd8c8fc3..57122c884fe4d7b5d8e483d9d50226ce046d10f7 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -223,8 +223,26 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -37,12 +37,12 @@ index edb36dee707433d4f9419aef6ac6cc0bec5f285e..c282566ee45d79b4fb3297989e054c80
// Paper end
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 17fafa62f21e505f9f77cf486f7f766a404f7c31..2ed9a088d0fd56043d161909ce8e0df683a6413a 100644
index 564abf2edec3a355070954947d5793575ac3d336..146ec32016983b80dd45d80802e1599d6e08d653 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -449,14 +449,26 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -443,13 +443,25 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
if (this.level.tickRateManager().runsNormally()) {
gameprofilerfiller.popPush("naturalSpawnCount");
this.level.timings.countNaturalMobs.startTiming(); // Paper - timings
int k = this.distanceManager.getNaturalSpawnChunkCount();
- NaturalSpawner.SpawnState spawnercreature_d = NaturalSpawner.createState(k, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap));
+ // Paper start - Optional per player mob spawns
@ -58,7 +58,6 @@ index 17fafa62f21e505f9f77cf486f7f766a404f7c31..2ed9a088d0fd56043d161909ce8e0df6
+ spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false);
+ }
+ // Paper end - Optional per player mob spawns
this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings
this.lastSpawnState = spawnercreature_d;
gameprofilerfiller.popPush("spawnAndTick");

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Improve cancelling PreCreatureSpawnEvent with per player mob
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index c282566ee45d79b4fb3297989e054c803873a294..dc64227e3b0d7855ef8870935aa437b78eea2407 100644
index 57122c884fe4d7b5d8e483d9d50226ce046d10f7..23b14afcb5f651a64fd572e49518a7ca36622ec6 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -240,8 +240,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -37,10 +37,10 @@ index c282566ee45d79b4fb3297989e054c803873a294..dc64227e3b0d7855ef8870935aa437b7
}
// Paper end
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 2ed9a088d0fd56043d161909ce8e0df683a6413a..cdb9160244cc69acd36ac9afcfe109a15ab2ab58 100644
index 146ec32016983b80dd45d80802e1599d6e08d653..9e282fabc6815393e4183aebefe112305bf2ff2c 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -455,7 +455,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -449,7 +449,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
// re-set mob counts
for (ServerPlayer player : this.level.players) {

View file

@ -220,7 +220,7 @@ index fb3dcce4e1888f96fdd260740d9d955962d879fc..6313726359a1c15ee1d4d93b872849a1
this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary());
this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager);
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 7d2896918ff5fed37e5de5a22c37b0c7f32634a8..d43b98bdfcb00603737a309c0fb7793d42289b8c 100644
index ccfd2c6df3657ff53187a377f573d5f0a182ae4f..b3ead72a2aca870fc607a340df4fc54c5866ac4b 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -328,7 +328,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@ -242,7 +242,7 @@ index 7d2896918ff5fed37e5de5a22c37b0c7f32634a8..d43b98bdfcb00603737a309c0fb7793d
}
@Override
@@ -842,7 +843,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -808,7 +809,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@Override
public void stopServer() {
super.stopServer();

View file

@ -48,10 +48,10 @@ index 1a5e73fd97781f3903e5ef13aa0352c64fbc2cc1..4126d82e83810126eb4a41b4587dc993
entityTrackerEntry.getLastSentYRot(),
entity.getType(),
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index dc64227e3b0d7855ef8870935aa437b78eea2407..4799af2ce8f44e8f99365323d57f099c551a5eb7 100644
index 23b14afcb5f651a64fd572e49518a7ca36622ec6..530f54a16d853f417e5b5c7cf85d528313364452 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1269,6 +1269,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1265,6 +1265,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.serverEntity.addPairing(player);
}
// Paper end - entity tracking events

View file

@ -25,7 +25,7 @@ index 90a2c61c42cba7e38f167eccdd7a951a947963c4..3e550f8e7cd4f4e16f499a8a2a4b9542
}
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
index d0d36a57ec4896bcb74970f8fb24d8f3e17db133..e2c24813f59c2fd075c740ac1842a38f20ed8554 100644
index f7197f1347251a37dd0f6d9ffa2f09bc3a4e1233..1f7f68aad97ee73763c042837f239bdc7167db55 100644
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
@@ -20,6 +20,24 @@ public class PacketUtils {
@ -61,8 +61,8 @@ index d0d36a57ec4896bcb74970f8fb24d8f3e17db133..e2c24813f59c2fd075c740ac1842a38f
+ try { // Paper - detailed watchdog information
if (listener instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players
if (listener.shouldHandleMessage(packet)) {
co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(packet); // Paper - timings
@@ -48,6 +68,12 @@ public class PacketUtils {
try {
@@ -47,6 +67,12 @@ public class PacketUtils {
} else {
PacketUtils.LOGGER.debug("Ignoring packet due to disconnection: {}", packet);
}
@ -122,7 +122,7 @@ index 86288143a54e1d786672a81c05698b37fa5d8de2..1d74a728c03e2c6ffe0e795a5f24eac4
private void tickPassenger(Entity vehicle, Entity passenger) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 5608576f461ce9dec9827f9f581adc5d5757baf1..f0eb2fcbaadb5796cb48050d2f9f88a6100bdb4a 100644
index bd8dc3c90f4f5bb31d21f7518b5988c05ecd9f30..1f7594e22f0f08ae110ef9b42f15119358aa5723 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1086,8 +1086,43 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Write SavedData IO async
Co-Authored-By: Shane Freeder <theboyetronic@gmail.com>
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index cdb9160244cc69acd36ac9afcfe109a15ab2ab58..8a0b00d645e4cf2ca96ec7e8ebc6ef726a0ab8b0 100644
index 9e282fabc6815393e4183aebefe112305bf2ff2c..74c39ffd7add898d8604cd23381811251e55f882 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -369,6 +369,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -367,6 +367,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
public void close(boolean save) throws IOException {
((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.close(save, true); // Paper - rewrite chunk system