Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on Fabric API #10

Closed
LoganDark opened this issue Apr 6, 2022 · 4 comments
Closed

Remove dependency on Fabric API #10

LoganDark opened this issue Apr 6, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@LoganDark
Copy link

LoganDark commented Apr 6, 2022

Currently, the only Fabric API features this mod uses are the lifecycle events. The dependency is so small that it should be able to be removed with just a couple mixins. Would you be open to doing that?

@Patbox Patbox added the enhancement New feature or request label Apr 7, 2022
@Patbox
Copy link
Member

Patbox commented Jun 20, 2022

It only depends on fabric-lifecycle-events-v1 submodule now so it should be simpler to jar in jar all required dependencies

@Patbox Patbox closed this as completed Jun 20, 2022
@sakurawald
Copy link

sakurawald commented Sep 29, 2024

The fabric-api is required, fabric-api not only provides some server lifecycle events, but also the registry sync and some other patches.

The test envirionment

the version in git commit: 8aeaa5f69333156d31ad2c5e68e6fa3e88fe1784
run the gradle task `runTestmodServer`

If you modify the build.gradle to only include the min set of fabric-api modules. (and remember to remove the fabric-api dependency in fantasy.mixins.json):

//  modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
  Set<String> apiModules = [
      "fabric-api-base",
      "fabric-command-api-v1",
      "fabric-lifecycle-events-v1"
  ]
// Add each module as a dependency
  apiModules.forEach {
    include(modImplementation(fabricApi.module(it, project.fabric_version)))
  }

You will get:

[09:03:36] [main/INFO] (FabricLoader/GameProvider) Loading Minecraft 1.21 with Fabric Loader 0.15.11
[09:03:36] [ForkJoinPool-1-worker-1/WARN] (FabricLoader/Metadata) Mod fantasy-test uses the version ${version} which isn't compatible with Loader's extended semantic version format (Could not parse version number component '${version}'!), SemVer is recommended for reliably evaluating dependencies and prioritizing newer version
[09:03:36] [main/INFO] (FabricLoader) Loading 11 mods:
	- fabric-api-base 0.4.42+6573ed8c90
	- fabric-command-api-v1 1.2.48+f71b366f90
	- fabric-command-api-v2 2.2.27+6a6dfa1990
	- fabric-lifecycle-events-v1 2.3.9+98a7dbbb90
	- fabric-networking-api-v1 4.1.0+686dcdce90
	- fabricloader 0.15.11
	- fantasy 0.6.4+1.21
	- fantasy-test ${version}
	- java 21
	- minecraft 1.21
	- mixinextras 0.3.5
[09:03:36] [main/INFO] (FabricLoader/Mixin) SpongePowered MIXIN Subsystem Version=0.8.5 Source=file:/home/sakurawald/.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.13.3+mixin.0.8.5/9527e6b0d2449408958fd1302594dc65ec5ade9c/sponge-mixin-0.13.3+mixin.0.8.5.jar Service=Knot/Fabric Env=SERVER
[09:03:37] [main/INFO] (FabricLoader/Mixin) Loaded Fabric development mappings for mixin remapper!
[09:03:37] [main/INFO] (FabricLoader/Mixin) Compatibility level set to JAVA_21
[09:03:39] [main/INFO] (FabricLoader/MixinExtras|Service) Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.3.5).
[09:03:41] [main/ERROR] (Minecraft) Failed to start the minecraft server
java.lang.RuntimeException: Could not execute entrypoint stage 'main' due to errors, provided by 'fantasy'!
	at net.fabricmc.loader.impl.FabricLoaderImpl.lambda$invokeEntrypoints$2(FabricLoaderImpl.java:388) ~[fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.util.ExceptionUtil.gatherExceptions(ExceptionUtil.java:33) ~[fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:386) ~[fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.game.minecraft.Hooks.startServer(Hooks.java:63) ~[fabric-loader-0.15.11.jar:?]
	at net.minecraft.server.Main.main(Main.java:111) [minecraft-merged-489b46b56f-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.loader.impl.launch.knot.KnotServer.main(KnotServer.java:23) [fabric-loader-0.15.11.jar:?]
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) [dev-launch-injector-0.2.1+build.8.jar:?]
Caused by: java.lang.IllegalStateException: Registry is already frozen (trying to add key ResourceKey[minecraft:worldgen/chunk_generator / fantasy:void])
	at net.minecraft.registry.SimpleRegistry.assertNotFrozen(SimpleRegistry.java:122) ~[minecraft-merged-489b46b56f-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.registry.SimpleRegistry.add(SimpleRegistry.java:128) ~[minecraft-merged-489b46b56f-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.registry.Registry.register(Registry.java:130) ~[minecraft-merged-489b46b56f-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.registry.Registry.register(Registry.java:126) ~[minecraft-merged-489b46b56f-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at xyz.nucleoid.fantasy.FantasyInitializer.onInitialize(FantasyInitializer.java:13) ~[main/:?]
	at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:384) ~[fabric-loader-0.15.11.jar:?]
	... 6 more

If we try to fix this and modified the code to

public final class FantasyInitializer implements ModInitializer {
    @Override
    public void onInitialize() {
        RemoveFromRegistry sr = (RemoveFromRegistry) Registries.CHUNK_GENERATOR;
        sr.fantasy$setFrozen(false);
        Registry.register(Registries.CHUNK_GENERATOR, Identifier.of(Fantasy.ID, "void"), VoidChunkGenerator.CODEC);
        Registry.register(Registries.CHUNK_GENERATOR, Identifier.of(Fantasy.ID, "transient"), TransientChunkGenerator.CODEC);
        sr.fantasy$setFrozen(true);
    }
}

You still get:

09:10:20: Executing 'runTestmodServer'...


> Configure project :
Fabric Loom: 1.6.12

> Task :compileJava

> Task :processResources UP-TO-DATE
> Task :classes
> Task :compileTestmodJava UP-TO-DATE
> Task :generateDLIConfig
> Task :generateLog4jConfig
> Task :generateRemapClasspath UP-TO-DATE
> Task :configureLaunch
> Task :processTestmodResources UP-TO-DATE
> Task :testmodClasses UP-TO-DATE
Note: /home/sakurawald/Workspace/github/fantasy/src/main/java/xyz/nucleoid/fantasy/util/SafeIterator.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :runTestmodServer
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
[09:10:21] [main/INFO] (FabricLoader/GameProvider) Loading Minecraft 1.21 with Fabric Loader 0.15.11
[09:10:21] [ForkJoinPool-1-worker-1/WARN] (FabricLoader/Metadata) Mod fantasy-test uses the version ${version} which isn't compatible with Loader's extended semantic version format (Could not parse version number component '${version}'!), SemVer is recommended for reliably evaluating dependencies and prioritizing newer version
[09:10:21] [main/INFO] (FabricLoader) Loading 10 mods:
	- fabric-api-base 0.4.42+6573ed8c90
	- fabric-command-api-v1 1.2.48+f71b366f90
	- fabric-command-api-v2 2.2.27+6a6dfa1990
	- fabric-lifecycle-events-v1 2.3.9+98a7dbbb90
	- fabricloader 0.15.11
	- fantasy 0.6.4+1.21
	- fantasy-test ${version}
	- java 21
	- minecraft 1.21
	- mixinextras 0.3.5
[09:10:21] [main/INFO] (FabricLoader/Mixin) SpongePowered MIXIN Subsystem Version=0.8.5 Source=file:/home/sakurawald/.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.13.3+mixin.0.8.5/9527e6b0d2449408958fd1302594dc65ec5ade9c/sponge-mixin-0.13.3+mixin.0.8.5.jar Service=Knot/Fabric Env=SERVER
[09:10:21] [main/INFO] (FabricLoader/Mixin) Loaded Fabric development mappings for mixin remapper!
[09:10:21] [main/INFO] (FabricLoader/Mixin) Compatibility level set to JAVA_17
[09:10:21] [main/INFO] (FabricLoader/Mixin) Compatibility level set to JAVA_21
[09:10:23] [main/INFO] (FabricLoader/MixinExtras|Service) Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.3.5).
[09:10:26] [main/INFO] (Minecraft) Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD]
[09:10:26] [main/WARN] (Minecraft) Missing data pack fabric
[09:10:26] [main/WARN] (Minecraft) Missing data pack fabric-convention-tags-v2
[09:10:26] [main/WARN] (Minecraft) Missing data pack fabric-gametest-api-v1
[09:10:26] [main/WARN] (Minecraft) Missing data pack fantasy
[09:10:27] [main/INFO] (Minecraft) Loaded 1290 recipes
[09:10:27] [main/INFO] (Minecraft) Loaded 1399 advancements
[09:10:27] [Server thread/INFO] (Minecraft) Starting minecraft server version 1.21
[09:10:27] [Server thread/INFO] (Minecraft) Loading properties
[09:10:27] [Server thread/INFO] (Minecraft) Default game type: SURVIVAL
[09:10:27] [Server thread/INFO] (Minecraft) Generating keypair
[09:10:27] [Server thread/INFO] (Minecraft) Starting Minecraft server on *:25565
[09:10:27] [Server thread/INFO] (Minecraft) Using epoll channel type
[09:10:28] [Server thread/INFO] (Minecraft) Preparing level "world"
[09:10:28] [Server thread/INFO] (Minecraft) Preparing start region for dimension minecraft:overworld
[09:10:28] [Worker-Main-3/INFO] (Minecraft) Preparing spawn area: 0%
[09:10:28] [Server thread/INFO] (Minecraft) Time elapsed: 216 ms
[09:10:28] [Server thread/INFO] (Minecraft) Done (0.892s)! For help, type "help"
[09:10:28] [Server thread/ERROR] (Minecraft) Encountered an unexpected exception
 java.lang.NullPointerException: invalid dimension type ResourceKey[minecraft:dimension_type / fantasy:default]
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:921) ~[guava-32.1.2-jre.jar:?]
	at xyz.nucleoid.fantasy.RuntimeWorldConfig.resolveDimensionType(RuntimeWorldConfig.java:330) ~[main/:?]
	at xyz.nucleoid.fantasy.RuntimeWorldConfig.createDimensionOptions(RuntimeWorldConfig.java:317) ~[main/:?]
	at xyz.nucleoid.fantasy.RuntimeWorldManager.add(RuntimeWorldManager.java:32) ~[main/:?]
	at xyz.nucleoid.fantasy.Fantasy.addTemporaryWorld(Fantasy.java:175) ~[main/:?]
	at xyz.nucleoid.fantasy.Fantasy.openTemporaryWorld(Fantasy.java:127) ~[main/:?]
	at xyz.nucleoid.fantasy.Fantasy.openTemporaryWorld(Fantasy.java:111) ~[main/:?]
	at xyz.nucleoid.fantasy.test.FantasyInitializer.lambda$onInitialize$0(FantasyInitializer.java:38) ~[testmod/:?]
	at net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents.lambda$static$2(ServerLifecycleEvents.java:49) ~[fabric-lifecycle-events-v1-2.3.9+98a7dbbb90.jar:?]
	at net.minecraft.server.MinecraftServer.handler$zze000$fabric-lifecycle-events-v1$afterSetupServer(MinecraftServer.java:2142) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:668) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:281) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
