v1.1.3: GUI左上角添加Git仓库与官网链接按钮(点击在系统浏览器打开)

这个提交包含在:
Lyizai
2026-08-17 11:12:20 +00:00
父节点 134a6e6f20
当前提交 8a2c4a21d8
共修改 3 个文件,包含 19 行新增和 3 行删除
@@ -17,6 +17,7 @@ import java.util.List;
import java.util.function.Consumer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
import net.minecraft.text.Text;
import net.minecraft.client.font.TextRenderer;
@@ -38,6 +39,9 @@ import net.minecraft.text.StringVisitable;
*/
public final class AutoStoreGui
extends Screen {
// ---- 外部链接 ----
private static final String GIT_REPO_URL = "https://git.bgjq.top/Lyizai/AutoStore/";
private static final String HOMEPAGE_URL = "https://8w.bgjq.top/";
private final AutoStoreModClient mod;
private final ExpansionConfig config;
private final ExpansionController controller;
@@ -99,6 +103,9 @@ extends Screen {
// ===== 顶部控制按钮 =====
int topX = this.panelX;
// 左上角外部链接按钮:Git 仓库与官网(点击在系统浏览器打开)
this.addDrawableChild(ButtonWidget.builder(Text.literal((String)"Git \u4ed3\u5e93"), button -> this.openUrl(GIT_REPO_URL)).dimensions(this.mapX, 8, 70, 16).build());
this.addDrawableChild(ButtonWidget.builder(Text.literal((String)"\u5b98\u7f51"), button -> this.openUrl(HOMEPAGE_URL)).dimensions(this.mapX + 76, 8, 50, 16).build());
ButtonWidget startButton = ButtonWidget.builder(Text.literal((String)"\u5f00\u59cb\u81ea\u52a8\u6269\u5730"), button -> this.start()).dimensions(topX, 34, 154, 30).build();
ButtonWidget stopButton = ButtonWidget.builder(Text.literal((String)"\u505c\u6b62"), button -> this.controller.stop()).dimensions(topX + 160, 34, 74, 30).build();
this.addDrawableChild(startButton);
@@ -158,6 +165,15 @@ extends Screen {
this.initializeMapView();
}
/** 在系统默认浏览器中打开外部链接(失败时静默忽略) */
private void openUrl(String url) {
try {
Util.getOperatingSystem().open(new java.net.URI(url));
} catch (Exception ignored) {
// 链接打开失败不影响界面正常使用
}
}
/** 创建整数输入框(初始值为 value,最多 12 位) */
private TextFieldWidget numberField(int value, int x, int y, int width) {
TextFieldWidget field = new TextFieldWidget(this.textRenderer, x, y, width, 20, Text.literal((String)""));
+1 -1
查看文件
@@ -1 +1 @@
{"schemaVersion":1,"id":"autostore","version":"1.1.2","name":"AutoStore","description":"","authors":[],"contact":{},"license":"All-Rights-Reserved","environment":"client","entrypoints":{"fabric-datagen":["autostore.client.AutoStoreModDataGenerator"],"client":["autostore.client.AutoStoreModClient"],"main":["autostore.AutoStoreMod"]},"mixins":["autostore.mixins.json",{"config":"autostore.client.mixins.json","environment":"client"}],"depends":{"fabricloader":">=0.16.14","fabric-api":"*","minecraft":"1.21.4"},"jars":[{"file":"META-INF/jars/baritone-api-fabric-1.13.1.jar"}]}
{"schemaVersion":1,"id":"autostore","version":"1.1.3","name":"AutoStore","description":"","authors":[],"contact":{},"license":"All-Rights-Reserved","environment":"client","entrypoints":{"fabric-datagen":["autostore.client.AutoStoreModDataGenerator"],"client":["autostore.client.AutoStoreModClient"],"main":["autostore.AutoStoreMod"]},"mixins":["autostore.mixins.json",{"config":"autostore.client.mixins.json","environment":"client"}],"depends":{"fabricloader":">=0.16.14","fabric-api":"*","minecraft":"1.21.4"},"jars":[{"file":"META-INF/jars/baritone-api-fabric-1.13.1.jar"}]}