Skip to content

Commit a403977

Browse files
committed
fix registry
1 parent 6f89cbb commit a403977

4 files changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--- a/net/minecraft/core/registries/BuiltInRegistries.java
2+
+++ b/net/minecraft/core/registries/BuiltInRegistries.java
3+
@@ -336,6 +_,7 @@
4+
public static final Registry<MapCodec<? extends DialogBody>> DIALOG_BODY_TYPE = registerSimple(Registries.DIALOG_BODY_TYPE, DialogBodyTypes::bootstrap);
5+
public static final Registry<Consumer<GameTestHelper>> TEST_FUNCTION = registerSimple(Registries.TEST_FUNCTION, BuiltinTestFunctions::bootstrap);
6+
public static final Registry<? extends Registry<?>> REGISTRY = WRITABLE_REGISTRY;
7+
+ private static boolean hasInitialised = false;
8+
// Paper start - add built-in registry conversions
9+
public static final io.papermc.paper.registry.data.util.Conversions STATIC_ACCESS_CONVERSIONS = new io.papermc.paper.registry.data.util.Conversions(
10+
new net.minecraft.resources.RegistryOps.HolderLookupAdapter(net.minecraft.server.RegistryLayer.STATIC_ACCESS)
11+
@@ -381,14 +_,19 @@
12+
}
13+
public static void bootStrap(Runnable runnable) {
14+
// Paper end
15+
- REGISTRY.freeze(); // Paper - freeze main registry early
16+
+ // REGISTRY.freeze(); // Paper - freeze main registry early // Tenet - not freeze
17+
createContents();
18+
runnable.run(); // Paper
19+
freeze();
20+
validate(REGISTRY);
21+
}
22+
23+
- private static void createContents() {
24+
+ public static void createContents() {
25+
+ if (hasInitialised) {
26+
+ return;
27+
+ }
28+
+
29+
+ hasInitialised = true;
30+
// Paper start - class-load org.bukkit.Registry
31+
// we have to class-load Registry here to create all the CraftRegistry instances
32+
// that will be created when Registry is class-loaded before RegistryAccess#getRegistry
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--- a/net/minecraft/core/registries/Registries.java
2+
+++ b/net/minecraft/core/registries/Registries.java
3+
@@ -294,11 +_,28 @@
4+
return ResourceKey.createRegistryKey(ResourceLocation.withDefaultNamespace(name));
5+
}
6+
7+
+ // Vanilla doesn't mark namespaces in the directories of tags and dynamic registry elements at all,
8+
+ // so we prepend the directories with the namespace if it's a modded registry id.
9+
public static String elementsDirPath(ResourceKey<? extends Registry<?>> registryKey) {
10+
- return registryKey.location().getPath();
11+
+ String original = registryKey.location().getPath();
12+
+ ResourceLocation id = registryKey.registry();
13+
+
14+
+ if (!id.getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE)) {
15+
+ return id.getNamespace() + "/" + id.getPath();
16+
+ }
17+
+ return original;
18+
}
19+
20+
+ // Vanilla doesn't mark namespaces in the directories of tags and dynamic registry elements at all,
21+
+ // so we prepend the directories with the namespace if it's a modded registry id.
22+
public static String tagsDirPath(ResourceKey<? extends Registry<?>> registryKey) {
23+
- return "tags/" + registryKey.location().getPath();
24+
+ String original = "tags/" + registryKey.location().getPath();
25+
+ ResourceLocation id = registryKey.registry();
26+
+
27+
+ if (!id.getNamespace().equals(ResourceLocation.DEFAULT_NAMESPACE)) {
28+
+ return "tags/" + id.getNamespace() + "/" + id.getPath();
29+
+ }
30+
+
31+
+ return original;
32+
}
33+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- a/net/minecraft/server/Bootstrap.java
2+
+++ b/net/minecraft/server/Bootstrap.java
3+
@@ -55,11 +_,7 @@
4+
EntitySelectorOptions.bootStrap();
5+
DispenseItemBehavior.bootStrap();
6+
CauldronInteraction.bootStrap();
7+
- // Paper start
8+
- BuiltInRegistries.bootStrap(() -> {
9+
- io.papermc.paper.world.worldgen.OptionallyFlatBedrockConditionSource.bootstrap(); // Paper - Flat bedrock generator settings
10+
- });
11+
- // Paper end
12+
+ BuiltInRegistries.createContents();
13+
CreativeModeTabs.validate();
14+
wrapStreams();
15+
bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis());
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--- a/net/minecraft/server/Main.java
2+
+++ b/net/minecraft/server/Main.java
3+
@@ -28,6 +_,7 @@
4+
import net.minecraft.commands.Commands;
5+
import net.minecraft.core.Registry;
6+
import net.minecraft.core.RegistryAccess;
7+
+import net.minecraft.core.registries.BuiltInRegistries;
8+
import net.minecraft.core.registries.Registries;
9+
import net.minecraft.nbt.NbtException;
10+
import net.minecraft.nbt.ReportedNbtException;
11+
@@ -44,6 +_,7 @@
12+
import net.minecraft.util.profiling.jfr.JvmProfiler;
13+
import net.minecraft.util.worldupdate.WorldUpgrader;
14+
import net.minecraft.world.flag.FeatureFlags;
15+
+import net.minecraft.world.item.CreativeModeTabs;
16+
import net.minecraft.world.level.GameRules;
17+
import net.minecraft.world.level.LevelSettings;
18+
import net.minecraft.world.level.WorldDataConfiguration;
19+
@@ -110,6 +_,15 @@
20+
io.papermc.paper.plugin.PluginInitializerManager.load(optionSet); // Paper
21+
Bootstrap.bootStrap();
22+
Bootstrap.validate();
23+
+ // Freeze the registries on the server
24+
+ LOGGER.debug("Freezing registries");
25+
+
26+
+ // Paper start
27+
+ BuiltInRegistries.bootStrap(() -> {
28+
+ io.papermc.paper.world.worldgen.OptionallyFlatBedrockConditionSource.bootstrap(); // Paper - Flat bedrock generator settings
29+
+ });
30+
+ // Paper end
31+
+ CreativeModeTabs.validate();
32+
Util.startTimerHackThread();
33+
Path path1 = Paths.get("server.properties");
34+
DedicatedServerSettings dedicatedServerSettings = new DedicatedServerSettings(optionSet); // CraftBukkit - CLI argument support

0 commit comments

Comments
 (0)