[09:10:29] [Server thread/ERROR] (Minecraft) This crash report has been saved to: /home/sakurawald/Workspace/github/fantasy/run/crash-reports/crash-2024-09-29_09.10.29-server.txt
[09:10:29] [Server thread/INFO] (Minecraft) Stopping server
[09:10:29] [Server thread/INFO] (Minecraft) Saving players
[09:10:29] [Server thread/INFO] (Minecraft) Saving worlds
[09:10:29] [Server thread/INFO] (Minecraft) Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[09:10:29] [Server thread/INFO] (Minecraft) Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
[09:10:29] [Server thread/INFO] (Minecraft) Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
[09:10:29] [Server thread/INFO] (Minecraft) ThreadedAnvilChunkStorage (world): All chunks are saved
[09:10:29] [Server thread/INFO] (Minecraft) ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[09:10:29] [Server thread/INFO] (Minecraft) ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[09:10:29] [Server thread/INFO] (Minecraft) ThreadedAnvilChunkStorage: All dimensions are saved

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 9s
8 actionable tasks: 4 executed, 4 up-to-date
09:10:29: Execution finished 'runTestmodServer'.

If you comment out this assert statement:

    /**
     * Resolves the dimension type from the server
     *
     * @return The dimension type
     */
    private RegistryEntry<DimensionType> resolveDimensionType(MinecraftServer server) {
        var dimensionType = this.dimensionType;
        if (dimensionType == null) {
            dimensionType = server.getRegistryManager().get(RegistryKeys.DIMENSION_TYPE).getEntry(this.dimensionTypeKey).orElse(null);
//            Preconditions.checkNotNull(dimensionType, "invalid dimension type " + this.dimensionTypeKey);
        }
        return dimensionType;
    }

