From 8788bf74415b127f1cb11ccb0b9f34a6f3ddc14d Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 16 Mar 2022 17:54:52 -0700 Subject: [PATCH] fix datapacks not being able to modify nether/end (#7588) --- patches/server/0005-MC-Dev-fixes.patch | 24 +++++++++++++++++++ ...lStem-registry-when-loading-default-.patch | 20 +++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/patches/server/0005-MC-Dev-fixes.patch b/patches/server/0005-MC-Dev-fixes.patch index bb35e3025..ee563f2c5 100644 --- a/patches/server/0005-MC-Dev-fixes.patch +++ b/patches/server/0005-MC-Dev-fixes.patch @@ -182,6 +182,30 @@ index 2a6969baca7c07c52223672de58886dd05c032eb..a620e53021e02da1663b8d8b68d429b2 @Override public void write(FriendlyByteBuf buf) { buf.writeInt(this.playerId); +diff --git a/src/main/java/net/minecraft/resources/RegistryLoader.java b/src/main/java/net/minecraft/resources/RegistryLoader.java +index 858037070db0b0fed07bf542294b76028f0018f9..75f72b568ee2b27c5042da688b62d4e3c5732e09 100644 +--- a/src/main/java/net/minecraft/resources/RegistryLoader.java ++++ b/src/main/java/net/minecraft/resources/RegistryLoader.java +@@ -73,7 +73,7 @@ public class RegistryLoader { + } + + private RegistryLoader.ReadCache readCache(ResourceKey> registryRef) { +- return this.readCache.computeIfAbsent(registryRef, (ref) -> { ++ return (RegistryLoader.ReadCache) this.readCache.computeIfAbsent(registryRef, (ref) -> { // Paper - decompile fix + return new RegistryLoader.ReadCache(); + }); + } +@@ -83,10 +83,6 @@ public class RegistryLoader { + } + + public static record Bound(RegistryAccess.Writable access, RegistryLoader loader) { +- public Bound(RegistryAccess.Writable writable, RegistryLoader registryLoader) { +- this.access = writable; +- this.loader = registryLoader; +- } + + public DataResult> overrideRegistryFromResources(ResourceKey> registryRef, Codec codec, DynamicOps ops) { + WritableRegistry writableRegistry = this.access.ownedWritableRegistryOrThrow(registryRef); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index ef128de5fe17231b39edb12a7014291d03cf79ec..868f6799a0e406401eecf18bc939fbdf88f534a2 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/patches/server/0754-Use-correct-LevelStem-registry-when-loading-default-.patch b/patches/server/0754-Use-correct-LevelStem-registry-when-loading-default-.patch index 9bc3b8153..9f6cbc394 100644 --- a/patches/server/0754-Use-correct-LevelStem-registry-when-loading-default-.patch +++ b/patches/server/0754-Use-correct-LevelStem-registry-when-loading-default-.patch @@ -4,9 +4,27 @@ Date: Sat, 16 Oct 2021 17:38:35 -0700 Subject: [PATCH] Use correct LevelStem registry when loading default end/nether +Co-authored-by: Jake Potrebic +diff --git a/src/main/java/net/minecraft/resources/RegistryLoader.java b/src/main/java/net/minecraft/resources/RegistryLoader.java +index 75f72b568ee2b27c5042da688b62d4e3c5732e09..8c3555842202d67793d818c96feda4daa2f08a0c 100644 +--- a/src/main/java/net/minecraft/resources/RegistryLoader.java ++++ b/src/main/java/net/minecraft/resources/RegistryLoader.java +@@ -42,6 +42,12 @@ public class RegistryLoader { + RegistryLoader.ReadCache readCache = this.readCache(registryRef); + DataResult> dataResult = readCache.values.get(entryKey); + if (dataResult != null) { ++ // Paper start - register in registry due to craftbukkit running this 3 times instead of once ++ if (registryRef == (ResourceKey) Registry.LEVEL_STEM_REGISTRY && dataResult.result().isPresent()) { ++ // OptionalInt.empty() because the LevelStem registry is only loaded from the resource manager, not the InMemory resource access ++ registry.registerOrOverride(java.util.OptionalInt.empty(), entryKey, dataResult.result().get().value(), dataResult.lifecycle()); ++ } ++ // Paper end + return dataResult; + } else { + Holder holder = registry.getOrCreateHolder(entryKey); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index a279368fe144bd41d15e5fe5e565412f8b4ef9f7..f877b956859643b4f3d969992f2e515dc490f90c 100644 +index fddb279d161b30d6944495f0de9f6b7e21761a80..df955666723a8cb1e612311f0b8e77fb577d6be5 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -563,7 +563,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop