Waystones (Fabric Edition)

Waystones (Fabric Edition)

4M Downloads

[1.19.3 Forge/Fabric] Update Repurposed Structures json conditions compatibility

TelepathicGrunt opened this issue ยท 1 comments

commented

Hello, I would make a PR but I'm having great difficulty with forking Waystones right now. Though the fix to make our mods work together properly is easy as I was able to work with an old clone I had of Waystones. At some point, it looks like 1.19.3 froze the custom registry I use and causes RS villages to not respect Forge waystone's config while Fabric waystones just crashes.

Here's the fix the would work best for this!

Delete this block of code:

// Registers a condition for repurposed structures compat
registryAccess.registry(ResourceKey.createRegistryKey(new ResourceLocation("repurposed_structures", "json_conditions")))
.ifPresent(registry -> {
ResourceLocation conditionId = new ResourceLocation("waystones", "config");
Supplier<Boolean> condition = () -> WaystonesConfig.getActive().spawnInVillages() || WaystonesConfig.getActive()
.forceSpawnInVillages();
if (!registry.containsKey(conditionId)) {
Registry.register(registry, conditionId, condition);
}
});

Then in https://github.com/TwelveIterationMods/Waystones/blob/1.19.x/forge/src/main/java/net/blay09/mods/waystones/ForgeWaystones.java
Change it to this:

 public ForgeWaystones() {
        Balm.initialize(Waystones.MOD_ID, Waystones::initialize);
        DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> BalmClient.initialize(Waystones.MOD_ID, WaystonesClient::initialize));

        Balm.initializeIfLoaded(Compat.THEONEPROBE, "net.blay09.mods.waystones.compat.TheOneProbeAddon");

        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        RS_CONDITIONS_REGISTRY.register(modEventBus);
    }

    public static final DeferredRegister<Supplier<Boolean>> RS_CONDITIONS_REGISTRY = DeferredRegister.createOptional(
            new ResourceLocation("repurposed_structures", "json_conditions"), "waystones");

    public static final RegistryObject<Supplier<Boolean>> WAYSTONE_CONFIG_CONDITION = RS_CONDITIONS_REGISTRY.register(
            "config", () -> () -> WaystonesConfig.getActive().spawnInVillages() || WaystonesConfig.getActive().forceSpawnInVillages());

And in https://github.com/TwelveIterationMods/Waystones/blob/1.19.x/fabric/src/main/java/net/blay09/mods/waystones/FabricWaystones.java
Change it to this:

    @Override
    public void onInitialize() {
        Balm.initialize(Waystones.MOD_ID, Waystones::initialize);
        compatSetup();
    }

    public void compatSetup() {
        // Registers a condition for repurposed structures compat
        BuiltInRegistries.REGISTRY.getOptional(new ResourceLocation("repurposed_structures", "json_conditions"))
                .ifPresent(registry -> Registry.register(
                        (Registry<Supplier<Boolean>>)registry,
                        new ResourceLocation("waystones", "config"),
                        () -> WaystonesConfig.getActive().spawnInVillages() || WaystonesConfig.getActive().forceSpawnInVillages()));
    }

This should address crash on 1.19.3 Fabric and make sure Forge's conditions gets registered correctly. Tested in dev with v6.3.14 Repurposed Structures that I have not yet released. I am able to verify that the Waystones config is working and can disable the Waystone pieces from appearing in RS villages for both forge and fabric.

Of course you can reformat this to however you would like it. Just the registration of the condition has to happen in mod init to avoid the registry freezing issues. Hope this helps!

commented

Awesome, thanks for completing this!