[Feature] openLink Helper Method
This commit is contained in:
parent
4c0ddad9aa
commit
96bfdc5afa
1 changed files with 14 additions and 0 deletions
|
@ -5,6 +5,9 @@ import org.betterx.ui.layout.components.*;
|
|||
import org.betterx.ui.layout.values.Value;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
|
@ -49,6 +52,17 @@ public abstract class LayoutScreen extends Screen {
|
|||
|
||||
protected abstract LayoutComponent<?, ?> initContent();
|
||||
|
||||
protected void openLink(String uri) {
|
||||
ConfirmLinkScreen cls = new ConfirmLinkScreen(bl -> {
|
||||
if (bl) {
|
||||
Util.getPlatform().openUri(uri);
|
||||
}
|
||||
this.minecraft.setScreen(this);
|
||||
}, uri, true);
|
||||
|
||||
Minecraft.getInstance().setScreen(cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void init() {
|
||||
super.init();
|
||||
|
|
Loading…
Reference in a new issue