fix some startup issues

This commit is contained in:
Jake Potrebic 2022-12-08 00:52:08 -08:00
parent 181b2c7e46
commit 06018dbedf
3 changed files with 55 additions and 10 deletions

View file

@ -19,6 +19,24 @@ public net.minecraft.world.level.levelgen.SurfaceSystem getOrCreateRandomFactory
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
diff --git a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
+++ b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
@@ -0,0 +0,0 @@ public class BuiltInRegistries {
}
public static void bootStrap() {
+ // Paper start
+ bootStrap(() -> {});
+ }
+ public static void bootStrap(Runnable runnable) {
+ // Paper end
createContents();
+ runnable.run(); // Paper
freeze();
validate(REGISTRY);
}
diff --git a/src/main/java/net/minecraft/data/worldgen/SurfaceRuleData.java b/src/main/java/net/minecraft/data/worldgen/SurfaceRuleData.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/data/worldgen/SurfaceRuleData.java
@ -118,10 +136,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/Bootstrap.java
+++ b/src/main/java/net/minecraft/server/Bootstrap.java
@@ -0,0 +0,0 @@ public class Bootstrap {
EntitySelectorOptions.bootStrap();
DispenseItemBehavior.bootStrap();
CauldronInteraction.bootStrap();
BuiltInRegistries.bootStrap();
+ net.minecraft.core.Registry.register(net.minecraft.core.registries.BuiltInRegistries.MATERIAL_CONDITION, new net.minecraft.resources.ResourceLocation("paper", "bedrock_condition_source"), net.minecraft.data.worldgen.SurfaceRuleData.PaperBedrockConditionSource.CODEC.codec()); // Paper - register custom flat bedrock thing. TODO is this the best place to do this?
- BuiltInRegistries.bootStrap();
+ // Paper start - register custom flat bedrock
+ BuiltInRegistries.bootStrap(() -> {
+ net.minecraft.core.Registry.register(net.minecraft.core.registries.BuiltInRegistries.MATERIAL_CONDITION, new net.minecraft.resources.ResourceLocation("paper", "bedrock_condition_source"), net.minecraft.data.worldgen.SurfaceRuleData.PaperBedrockConditionSource.CODEC.codec());
+ });
+ // Paper end
Bootstrap.wrapStreams();
}
// CraftBukkit start - easier than fixing the decompile

View file

@ -39,6 +39,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
}
};
diff --git a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
+++ b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
@@ -0,0 +0,0 @@ public class BuiltInRegistries {
LOADERS.put(resourceLocation, () -> {
return initializer.run(registry);
});
- WRITABLE_REGISTRY.register(key, registry, lifecycle);
+ WRITABLE_REGISTRY.register((ResourceKey) key, registry, lifecycle); // Paper - decompile fix
return registry;
}
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java

View file

@ -1143,7 +1143,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ .register(new TypeToken<Reference2IntMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2IntMap<?>>(Reference2IntOpenHashMap::new, Integer.TYPE))
+ .register(new TypeToken<Reference2LongMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2LongMap<?>>(Reference2LongOpenHashMap::new, Long.TYPE))
+ .register(new TypeToken<Table<?, ?, ?>>() {}, new TableSerializer())
+ .register(new StringRepresentableSerializer())
+ .register(StringRepresentableSerializer::isValidFor, new StringRepresentableSerializer())
+ .register(IntOr.Default.SERIALIZER)
+ .register(IntOr.Disabled.SERIALIZER)
+ .register(DoubleOrDefault.SERIALIZER)
@ -2476,6 +2476,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import net.minecraft.util.StringRepresentable;
+import net.minecraft.world.entity.MobCategory;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.spongepowered.configurate.serialize.ScalarSerializer;
+import org.spongepowered.configurate.serialize.SerializationException;
+
@ -2487,18 +2488,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+public final class StringRepresentableSerializer extends ScalarSerializer<StringRepresentable> {
+ private static final Map<Type, Function<String, StringRepresentable>> TYPES = Collections.synchronizedMap(Map.ofEntries(
+ Map.entry(MobCategory.class, s -> {
+ for (MobCategory value : MobCategory.values()) {
+ createEntry(MobCategory.class)
+ ));
+
+ public StringRepresentableSerializer() {
+ super(StringRepresentable.class);
+ }
+
+ public static boolean isValidFor(final Type type) {
+ return TYPES.containsKey(type);
+ }
+
+ private static <E extends Enum<E> & StringRepresentable> Map.Entry<Type, Function<String, @Nullable StringRepresentable>> createEntry(Class<E> type) {
+ return Map.entry(type, s -> {
+ for (E value : type.getEnumConstants()) {
+ if (value.getSerializedName().equals(s)) {
+ return value;
+ }
+ }
+ return null;
+ })
+ ));
+
+ public StringRepresentableSerializer() {
+ super(StringRepresentable.class);
+ });
+ }
+
+ @Override