You will get:

09:12:23: Executing 'runTestmodServer'...


> Configure project :
Fabric Loom: 1.6.12

> Task :compileJava

> Task :processResources UP-TO-DATE
> Task :classes
> Task :compileTestmodJava UP-TO-DATE
> Task :generateDLIConfig
> Task :generateLog4jConfig
> Task :generateRemapClasspath UP-TO-DATE
> Task :configureLaunch
> Task :processTestmodResources UP-TO-DATE
> Task :testmodClasses UP-TO-DATE
Note: /home/sakurawald/Workspace/github/fantasy/src/main/java/xyz/nucleoid/fantasy/util/SafeIterator.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :runTestmodServer
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release
[09:12:25] [main/INFO] (FabricLoader/GameProvider) Loading Minecraft 1.21 with Fabric Loader 0.15.11
[09:12:25] [ForkJoinPool-1-worker-1/WARN] (FabricLoader/Metadata) Mod fantasy-test uses the version ${version} which isn't compatible with Loader's extended semantic version format (Could not parse version number component '${version}'!), SemVer is recommended for reliably evaluating dependencies and prioritizing newer version
[09:12:25] [main/INFO] (FabricLoader) Loading 10 mods:
	- fabric-api-base 0.4.42+6573ed8c90
	- fabric-command-api-v1 1.2.48+f71b366f90
	- fabric-command-api-v2 2.2.27+6a6dfa1990
	- fabric-lifecycle-events-v1 2.3.9+98a7dbbb90
	- fabricloader 0.15.11
	- fantasy 0.6.4+1.21
	- fantasy-test ${version}
	- java 21
	- minecraft 1.21
	- mixinextras 0.3.5
[09:12:25] [main/INFO] (FabricLoader/Mixin) SpongePowered MIXIN Subsystem Version=0.8.5 Source=file:/home/sakurawald/.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.13.3+mixin.0.8.5/9527e6b0d2449408958fd1302594dc65ec5ade9c/sponge-mixin-0.13.3+mixin.0.8.5.jar Service=Knot/Fabric Env=SERVER
[09:12:25] [main/INFO] (FabricLoader/Mixin) Loaded Fabric development mappings for mixin remapper!
[09:12:25] [main/INFO] (FabricLoader/Mixin) Compatibility level set to JAVA_17
[09:12:25] [main/INFO] (FabricLoader/Mixin) Compatibility level set to JAVA_21
[09:12:27] [main/INFO] (FabricLoader/MixinExtras|Service) Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.3.5).
[09:12:29] [main/INFO] (Minecraft) Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD]
[09:12:30] [main/INFO] (Minecraft) Loaded 1290 recipes
[09:12:30] [main/INFO] (Minecraft) Loaded 1399 advancements
[09:12:30] [Server thread/INFO] (Minecraft) Starting minecraft server version 1.21
[09:12:30] [Server thread/INFO] (Minecraft) Loading properties
[09:12:30] [Server thread/INFO] (Minecraft) Default game type: SURVIVAL
[09:12:30] [Server thread/INFO] (Minecraft) Generating keypair
[09:12:30] [Server thread/INFO] (Minecraft) Starting Minecraft server on *:25565
[09:12:30] [Server thread/INFO] (Minecraft) Using epoll channel type
[09:12:30] [Server thread/INFO] (Minecraft) Preparing level "world"
[09:12:31] [Server thread/INFO] (Minecraft) Preparing start region for dimension minecraft:overworld
[09:12:31] [Worker-Main-9/INFO] (Minecraft) Preparing spawn area: 0%
[09:12:31] [Server thread/INFO] (Minecraft) Time elapsed: 210 ms
[09:12:31] [Server thread/INFO] (Minecraft) Done (0.891s)! For help, type "help"
[09:12:31] [Server thread/ERROR] (Minecraft) Encountered an unexpected exception
 java.lang.NullPointerException: Cannot invoke "net.minecraft.registry.entry.RegistryEntry.value()" because "dimensionEntry" is null
	at net.minecraft.world.World.<init>(World.java:143) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.server.world.ServerWorld.<init>(ServerWorld.java:229) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at xyz.nucleoid.fantasy.RuntimeWorld.<init>(RuntimeWorld.java:30) ~[main/:?]
	at xyz.nucleoid.fantasy.test.CustomWorld.<init>(CustomWorld.java:17) ~[testmod/:?]
	at xyz.nucleoid.fantasy.RuntimeWorldManager.add(RuntimeWorldManager.java:49) ~[main/:?]
	at xyz.nucleoid.fantasy.Fantasy.addTemporaryWorld(Fantasy.java:175) ~[main/:?]
	at xyz.nucleoid.fantasy.Fantasy.openTemporaryWorld(Fantasy.java:127) ~[main/:?]
	at xyz.nucleoid.fantasy.Fantasy.openTemporaryWorld(Fantasy.java:111) ~[main/:?]
	at xyz.nucleoid.fantasy.test.FantasyInitializer.lambda$onInitialize$0(FantasyInitializer.java:38) ~[testmod/:?]
	at net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents.lambda$static$2(ServerLifecycleEvents.java:49) ~[fabric-lifecycle-events-v1-2.3.9+98a7dbbb90.jar:?]
	at net.minecraft.server.MinecraftServer.handler$zze000$fabric-lifecycle-events-v1$afterSetupServer(MinecraftServer.java:2142) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:668) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:281) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
