fix datapacks not being able to modify nether/end (#7588)

This commit is contained in:
Jake Potrebic 2022-03-16 17:54:52 -07:00
parent 639b4ba80c
commit f258c4f2e9
2 changed files with 42 additions and 0 deletions

View file

@ -182,6 +182,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/resources/RegistryLoader.java
+++ b/src/main/java/net/minecraft/resources/RegistryLoader.java
@@ -0,0 +0,0 @@ public class RegistryLoader {
}
private <E> RegistryLoader.ReadCache<E> readCache(ResourceKey<? extends Registry<E>> registryRef) {
- return this.readCache.computeIfAbsent(registryRef, (ref) -> {
+ return (RegistryLoader.ReadCache<E>) this.readCache.computeIfAbsent(registryRef, (ref) -> { // Paper - decompile fix
return new RegistryLoader.ReadCache();
});
}
@@ -0,0 +0,0 @@ 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 <E> DataResult<? extends Registry<E>> overrideRegistryFromResources(ResourceKey<? extends Registry<E>> registryRef, Codec<E> codec, DynamicOps<JsonElement> ops) {
WritableRegistry<E> 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java

View file

@ -4,7 +4,25 @@ 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 <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/net/minecraft/resources/RegistryLoader.java b/src/main/java/net/minecraft/resources/RegistryLoader.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/resources/RegistryLoader.java
+++ b/src/main/java/net/minecraft/resources/RegistryLoader.java
@@ -0,0 +0,0 @@ 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.getOrCreateHolder(entryKey);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java