Update client event handler
This commit is contained in:
parent
0fdc3ef97e
commit
9cc572be62
@ -17,7 +17,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue;
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability;
|
||||
import ru.dbotthepony.mc.otm.capability.drive.DrivePool;
|
||||
import ru.dbotthepony.mc.otm.client.ClientEventHandler;
|
||||
import ru.dbotthepony.mc.otm.client.ClientEventHandlerKt;
|
||||
import ru.dbotthepony.mc.otm.client.MatteryGUI;
|
||||
import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel;
|
||||
import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel;
|
||||
@ -146,9 +146,9 @@ public final class OverdriveThatMatters {
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, MatteryGUI.INSTANCE::onRenderGuiEvent);
|
||||
EVENT_BUS.addListener(EventPriority.HIGH, MatteryGUI.INSTANCE::onLayerRenderEvent);
|
||||
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandler.INSTANCE::inputEvent);
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandler.INSTANCE::screenOpen);
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandler.INSTANCE::postScreenInit);
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onMovementInputUpdate);
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onScreenOpen);
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onPostScreenInit);
|
||||
|
||||
if (ModList.get().isLoaded("mekanism")) {
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, TooltipsKt::tooltipEvent);
|
||||
|
@ -13,73 +13,71 @@ import ru.dbotthepony.mc.otm.client.screen.panels.Panel2Widget
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
|
||||
object ClientEventHandler {
|
||||
fun inputEvent(event: MovementInputUpdateEvent) {
|
||||
val ply = event.entity
|
||||
val input = event.input
|
||||
fun onMovementInputUpdate(event: MovementInputUpdateEvent) {
|
||||
val ply = event.entity
|
||||
val input = event.input
|
||||
|
||||
val cap = ply.matteryPlayer ?: return
|
||||
val cap = ply.matteryPlayer ?: return
|
||||
|
||||
if (!cap.isAndroid || cap.hasFeature(AndroidFeatures.AIR_BAGS))
|
||||
return
|
||||
if (!cap.isAndroid || cap.hasFeature(AndroidFeatures.AIR_BAGS))
|
||||
return
|
||||
|
||||
if (ply.abilities.mayfly) {
|
||||
cap.lastJumpTicks = 14
|
||||
} else {
|
||||
if (ply.isInWater) {
|
||||
if (ply.isOnGround) {
|
||||
cap.lastJumpTicks = 14
|
||||
}
|
||||
if (ply.abilities.mayfly) {
|
||||
cap.lastJumpTicks = 14
|
||||
} else {
|
||||
if (ply.isInWater) {
|
||||
if (ply.isOnGround) {
|
||||
cap.lastJumpTicks = 14
|
||||
}
|
||||
|
||||
if (ply.isSwimming) {
|
||||
ply.isSwimming = false
|
||||
}
|
||||
if (ply.isSwimming) {
|
||||
ply.isSwimming = false
|
||||
}
|
||||
|
||||
if (cap.lastJumpTicks <= 0) {
|
||||
input.jumping = false
|
||||
input.up = false
|
||||
} else {
|
||||
cap.lastJumpTicks--
|
||||
}
|
||||
if (cap.lastJumpTicks <= 0) {
|
||||
input.jumping = false
|
||||
input.up = false
|
||||
} else {
|
||||
cap.lastJumpTicks--
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var shouldOpenVanillaInventory = false
|
||||
var shouldOpenVanillaInventory = false
|
||||
|
||||
fun postScreenInit(event: ScreenEvent.Init.Post) {
|
||||
val player = minecraft.player?.matteryPlayer ?: return
|
||||
fun onPostScreenInit(event: ScreenEvent.Init.Post) {
|
||||
val player = minecraft.player?.matteryPlayer ?: return
|
||||
|
||||
val screen = event.screen as? InventoryScreen ?: return
|
||||
val screen = event.screen as? InventoryScreen ?: return
|
||||
|
||||
if (player.hasExoSuit) {
|
||||
event.addListener(Panel2Widget(LargeSquareButtonPanel(event.screen as InventoryScreen, null,
|
||||
x = screen.guiLeft + screen.xSize + 2f,
|
||||
y = screen.guiTop.toFloat(),
|
||||
skinElement = Widgets18.RETURN_ARROW_LEFT,
|
||||
skinElementWinding = UVWindingOrder.FLOP,
|
||||
onPress = {
|
||||
shouldOpenVanillaInventory = false
|
||||
val mouseX = minecraft.mouseHandler.xpos()
|
||||
val mouseY = minecraft.mouseHandler.ypos()
|
||||
if (player.hasExoSuit) {
|
||||
event.addListener(Panel2Widget(LargeSquareButtonPanel(event.screen as InventoryScreen, null,
|
||||
x = screen.guiLeft + screen.xSize + 2f,
|
||||
y = screen.guiTop.toFloat(),
|
||||
skinElement = Widgets18.RETURN_ARROW_LEFT,
|
||||
skinElementWinding = UVWindingOrder.FLOP,
|
||||
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)
|
||||
}).also { it.tooltip = TranslatableComponent("otm.gui.exosuit.go_in") }))
|
||||
}
|
||||
}
|
||||
|
||||
fun screenOpen(event: ScreenEvent.Opening) {
|
||||
if (shouldOpenVanillaInventory || minecraft.player?.isCreative == true) {
|
||||
return
|
||||
}
|
||||
|
||||
val player = minecraft.player?.matteryPlayer ?: return
|
||||
|
||||
if (player.hasExoSuit && event.newScreen is InventoryScreen) {
|
||||
event.newScreen = ExoSuitInventoryScreen(player.exoSuitMenu)
|
||||
}
|
||||
InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY)
|
||||
}).also { it.tooltip = TranslatableComponent("otm.gui.exosuit.go_in") }))
|
||||
}
|
||||
}
|
||||
|
||||
fun onScreenOpen(event: ScreenEvent.Opening) {
|
||||
if (shouldOpenVanillaInventory || minecraft.player?.isCreative == true) {
|
||||
return
|
||||
}
|
||||
|
||||
val player = minecraft.player?.matteryPlayer ?: return
|
||||
|
||||
if (player.hasExoSuit && event.newScreen is InventoryScreen) {
|
||||
event.newScreen = ExoSuitInventoryScreen(player.exoSuitMenu)
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ package ru.dbotthepony.mc.otm.client.screen
|
||||
import com.mojang.blaze3d.platform.InputConstants
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen
|
||||
import ru.dbotthepony.mc.otm.client.ClientEventHandler
|
||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.client.render.element
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.*
|
||||
import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory
|
||||
import ru.dbotthepony.mc.otm.menu.ExoSuitInventoryMenu
|
||||
import ru.dbotthepony.mc.otm.network.ExoSuitMenuOpen
|
||||
import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel
|
||||
@ -129,7 +129,7 @@ class ExoSuitInventoryScreen(menu: ExoSuitInventoryMenu) : MatteryScreen<ExoSuit
|
||||
scrollPanel.setDockMargin(right = 3f)
|
||||
|
||||
LargeSquareButtonPanel(this, frame, x = frame.width + 2f, skinElement = Widgets18.RETURN_ARROW_LEFT, onPress = {
|
||||
ClientEventHandler.shouldOpenVanillaInventory = true
|
||||
shouldOpenVanillaInventory = true
|
||||
val minecraft = minecraft!!
|
||||
|
||||
val mouseX = minecraft.mouseHandler.xpos()
|
||||
|
Loading…
Reference in New Issue
Block a user