Remember player's choice whenever to open vanilla or exosuit
This commit is contained in:
parent
fdc540483f
commit
a4a8eb57ee
@ -44,7 +44,7 @@ object ClientEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
var ignoreInventoryOpen = false
|
||||
var shouldOpenVanillaInventory = false
|
||||
|
||||
fun postScreenInit(event: ScreenEvent.Init.Post) {
|
||||
val player = minecraft.player?.matteryPlayer ?: return
|
||||
@ -55,20 +55,22 @@ object ClientEventHandler {
|
||||
event.addListener(Panel2Widget(LargeSquareButtonPanel(event.screen as InventoryScreen, null,
|
||||
x = screen.guiLeft + screen.xSize + 2f,
|
||||
y = screen.guiTop.toFloat(),
|
||||
skinElement = Widgets18.RETURN_ARROW_LEFT, onPress = {
|
||||
val mouseX = minecraft.mouseHandler.xpos()
|
||||
val mouseY = minecraft.mouseHandler.ypos()
|
||||
skinElement = Widgets18.RETURN_ARROW_LEFT,
|
||||
onPress = {
|
||||
shouldOpenVanillaInventory = false
|
||||
val mouseX = minecraft.mouseHandler.xpos()
|
||||
val mouseY = minecraft.mouseHandler.ypos()
|
||||
|
||||
event.screen.onClose()
|
||||
minecraft.setScreen(ExoSuitInventoryScreen(player.exoSuitMenu))
|
||||
event.screen.onClose()
|
||||
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") }))
|
||||
}
|
||||
}
|
||||
|
||||
fun screenOpen(event: ScreenEvent.Opening) {
|
||||
if (ignoreInventoryOpen || minecraft.player?.isCreative == true) {
|
||||
if (shouldOpenVanillaInventory || minecraft.player?.isCreative == true) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -129,20 +129,16 @@ class ExoSuitInventoryScreen(menu: ExoSuitInventoryMenu) : MatteryScreen<ExoSuit
|
||||
scrollPanel.setDockMargin(right = 3f)
|
||||
|
||||
LargeSquareButtonPanel(this, frame, x = frame.width + 2f, skinElement = Widgets18.RETURN_ARROW_LEFT, onPress = {
|
||||
try {
|
||||
ClientEventHandler.ignoreInventoryOpen = true
|
||||
val minecraft = minecraft!!
|
||||
ClientEventHandler.shouldOpenVanillaInventory = true
|
||||
val minecraft = minecraft!!
|
||||
|
||||
val mouseX = minecraft.mouseHandler.xpos()
|
||||
val mouseY = minecraft.mouseHandler.ypos()
|
||||
val mouseX = minecraft.mouseHandler.xpos()
|
||||
val mouseY = minecraft.mouseHandler.ypos()
|
||||
|
||||
onClose()
|
||||
minecraft.setScreen(InventoryScreen(minecraft.player!!))
|
||||
onClose()
|
||||
minecraft.setScreen(InventoryScreen(minecraft.player!!))
|
||||
|
||||
InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY)
|
||||
} finally {
|
||||
ClientEventHandler.ignoreInventoryOpen = false
|
||||
}
|
||||
InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY)
|
||||
}).also { it.tooltip = TranslatableComponent("otm.gui.exosuit.go_back") }
|
||||
|
||||
return frame
|
||||
|
Loading…
Reference in New Issue
Block a user