diff --git a/common/src/main/resources/assets/pfm/lang/en_us.json b/common/src/main/resources/assets/pfm/lang/en_us.json index d8e64dbce..159beced5 100644 --- a/common/src/main/resources/assets/pfm/lang/en_us.json +++ b/common/src/main/resources/assets/pfm/lang/en_us.json @@ -1264,8 +1264,8 @@ "keybindings.category.pfm": "Paladin's Furniture", "key.pfm.toiletUse": "Use Toilet", - "pfm.compat.failure.reason.arrpNotFound": "To use Sandwichable and Paladin's Furniture Mod together you will need to install ARRP. Please download it, place it on your mods folder, then re-launch the game.", - "pfm.compat.failure.arrpDownload": "Download ARRP", + "pfm.compat.failure.reason.indiumNotFound": "To use Paladin's Furniture mod with Sodium you will need Indium. Please download the latest version of it, place it on your mods folder, then re-launch the game.", + "pfm.compat.failure.indiumDownload": "Download Indium", "pfm.compat.failure.title": "Paladin's Furniture Mod failed to load!", "emi.category.pfm.freezer": "Freezing", diff --git a/fabric/src/main/java/com/unlikepaladin/pfm/mixin/fabric/PFMTitleScreenMixin.java b/fabric/src/main/java/com/unlikepaladin/pfm/mixin/fabric/PFMTitleScreenMixin.java new file mode 100644 index 000000000..57b8a4310 --- /dev/null +++ b/fabric/src/main/java/com/unlikepaladin/pfm/mixin/fabric/PFMTitleScreenMixin.java @@ -0,0 +1,58 @@ +package com.unlikepaladin.pfm.mixin.fabric; + +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.ConfirmScreen; +import net.minecraft.client.gui.screen.TitleScreen; +import net.minecraft.text.TranslatableText; +import net.minecraft.util.Formatting; +import net.minecraft.util.Util; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.net.URI; +import java.net.URISyntaxException; + +@Mixin(TitleScreen.class) +public class PFMTitleScreenMixin { + @Unique + private static boolean pfm$firstInit; + + @Inject(method = "init", at = @At("RETURN")) + public void pfm$showMissingDependencyScreen(CallbackInfo ci) { + if (pfm$firstInit) { + return; + } + + pfm$firstInit = true; + + String reason; + + if (FabricLoader.getInstance().isModLoaded("sodium") && !FabricLoader.getInstance().isModLoaded("indium")) { + reason = "pfm.compat.failure.reason.indiumNotFound"; + } + else { + return; + } + + MinecraftClient.getInstance().setScreen(new ConfirmScreen( + (boolean accepted) -> { + if (accepted) { + try { + Util.getOperatingSystem().open(new URI("https://modrinth.com/mod/indium/versions?g=1.17.1")); + } catch (URISyntaxException e) { + throw new IllegalStateException(e); + } + } else { + MinecraftClient.getInstance().stop(); + } + }, + new TranslatableText("pfm.compat.failure.title").formatted(Formatting.RED), + new TranslatableText(reason), + new TranslatableText("pfm.compat.failure.indiumNotFound"), + new TranslatableText("menu.quit"))); + } +} diff --git a/fabric/src/main/resources/pfm.mixins.json b/fabric/src/main/resources/pfm.mixins.json index 81ab8231d..025c1c04c 100755 --- a/fabric/src/main/resources/pfm.mixins.json +++ b/fabric/src/main/resources/pfm.mixins.json @@ -3,6 +3,7 @@ "package": "com.unlikepaladin.pfm.mixin.fabric", "compatibilityLevel": "JAVA_16", "client": [ + "PFMTitleScreenMixin" ], "mixins": [ "PFMAbstractTagProvider$ObjectBuilderMixin",