From f634bddc37b19e5cb36f8ee12d8b2a60cbf7b232 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Thu, 27 Feb 2025 15:00:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=89=E9=92=AE=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/screens/ModSellWarningScreen.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/ModSellWarningScreen.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/ModSellWarningScreen.java index 6345f13d7..fd5f59832 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/ModSellWarningScreen.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/ModSellWarningScreen.java @@ -67,6 +67,7 @@ public class ModSellWarningScreen extends WarningScreen { private static final Component CHECK = Component.translatable("multiplayer.superbwarfare.warning.check"); private static final Component NARRATION = TITLE.copy().append("\n").append(CONTENT); private final Screen lastScreen; + private AbstractButton proceedButton; public ModSellWarningScreen(Screen lastScreen) { super(TITLE, CONTENT, CHECK, NARRATION); @@ -75,7 +76,8 @@ public class ModSellWarningScreen extends WarningScreen { @Override protected void initButtons(int pYOffset) { - this.addRenderableWidget(this.createProceedButton(pYOffset)); + this.proceedButton = this.createProceedButton(pYOffset); + this.addRenderableWidget(this.proceedButton); this.addRenderableWidget( Button.builder(CommonComponents.GUI_BACK, button -> Minecraft.getInstance().setScreen(this.lastScreen)) @@ -84,20 +86,24 @@ public class ModSellWarningScreen extends WarningScreen { ); } - // TODO 实现按钮状态刷新 private AbstractButton createProceedButton(int pYOffset) { - boolean flag = this.stopShowing != null && this.stopShowing.selected(); var proceedButton = Button.builder(CommonComponents.GUI_PROCEED, button -> { - if (flag) { + if (this.stopShowing != null && this.stopShowing.selected()) { ModSellWarningConfig.ENVIRONMENT_CHECKSUM.set(ENVIRONMENT_CHECKSUM); ModSellWarningConfig.ENVIRONMENT_CHECKSUM.save(); } Minecraft.getInstance().setScreen(new JoinMultiplayerScreen(this.lastScreen)); }).bounds(this.width / 2 - 155, 100 + pYOffset, 150, 20).build(); - proceedButton.active = flag; + proceedButton.active = false; return proceedButton; } + @Override + public void tick() { + super.tick(); + this.proceedButton.active = this.stopShowing != null && this.stopShowing.selected(); + } + @SubscribeEvent(priority = EventPriority.HIGH) public static void onGuiOpen(ScreenEvent.Opening event) { if (!(event.getNewScreen() instanceof JoinMultiplayerScreen && !(event.getCurrentScreen() instanceof ModSellWarningScreen)))