@@ -23277,10 +23277,10 @@ index 1cd5901c8e4eb4114ab347a393fc37095c8642d2..fadce1c051e6c7bc0c3d041c0cc8ecd7
2327723277+}
2327823278diff --git a/io/papermc/paper/command/subcommands/ChunkDebugCommand.java b/io/papermc/paper/command/subcommands/ChunkDebugCommand.java
2327923279new file mode 100644
23280- index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9b89a6fb3
23280+ index 0000000000000000000000000000000000000000..d86bd11e0155f767c3bf66ac05fa4acf6d2bfccb
2328123281--- /dev/null
2328223282+++ b/io/papermc/paper/command/subcommands/ChunkDebugCommand.java
23283- @@ -0,0 +1,277 @@
23283+ @@ -0,0 +1,269 @@
2328423284+package io.papermc.paper.command.subcommands;
2328523285+
2328623286+import ca.spottedleaf.moonrise.common.util.JsonUtil;
@@ -23301,6 +23301,8 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9
2330123301+import net.minecraft.world.level.chunk.LevelChunk;
2330223302+import net.minecraft.world.level.chunk.ProtoChunk;
2330323303+import org.bukkit.Bukkit;
23304+ +import org.bukkit.NamespacedKey;
23305+ +import org.bukkit.World;
2330423306+import org.bukkit.command.CommandSender;
2330523307+import org.bukkit.craftbukkit.CraftWorld;
2330623308+import org.checkerframework.checker.nullness.qual.NonNull;
@@ -23327,44 +23329,33 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9
2332723329+
2332823330+ @Override
2332923331+ public List<String> tabComplete(final CommandSender sender, final String subCommand, final String[] args) {
23330- + switch (subCommand) {
23331- + case "debug" -> {
23332- + if (args.length == 1) {
23333- + return CommandUtil.getListMatchingLast(sender, args, "help", "chunks");
23334- + }
23335- + }
23336- + case "holderinfo" -> {
23337- + List<String> worldNames = new ArrayList<>();
23338- + worldNames.add("*");
23339- + for (org.bukkit.World world : Bukkit.getWorlds()) {
23340- + worldNames.add(world.getKey().toString());
23341- + }
23342- + if (args.length == 1) {
23343- + return CommandUtil.getListMatchingLast(sender, args, worldNames);
23344- + }
23345- + }
23346- + case "chunkinfo" -> {
23347- + List<String> worldNames = new ArrayList<>();
23348- + worldNames.add("*");
23349- + for (org.bukkit.World world : Bukkit.getWorlds()) {
23350- + worldNames.add(world.getKey().toString());
23351- + }
23332+ + return switch (subCommand) {
23333+ + case "debug":
2335223334+ if (args.length == 1) {
23353- + return CommandUtil.getListMatchingLast(sender, args, worldNames);
23335+ + yield CommandUtil.getListMatchingLast(sender, args, "help", "chunks");
23336+ + }
23337+ + case "chunkinfo", "holderinfo":
23338+ + if (args.length >= 1 && (args.length == 1 || !args[0].equals("*"))) {
23339+ + yield CommandUtil.getListMatchingLast(
23340+ + sender,
23341+ + args,
23342+ + CommandUtil.getWorldSuggestions(sender.getServer(), args.length == 1)
23343+ + );
2335423344+ }
23355- + }
23356- + }
23357- + return Collections.emptyList() ;
23345+ + default:
23346+ + yield Collections.emptyList();
23347+ + } ;
2335823348+ }
2335923349+
2336023350+ private void doChunkInfo(final CommandSender sender, final String[] args) {
23361- + List<org.bukkit. World> worlds;
23351+ + List<World> worlds;
2336223352+ if (args.length < 1 || args[0].equals("*")) {
23363- + worlds = Bukkit.getWorlds();
23353+ + worlds = Bukkit.getServer(). getWorlds();
2336423354+ } else {
2336523355+ worlds = new ArrayList<>(args.length);
2336623356+ for (final String arg : args) {
23367- + org.bukkit.@Nullable World world = Bukkit.getWorld(arg);
23357+ + @Nullable NamespacedKey key = NamespacedKey.fromString(arg);
23358+ + @Nullable World world = key == null ? null : sender.getServer().getWorld(key);
2336823359+ if (world == null) {
2336923360+ sender.sendMessage(text("World '" + arg + "' is invalid", RED));
2337023361+ return;
@@ -23379,7 +23370,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9
2337923370+ int accumulatedTicking = 0;
2338023371+ int accumulatedEntityTicking = 0;
2338123372+
23382- + for (final org.bukkit. World bukkitWorld : worlds) {
23373+ + for (final World bukkitWorld : worlds) {
2338323374+ final ServerLevel world = ((CraftWorld) bukkitWorld).getHandle();
2338423375+
2338523376+ int total = 0;
@@ -23390,7 +23381,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9
2339023381+
2339123382+ for (final NewChunkHolder holder : ((ChunkSystemServerLevel)world).moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolders()) {
2339223383+ final NewChunkHolder.ChunkCompletion completion = holder.getLastChunkCompletion();
23393- + final ChunkAccess chunk = completion == null ? null : completion.chunk();
23384+ + final @Nullable ChunkAccess chunk = completion == null ? null : completion.chunk();
2339423385+
2339523386+ if (!(chunk instanceof LevelChunk fullChunk)) {
2339623387+ continue;
@@ -23424,7 +23415,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9
2342423415+ accumulatedTicking += blockTicking;
2342523416+ accumulatedEntityTicking += entityTicking;
2342623417+
23427- + sender.sendMessage(text().append(text("Chunks in ", BLUE), text(bukkitWorld.key().toString (), GREEN), text(":")));
23418+ + sender.sendMessage(text().append(text("Chunks in ", BLUE), text(bukkitWorld.key().asString (), GREEN), text(":")));
2342823419+ sender.sendMessage(text().color(DARK_AQUA).append(
2342923420+ text("Total: ", BLUE), text(total),
2343023421+ text(" Inactive: ", BLUE), text(inactive),
@@ -23446,13 +23437,14 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9
2344623437+ }
2344723438+
2344823439+ private void doHolderInfo(final CommandSender sender, final String[] args) {
23449- + List<org.bukkit. World> worlds;
23440+ + List<World> worlds;
2345023441+ if (args.length < 1 || args[0].equals("*")) {
23451- + worlds = Bukkit.getWorlds();
23442+ + worlds = Bukkit.getServer(). getWorlds();
2345223443+ } else {
2345323444+ worlds = new ArrayList<>(args.length);
2345423445+ for (final String arg : args) {
23455- + org.bukkit.@Nullable World world = Bukkit.getWorld(arg);
23446+ + @Nullable NamespacedKey key = NamespacedKey.fromString(arg);
23447+ + @Nullable World world = key == null ? null : sender.getServer().getWorld(key);
2345623448+ if (world == null) {
2345723449+ sender.sendMessage(text("World '" + arg + "' is invalid", RED));
2345823450+ return;
@@ -23468,7 +23460,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9
2346823460+ int accumulatedProtoChunk = 0;
2346923461+ int accumulatedFullChunk = 0;
2347023462+
23471- + for (final org.bukkit. World bukkitWorld : worlds) {
23463+ + for (final World bukkitWorld : worlds) {
2347223464+ final ServerLevel world = ((CraftWorld) bukkitWorld).getHandle();
2347323465+
2347423466+ int total = 0;
@@ -23480,7 +23472,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9
2348023472+
2348123473+ for (final NewChunkHolder holder : ((ChunkSystemServerLevel)world).moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolders()) {
2348223474+ final NewChunkHolder.ChunkCompletion completion = holder.getLastChunkCompletion();
23483- + final ChunkAccess chunk = completion == null ? null : completion.chunk();
23475+ + final @Nullable ChunkAccess chunk = completion == null ? null : completion.chunk();
2348423476+
2348523477+ ++total;
2348623478+
@@ -23506,7 +23498,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9
2350623498+ accumulatedProtoChunk += protoChunk;
2350723499+ accumulatedFullChunk += fullChunk;
2350823500+
23509- + sender.sendMessage(text().append(text("Chunks in ", BLUE), text(bukkitWorld.getKey ().toString (), GREEN), text(":")));
23501+ + sender.sendMessage(text().append(text("Chunks in ", BLUE), text(bukkitWorld.key ().asString (), GREEN), text(":")));
2351023502+ sender.sendMessage(text().color(DARK_AQUA).append(
2351123503+ text("Total: ", BLUE), text(total),
2351223504+ text(" Unloadable: ", BLUE), text(canUnload),
@@ -23838,7 +23830,7 @@ index 3c1490ac7c259da04031db2f170e0c0a5f512191..470d7c770ae9d045b97e2df145cfe3cf
2383823830 }
2383923831 }
2384023832diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
23841- index aebc47b0ed5c5a47b3e70e0c94ab5f7abaca523d..7c6a23408d7fe9cb11891678af97b5b7761d6bbc 100644
23833+ index d22f55c63eb950e1b979280612eb9f155e986406..93690b360e5eb1b8d2f8ab2198aa087c9be7ffe2 100644
2384223834--- a/net/minecraft/server/MinecraftServer.java
2384323835+++ b/net/minecraft/server/MinecraftServer.java
2384423836@@ -191,7 +191,7 @@ import net.minecraft.world.scores.ScoreboardSaveData;
@@ -30053,7 +30045,7 @@ index e07a7bda45146686a6ac2d20507df9fc8630514f..f84e651e2a34e76a0a71993332e4be1b
3005330045
3005430046 // Paper start - Affects Spawning API
3005530047diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
30056- index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb06be81da 100644
30048+ index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669b111f4c0 100644
3005730049--- a/net/minecraft/world/level/Level.java
3005830050+++ b/net/minecraft/world/level/Level.java
3005930051@@ -87,6 +87,7 @@ import net.minecraft.world.level.storage.LevelData;
@@ -30725,18 +30717,18 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb
3072530717+ this.maxSectionY = this.maxY >> 4;
3072630718+ this.sectionsCount = this.maxSectionY - this.minSectionY + 1;
3072730719+ // Paper end - getblock optimisations - cache world height/sections
30728- this.spigotConfig = new org.spigotmc.SpigotWorldConfig(bukkitName, CraftNamespacedKey.fromMinecraft(dimension.identifier())); // Spigot
30720+ final org.bukkit.NamespacedKey worldKey = CraftNamespacedKey.fromMinecraft(dimension.identifier()); // Paper
30721+ this.spigotConfig = new org.spigotmc.SpigotWorldConfig(bukkitName, worldKey); // Spigot
3072930722 this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
30730- this.generator = generator;
30731- @@ -230,6 +863,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
30723+ @@ -231,6 +864,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
3073230724 this.registryAccess = registryAccess;
3073330725 this.palettedContainerFactory = PalettedContainerFactory.create(registryAccess);
3073430726 this.damageSources = new DamageSources(registryAccess);
3073530727+ this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system
3073630728 }
3073730729
3073830730 // Paper start - Cancel hit for vanished players
30739- @@ -511 ,7 +1145 ,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
30731+ @@ -512 ,7 +1146 ,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
3074030732 this.setBlocksDirty(pos, blockState, blockState1);
3074130733 }
3074230734
@@ -30745,15 +30737,15 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb
3074530737 this.sendBlockUpdated(pos, blockState, state, flags);
3074630738 }
3074730739
30748- @@ -845 ,6 +1479 ,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
30740+ @@ -846 ,6 +1480 ,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
3074930741 // Paper - Fix MC-117075 use removeAll - remove iterator in favour of indexed for loop, ensuring compile error if something uses iter incorrectly
3075030742 boolean tickBlockEntities = this.tickRateManager().runsNormally();
3075130743
3075230744+ int tickedEntities = 0; // Paper - rewrite chunk system
3075330745 // Paper start - Fix MC-117075 use removeAll
3075430746 final it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<@Nullable TickingBlockEntity> toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>();
3075530747 toRemove.add(null);
30756- @@ -855 ,6 +1490 ,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
30748+ @@ -856 ,6 +1491 ,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
3075730749 toRemove.add(ticker); // Paper - Fix MC-117075 use removeAll
3075830750 } else if (tickBlockEntities && this.shouldTickBlocksAt(ticker.getPos())) {
3075930751 ticker.tick();
@@ -30765,15 +30757,15 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb
3076530757 }
3076630758 }
3076730759
30768- @@ -873 ,6 +1513 ,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
30760+ @@ -874 ,6 +1514 ,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
3076930761 entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
3077030762 // Paper end - Prevent block entity and entity crashes
3077130763 }
3077230764+ this.moonrise$midTickTasks(); // Paper - rewrite chunk system
3077330765 }
3077430766
3077530767 // Paper start - Option to prevent armor stands from doing entity lookups
30776- @@ -880 ,7 +1521 ,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
30768+ @@ -881 ,7 +1522 ,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
3077730769 public boolean noCollision(@Nullable Entity entity, AABB box) {
3077830770 if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups)
3077930771 return false;
@@ -30789,7 +30781,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb
3078930781 }
3079030782 // Paper end - Option to prevent armor stands from doing entity lookups
3079130783
30792- @@ -1025 ,7 +1673 ,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
30784+ @@ -1026 ,7 +1674 ,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
3079330785 if (!this.isInValidBounds(pos)) {
3079430786 return null;
3079530787 } else {
@@ -30798,7 +30790,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb
3079830790 ? null
3079930791 : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE);
3080030792 }
30801- @@ -1105 ,20 +1753 ,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
30793+ @@ -1106 ,20 +1754 ,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
3080230794 @Override
3080330795 public List<Entity> getEntities(final @Nullable Entity except, final AABB bb, final Predicate<? super Entity> selector) {
3080430796 Profiler.get().incrementCounter("getEntities");
@@ -30826,7 +30818,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb
3082630818 }
3082730819
3082830820 @Override
30829- @@ -1134 ,33 +1777 ,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
30821+ @@ -1135 ,33 +1778 ,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
3083030822 this.getEntities(type, bb, selector, output, Integer.MAX_VALUE);
3083130823 }
3083230824
@@ -30941,7 +30933,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb
3094130933
3094230934 public <T extends Entity> boolean hasEntities(final EntityTypeTest<Entity, T> type, final AABB bb, final Predicate<? super T> selector) {
3094330935 Profiler.get().incrementCounter("hasEntities");
30944- @@ -1465 ,13 +2169 ,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
30936+ @@ -1466 ,13 +2170 ,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
3094530937
3094630938 // Paper start - allow patching this logic
3094730939 public final int getEntityCount() {
0 commit comments