From 83cd94ea936f22665bff4de1694a5362c9ffdb58 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 29 Mar 2022 01:32:18 -0700 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit) (#7672) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 7902647a PR-737: Update WorldCreator#generatorSettings docs 67556a50 PR-736: Update README CraftBukkit Changes: 10922194 Java 18 support d53c4fb6 PR-1039: Use correct ops in GeneratorSettings a567e4ae PR-1038: Removed the no longer needed getChunkUnchecked method from ChunkProviderServer. 4ac8fcce SPIGOT-6980: Since 1.18.2, World#isChunkLoaded returned false for chunks that have just been loaded (e.g. inside ChunkLoadEvent). e6cc7c70 PR-1035: Update README 3ec79a27 SPIGOT-5140: Call EntityChangeBlockEvent when a ChorusFlower is destroyed by a projectile --- patches/server/Chunk-debug-command.patch | 4 +-- .../server/Do-not-copy-visible-chunks.patch | 8 +++--- ...settings-string-for-flat-type-worlds.patch | 20 --------------- patches/server/MC-Dev-fixes.patch | 13 ---------- patches/server/MC-Utils.patch | 25 +++++++------------ .../Optimise-chunk-tick-iteration.patch | 2 +- .../Optimise-nearby-player-lookups.patch | 4 +-- .../Remove-garbage-Java-version-check.patch | 4 +-- work/Bukkit | 2 +- work/CraftBukkit | 2 +- 10 files changed, 22 insertions(+), 62 deletions(-) delete mode 100644 patches/server/Fix-generator-settings-string-for-flat-type-worlds.patch diff --git a/patches/server/Chunk-debug-command.patch b/patches/server/Chunk-debug-command.patch index e0583e74d1..33319a737e 100644 --- a/patches/server/Chunk-debug-command.patch +++ b/patches/server/Chunk-debug-command.patch @@ -132,7 +132,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + int entityTicking = 0; + + for (ChunkHolder chunk : world.getChunkSource().chunkMap.updatingChunkMap.values()) { -+ if (chunk.getFullChunkUnchecked() == null) { ++ if (chunk.getFullChunkNowUnchecked() == null) { + continue; + } + @@ -334,7 +334,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + int fullLoadedChunks = 0; + + for (ChunkHolder chunk : allChunks) { -+ if (chunk.getFullChunkUnchecked() != null) { ++ if (chunk.getFullChunkNowUnchecked() != null) { + ++fullLoadedChunks; + } + } diff --git a/patches/server/Do-not-copy-visible-chunks.patch b/patches/server/Do-not-copy-visible-chunks.patch index b7c5351d77..773bb5c978 100644 --- a/patches/server/Do-not-copy-visible-chunks.patch +++ b/patches/server/Do-not-copy-visible-chunks.patch @@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - for (ChunkHolder chunk : world.getChunkSource().chunkMap.updatingChunkMap.values()) { + for (ChunkHolder chunk : world.getChunkSource().chunkMap.updatingChunks.getUpdatingMap().values()) { // Paper - change updating chunks map - if (chunk.getFullChunkUnchecked() == null) { + if (chunk.getFullChunkNowUnchecked() == null) { continue; } diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java @@ -219,12 +219,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + synchronized (world.getChunkSource().chunkMap.updatingChunks) { + chunks = world.getChunkSource().chunkMap.updatingChunks.getVisibleMap().clone(); + } -+ return chunks.values().stream().map(ChunkHolder::getFullChunk).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new); ++ return chunks.values().stream().map(ChunkHolder::getFullChunkNow).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new); + // Paper end - change updating chunks map + } + // Paper end -+ Long2ObjectLinkedOpenHashMap chunks = world.getChunkSource().chunkMap.updatingChunks.getVisibleMap(); // Paper - change updating chunks map - return chunks.values().stream().map(ChunkHolder::getFullChunk).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new); ++ Long2ObjectLinkedOpenHashMap chunks = this.world.getChunkSource().chunkMap.updatingChunks.getVisibleMap(); // Paper - change updating chunks map + return chunks.values().stream().map(ChunkHolder::getFullChunkNow).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new); } @@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { diff --git a/patches/server/Fix-generator-settings-string-for-flat-type-worlds.patch b/patches/server/Fix-generator-settings-string-for-flat-type-worlds.patch deleted file mode 100644 index 02e3e7e46f..0000000000 --- a/patches/server/Fix-generator-settings-string-for-flat-type-worlds.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Wed, 9 Mar 2022 12:51:29 -0800 -Subject: [PATCH] Fix generator settings string for flat-type worlds - -Fixes MC-195468 - -diff --git a/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java b/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -@@ -0,0 +0,0 @@ public class WorldGenSettings { - String var8 = worldGenProperties.levelType(); - switch(var8) { - case "flat": -- Dynamic dynamic = new Dynamic<>(JsonOps.INSTANCE, worldGenProperties.generatorSettings()); -+ Dynamic dynamic = new Dynamic<>(net.minecraft.resources.RegistryOps.create(JsonOps.INSTANCE, registryManager), worldGenProperties.generatorSettings()); // Paper - needs RegistryOps to access biome registry inside FlatLevelGeneratorSettings's Codec, Fixes MC-195468 - return new WorldGenSettings(l, worldGenProperties.generateStructures(), false, withOverworld(registry, registry4, new FlatLevelSource(registry3, FlatLevelGeneratorSettings.CODEC.parse(dynamic).resultOrPartial(LOGGER::error).orElseGet(() -> { - return FlatLevelGeneratorSettings.getDefault(registry2, registry3); - })))); diff --git a/patches/server/MC-Dev-fixes.patch b/patches/server/MC-Dev-fixes.patch index 259786a76d..e91450d1d5 100644 --- a/patches/server/MC-Dev-fixes.patch +++ b/patches/server/MC-Dev-fixes.patch @@ -345,16 +345,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } -diff --git a/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java b/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java -@@ -0,0 +0,0 @@ import org.apache.commons.lang3.StringUtils; - import org.slf4j.Logger; - - public class WorldGenSettings { -- public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { -+ public static final Codec CODEC = RecordCodecBuilder.create((instance) -> { // Paper - decompile fix - return instance.group(Codec.LONG.fieldOf("seed").stable().forGetter(WorldGenSettings::seed), Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldGenSettings::generateFeatures), Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldGenSettings::generateBonusChest), RegistryCodecs.dataPackAwareCodec(Registry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), LevelStem.CODEC).xmap(LevelStem::sortMap, Function.identity()).fieldOf("dimensions").forGetter(WorldGenSettings::dimensions), Codec.STRING.optionalFieldOf("legacy_custom_options").stable().forGetter((worldGenSettings) -> { - return worldGenSettings.legacyCustomOptions; - })).apply(instance, instance.stable(WorldGenSettings::new)); diff --git a/patches/server/MC-Utils.patch b/patches/server/MC-Utils.patch index 6d459d54b0..ca92ec1be3 100644 --- a/patches/server/MC-Utils.patch +++ b/patches/server/MC-Utils.patch @@ -5082,21 +5082,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.setTicketLevel(level); this.changedBlocksPerSection = new ShortSet[world.getSectionsCount()]; + this.chunkMap = (ChunkMap)playersWatchingChunkProvider; // Paper -+ } -+ -+ // Paper start -+ public LevelChunk getFullChunkUnchecked() { -+ CompletableFuture> statusFuture = this.getFutureIfPresentUnchecked(ChunkStatus.FULL); -+ Either either = (Either) statusFuture.getNow(null); -+ return (either == null) ? null : (LevelChunk) either.left().orElse(null); } -+ public ChunkAccess getAvailableChunkNow() { ++ // Paper start ++ public @Nullable ChunkAccess getAvailableChunkNow() { + // TODO can we just getStatusFuture(EMPTY)? + for (ChunkStatus curr = ChunkStatus.FULL, next = curr.getParent(); curr != next; curr = next, next = next.getParent()) { + CompletableFuture> future = this.getFutureIfPresentUnchecked(curr); + Either either = future.getNow(null); -+ if (either == null || !either.left().isPresent()) { ++ if (either == null || either.left().isEmpty()) { + continue; + } + return either.left().get(); @@ -5104,10 +5098,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return null; + } + // Paper end -+ - public CompletableFuture> getFutureIfPresentUnchecked(ChunkStatus leastStatus) { - CompletableFuture> completablefuture = (CompletableFuture) this.futures.get(leastStatus.getIndex()); - + // CraftBukkit start + public LevelChunk getFullChunkNow() { + // Note: We use the oldTicketLevel for isLoaded checks. @@ -0,0 +0,0 @@ public class ChunkHolder { return ChunkHolder.getStatus(this.ticketLevel).isOrAfter(leastStatus) ? this.getFutureIfPresentUnchecked(leastStatus) : ChunkHolder.UNLOADED_CHUNK_FUTURE; } @@ -5238,7 +5231,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.tickingChunkFuture.complete(ChunkHolder.UNLOADED_LEVEL_CHUNK); this.isTickingReady = false; // Paper - cache chunk ticking stage this.tickingChunkFuture = ChunkHolder.UNLOADED_LEVEL_CHUNK_FUTURE; + // Paper start - ticking chunk set -+ LevelChunk chunkIfCached = this.getFullChunkUnchecked(); ++ LevelChunk chunkIfCached = this.getFullChunkNowUnchecked(); + if (chunkIfCached != null) { + this.chunkMap.level.getChunkSource().tickingChunks.remove(chunkIfCached); + } @@ -5268,7 +5261,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.entityTickingChunkFuture.complete(ChunkHolder.UNLOADED_LEVEL_CHUNK); this.isEntityTickingReady = false; // Paper - cache chunk ticking stage this.entityTickingChunkFuture = ChunkHolder.UNLOADED_LEVEL_CHUNK_FUTURE; + // Paper start - entity ticking chunk set -+ LevelChunk chunkIfCached = this.getFullChunkUnchecked(); ++ LevelChunk chunkIfCached = this.getFullChunkNowUnchecked(); + if (chunkIfCached != null) { + this.chunkMap.level.getChunkSource().entityTickingChunks.remove(chunkIfCached); + } @@ -5859,7 +5852,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return null; + } + -+ return playerChunk.getFullChunkUnchecked(); ++ return playerChunk.getFullChunkNowUnchecked(); + } + + @Nullable diff --git a/patches/server/Optimise-chunk-tick-iteration.patch b/patches/server/Optimise-chunk-tick-iteration.patch index ab1fa5c085..46b0b61ee0 100644 --- a/patches/server/Optimise-chunk-tick-iteration.patch +++ b/patches/server/Optimise-chunk-tick-iteration.patch @@ -188,7 +188,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + ReferenceOpenHashSet copy = this.chunkMap.needsChangeBroadcasting.clone(); + this.chunkMap.needsChangeBroadcasting.clear(); + for (ChunkHolder holder : copy) { -+ holder.broadcastChanges(holder.getFullChunkUnchecked()); // LevelChunks are NEVER unloaded ++ holder.broadcastChanges(holder.getFullChunkNowUnchecked()); // LevelChunks are NEVER unloaded + if (holder.needsBroadcastChanges()) { + // I DON'T want to KNOW what DUMB plugins might be doing. + this.chunkMap.needsChangeBroadcasting.add(holder); diff --git a/patches/server/Optimise-nearby-player-lookups.patch b/patches/server/Optimise-nearby-player-lookups.patch index acabff4702..8c2d4c98fa 100644 --- a/patches/server/Optimise-nearby-player-lookups.patch +++ b/patches/server/Optimise-nearby-player-lookups.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } // Paper end - optimise chunk tick iteration + // Paper start - optimise checkDespawn -+ LevelChunk chunk = this.getFullChunkUnchecked(); ++ LevelChunk chunk = this.getFullChunkNowUnchecked(); + if (chunk != null) { + chunk.updateGeneralAreaCache(); + } @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } // Paper end - optimise chunk tick iteration + // Paper start - optimise checkDespawn -+ LevelChunk chunk = this.getFullChunkUnchecked(); ++ LevelChunk chunk = this.getFullChunkNowUnchecked(); + if (chunk != null) { + chunk.removeGeneralAreaCache(); + } diff --git a/patches/server/Remove-garbage-Java-version-check.patch b/patches/server/Remove-garbage-Java-version-check.patch index d0eb1c9fd1..94994e86fa 100644 --- a/patches/server/Remove-garbage-Java-version-check.patch +++ b/patches/server/Remove-garbage-Java-version-check.patch @@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 System.err.println("Unsupported Java detected (" + javaVersion + "). This version of Minecraft requires at least Java 17. Check your Java version with the command 'java -version'."); return; } -- if (javaVersion > 61.0) { -- System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 17 is supported."); +- if (javaVersion > 62.0) { +- System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 18 is supported."); - return; - } diff --git a/work/Bukkit b/work/Bukkit index 33a2b476bb..7902647a66 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 33a2b476bbde7c2c0c45e644dc99b10d65736d40 +Subproject commit 7902647a668318b7e04f817e07ae9b955d7c0485 diff --git a/work/CraftBukkit b/work/CraftBukkit index e9f972d674..10922194f4 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit e9f972d6744d66460a78a868d298c7f543533073 +Subproject commit 10922194f43009dea660c8b5c9fe27f136e940a6