-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'architectury-1.17.1' into architectury-1.18.1
- Loading branch information
Showing
3 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
fabric/src/main/java/com/unlikepaladin/pfm/mixin/fabric/PFMTitleScreenMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters