Remember player's choice whenever to open vanilla or exosuit

This commit is contained in:
DBotThePony 2022-09-07 17:16:44 +07:00
parent fdc540483f
commit a4a8eb57ee
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 17 additions and 19 deletions

View File

@ -44,7 +44,7 @@ object ClientEventHandler {
} }
} }
var ignoreInventoryOpen = false var shouldOpenVanillaInventory = false
fun postScreenInit(event: ScreenEvent.Init.Post) { fun postScreenInit(event: ScreenEvent.Init.Post) {
val player = minecraft.player?.matteryPlayer ?: return val player = minecraft.player?.matteryPlayer ?: return
@ -55,20 +55,22 @@ object ClientEventHandler {
event.addListener(Panel2Widget(LargeSquareButtonPanel(event.screen as InventoryScreen, null, event.addListener(Panel2Widget(LargeSquareButtonPanel(event.screen as InventoryScreen, null,
x = screen.guiLeft + screen.xSize + 2f, x = screen.guiLeft + screen.xSize + 2f,
y = screen.guiTop.toFloat(), y = screen.guiTop.toFloat(),
skinElement = Widgets18.RETURN_ARROW_LEFT, onPress = { skinElement = Widgets18.RETURN_ARROW_LEFT,
val mouseX = minecraft.mouseHandler.xpos() onPress = {
val mouseY = minecraft.mouseHandler.ypos() shouldOpenVanillaInventory = false
val mouseX = minecraft.mouseHandler.xpos()
val mouseY = minecraft.mouseHandler.ypos()
event.screen.onClose() event.screen.onClose()
minecraft.setScreen(ExoSuitInventoryScreen(player.exoSuitMenu)) minecraft.setScreen(ExoSuitInventoryScreen(player.exoSuitMenu))
InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY) InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY)
}).also { it.tooltip = TranslatableComponent("otm.gui.exosuit.go_in") })) }).also { it.tooltip = TranslatableComponent("otm.gui.exosuit.go_in") }))
} }
} }
fun screenOpen(event: ScreenEvent.Opening) { fun screenOpen(event: ScreenEvent.Opening) {
if (ignoreInventoryOpen || minecraft.player?.isCreative == true) { if (shouldOpenVanillaInventory || minecraft.player?.isCreative == true) {
return return
} }

View File

@ -129,20 +129,16 @@ class ExoSuitInventoryScreen(menu: ExoSuitInventoryMenu) : MatteryScreen<ExoSuit
scrollPanel.setDockMargin(right = 3f) scrollPanel.setDockMargin(right = 3f)
LargeSquareButtonPanel(this, frame, x = frame.width + 2f, skinElement = Widgets18.RETURN_ARROW_LEFT, onPress = { LargeSquareButtonPanel(this, frame, x = frame.width + 2f, skinElement = Widgets18.RETURN_ARROW_LEFT, onPress = {
try { ClientEventHandler.shouldOpenVanillaInventory = true
ClientEventHandler.ignoreInventoryOpen = true val minecraft = minecraft!!
val minecraft = minecraft!!
val mouseX = minecraft.mouseHandler.xpos() val mouseX = minecraft.mouseHandler.xpos()
val mouseY = minecraft.mouseHandler.ypos() val mouseY = minecraft.mouseHandler.ypos()
onClose() onClose()
minecraft.setScreen(InventoryScreen(minecraft.player!!)) minecraft.setScreen(InventoryScreen(minecraft.player!!))
InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY) InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY)
} finally {
ClientEventHandler.ignoreInventoryOpen = false
}
}).also { it.tooltip = TranslatableComponent("otm.gui.exosuit.go_back") } }).also { it.tooltip = TranslatableComponent("otm.gui.exosuit.go_back") }
return frame return frame