From c119383f2da101b254e35f4cabe4c975491d40b8 Mon Sep 17 00:00:00 2001 From: Potatoboy9999 <51728317+PotatoPresident@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:12:52 -0800 Subject: [PATCH] Fix kit selection ui --- gradle.properties | 8 ++++---- .../us/potatoboy/skywars/game/ui/KitPreviewUI.java | 12 ++++++++++++ .../us/potatoboy/skywars/game/ui/KitSelectorUI.java | 12 ++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index ffb1d05..39f0617 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.21.3 -yarn_mappings=1.21.3+build.2 +minecraft_version=1.21.4 +yarn_mappings=1.21.4+build.1 loader_version=0.16.9 # Mod Properties @@ -14,7 +14,7 @@ archives_base_name=skywars # Dependencies # check these on https://modmuss50.me/fabric.html -fabric_version=0.110.0+1.21.3 +fabric_version=0.110.5+1.21.4 # check this on https://ci.gegy.dev/job/plasmid/ -plasmid_version=0.6.1+1.21.3 \ No newline at end of file +plasmid_version=0.6.2+1.21.4 \ No newline at end of file diff --git a/src/main/java/us/potatoboy/skywars/game/ui/KitPreviewUI.java b/src/main/java/us/potatoboy/skywars/game/ui/KitPreviewUI.java index dc7ebd6..003b989 100644 --- a/src/main/java/us/potatoboy/skywars/game/ui/KitPreviewUI.java +++ b/src/main/java/us/potatoboy/skywars/game/ui/KitPreviewUI.java @@ -1,6 +1,8 @@ package us.potatoboy.skywars.game.ui; +import eu.pb4.sgui.api.GuiHelpers; import eu.pb4.sgui.api.elements.GuiElementBuilder; +import eu.pb4.sgui.api.gui.GuiInterface; import eu.pb4.sgui.api.gui.SimpleGui; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -9,14 +11,17 @@ import net.minecraft.sound.SoundEvents; import net.minecraft.text.Style; import net.minecraft.text.Text; +import org.jetbrains.annotations.Nullable; import us.potatoboy.skywars.kit.Kit; public class KitPreviewUI extends SimpleGui { private final KitSelectorUI selectorUI; private final Kit kit; + private final @Nullable GuiInterface prev; public KitPreviewUI(KitSelectorUI selectorUI, Kit kit) { super(ScreenHandlerType.GENERIC_9X3, selectorUI.getPlayer(), false); + this.prev = GuiHelpers.getCurrentGui(player); this.selectorUI = selectorUI; this.kit = kit; this.setTitle(kit.displayName()); @@ -49,4 +54,11 @@ public void onOpen() { super.onOpen(); } + + @Override + public void onClose() { + if (this.prev != null) { + this.prev.open(); + } + } } diff --git a/src/main/java/us/potatoboy/skywars/game/ui/KitSelectorUI.java b/src/main/java/us/potatoboy/skywars/game/ui/KitSelectorUI.java index 7f1e397..89aebf5 100644 --- a/src/main/java/us/potatoboy/skywars/game/ui/KitSelectorUI.java +++ b/src/main/java/us/potatoboy/skywars/game/ui/KitSelectorUI.java @@ -1,6 +1,8 @@ package us.potatoboy.skywars.game.ui; +import eu.pb4.sgui.api.GuiHelpers; import eu.pb4.sgui.api.elements.GuiElementBuilder; +import eu.pb4.sgui.api.gui.GuiInterface; import eu.pb4.sgui.api.gui.SimpleGui; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.server.network.ServerPlayerEntity; @@ -9,6 +11,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; +import org.jetbrains.annotations.Nullable; import us.potatoboy.skywars.game.SkyWarsPlayer; import us.potatoboy.skywars.game.SkyWarsWaiting; import us.potatoboy.skywars.kit.Kit; @@ -23,9 +26,11 @@ public final class KitSelectorUI extends SimpleGui { private final SkyWarsPlayer playerData; private final SkyWarsWaiting game; private final List kits; + private final @Nullable GuiInterface prev; KitSelectorUI(ServerPlayerEntity player, SkyWarsPlayer data, SkyWarsWaiting game, List kits) { super(getType(kits.size()), player, kits.size() > 53); + this.prev = GuiHelpers.getCurrentGui(player); this.playerData = data; this.game = game; this.kits = kits; @@ -104,4 +109,11 @@ public void onOpen() { public static void changeKit(SkyWarsWaiting game, ServerPlayerEntity player, SkyWarsPlayer playerData, Kit kit) { playerData.selectedKit = kit; } + + @Override + public void onClose() { + if (this.prev != null) { + this.prev.open(); + } + } }