summaryrefslogtreecommitdiffhomepage
path: root/patches/server/0747-Use-correct-LevelStem-registry-when-loading-default-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0747-Use-correct-LevelStem-registry-when-loading-default-.patch')
-rw-r--r--patches/server/0747-Use-correct-LevelStem-registry-when-loading-default-.patch45
1 files changed, 45 insertions, 0 deletions
diff --git a/patches/server/0747-Use-correct-LevelStem-registry-when-loading-default-.patch b/patches/server/0747-Use-correct-LevelStem-registry-when-loading-default-.patch
new file mode 100644
index 0000000000..0fb83af7c8
--- /dev/null
+++ b/patches/server/0747-Use-correct-LevelStem-registry-when-loading-default-.patch
@@ -0,0 +1,45 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jason Penilla <[email protected]>
+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 <[email protected]>
+
+diff --git a/src/main/java/net/minecraft/resources/RegistryLoader.java b/src/main/java/net/minecraft/resources/RegistryLoader.java
+index 8da1226a6c293abb038d10c7921a77ed71ad06cc..f958f0ae738a6fb26400e17e54c8d69e95268cdd 100644
+--- a/src/main/java/net/minecraft/resources/RegistryLoader.java
++++ b/src/main/java/net/minecraft/resources/RegistryLoader.java
+@@ -46,6 +46,12 @@ public class RegistryLoader {
+ RegistryLoader.ReadCache<E> readCache = this.readCache(registryRef);
+ DataResult<Holder<E>> 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<E> holder = registry.getOrCreateHolderOrThrow(entryKey);
+diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
+index 421872f7cc1a3cbb4dc596d0e0fa0f9b63602a8a..8a36c0bacb71cd9e31affa6290d28bf0f0374d07 100644
+--- a/src/main/java/net/minecraft/server/MinecraftServer.java
++++ b/src/main/java/net/minecraft/server/MinecraftServer.java
+@@ -553,7 +553,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
+ long i = generatorsettings.seed();
+ long j = BiomeManager.obfuscateSeed(i);
+ List<CustomSpawner> list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(iworlddataserver));
+- LevelStem worlddimension = (LevelStem) iregistry.get(dimensionKey);
++ // Paper start - Use correct LevelStem registry
++ final LevelStem worlddimension;
++ if (dimensionKey == LevelStem.END || dimensionKey == LevelStem.NETHER) {
++ worlddimension = generatorsettings.dimensions().get(dimensionKey);
++ } else {
++ worlddimension = iregistry.get(dimensionKey);
++ }
++ // Paper end
+
+ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), worlddimension.typeHolder().value());
+ if (biomeProvider == null && gen != null) {