[09:12:31] [Server thread/ERROR] (Minecraft) This crash report has been saved to: /home/sakurawald/Workspace/github/fantasy/run/crash-reports/crash-2024-09-29_09.12.31-server.txt
[09:12:31] [Server thread/INFO] (Minecraft) Stopping server
[09:12:31] [Server thread/INFO] (Minecraft) Saving players
[09:12:31] [Server thread/INFO] (Minecraft) Saving worlds
[09:12:32] [Server thread/INFO] (Minecraft) Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[09:12:32] [Server thread/INFO] (Minecraft) Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
[09:12:32] [Server thread/INFO] (Minecraft) Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
[09:12:32] [Server thread/ERROR] (Minecraft) Exception stopping the server
 java.lang.IllegalStateException: Trying to access unbound value 'ResourceKey[minecraft:dimension / fantasy:6c8gnmm0uixgwxvi]' from registry net.minecraft.registry.SimpleRegistry$1@1917eb2a
	at net.minecraft.registry.entry.RegistryEntry$Reference.value(RegistryEntry.java:180) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180) ~[?:?]
	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) ~[?:?]
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[?:?]
	at it.unimi.dsi.fastutil.objects.ObjectArrayList$Spliterator.forEachRemaining(ObjectArrayList.java:955) ~[fastutil-8.5.12.jar:?]
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[?:?]
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[?:?]
	at net.minecraft.world.dimension.DimensionOptionsRegistryHolder.<init>(DimensionOptionsRegistryHolder.java:62) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.world.level.WorldGenSettings.encode(WorldGenSettings.java:24) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.world.level.LevelProperties.updateProperties(LevelProperties.java:256) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.world.level.LevelProperties.cloneWorldNbt(LevelProperties.java:233) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.world.level.storage.LevelStorage$Session.backupLevelDataFile(LevelStorage.java:452) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.server.MinecraftServer.save(MinecraftServer.java:563) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.server.MinecraftServer.shutdown(MinecraftServer.java:620) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.server.dedicated.MinecraftDedicatedServer.shutdown(MinecraftDedicatedServer.java:561) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:735) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:281) ~[minecraft-merged-7ed2b35a4c-1.21-net.fabricmc.yarn.1_21.1.21+build.1-v2.jar:?]
	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]

Also, you can trigger this manually by issue the command /save-all

@sakurawald
Copy link

I found this pr in 1.20.4 branch, it seems like this pr fix this bug: 35f2e3a#diff-0be594c03dbbbe59526ede2044fd95993ca4954322fa8ea878e1c251b96c28df

The DimensionOptionsRegistryHolderMixin fixes the crash on executing /save-all in an environment without the installation of fabric-api.

However, this mixin is deleted in branch 1.21

@LoganDark
Copy link
Author

The fabric-api is required, fabric-api not only provides some server lifecycle events, but also the registry sync and some other patches.

Extracting individual modules out of fabric-api is for advanced users. It's not necessarily supported but to have the option is preferable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants