Skip to content

Commit

Permalink
Merge pull request #5
Browse files Browse the repository at this point in the history
Capture Registries even earlier
  • Loading branch information
gniftygnome authored Jun 18, 2023
2 parents a190f3b + 02a8eea commit b666d7d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class BiomeCoordinator {
protected static DynamicRegistryManager.Immutable registryManager;

public static void setRegistryManager(CombinedDynamicRegistries<ServerDynamicRegistryType> combinedDynamicRegistries) {
// Called by biolith$earlyCaptureRegistries() in MixinMinecraftServer so we can set this really early.
// Called by biolith$earlyCaptureRegistries() in MixinMinecraftServer and MixinServerLoad so we can set this really early.
registryManager = combinedDynamicRegistries.getCombinedRegistryManager();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.terraformersmc.biolith.impl.mixin;

import net.minecraft.registry.CombinedDynamicRegistries;
import net.minecraft.registry.ServerDynamicRegistryType;
import net.minecraft.server.SaveLoader;

import com.terraformersmc.biolith.impl.biome.BiomeCoordinator;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(value=SaveLoader.class, priority = 500)
public class MixinSaveLoader {
@Shadow @Final private CombinedDynamicRegistries<ServerDynamicRegistryType> combinedDynamicRegistries;

@ModifyVariable(method = "<init>", argsOnly = true, at = @At(value = "INVOKE", target = "Ljava/lang/Record;<init>()V", shift = At.Shift.AFTER))
private CombinedDynamicRegistries<ServerDynamicRegistryType> biolith$earlyCaptureRegistries(
CombinedDynamicRegistries<ServerDynamicRegistryType> combinedDynamicRegistries
) {
System.out.println("Biolith: early capture registries");
// We need the registries really early in case TerraBlender calls us before the Fabric server start event.
BiomeCoordinator.setRegistryManager(combinedDynamicRegistries);
return combinedDynamicRegistries;
}
}
1 change: 1 addition & 0 deletions src/main/resources/biolith.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"MixinEntries",
"MixinMinecraftServer",
"MixinMultiNoiseBiomeSource",
"MixinSaveLoader",
"MixinSearchTree",
"MixinServerWorld",
"MixinSurfaceBuilder",
Expand Down

0 comments on commit b666d7d

Please sign in to comment.