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.block.entity.blackhole.ExplosionQueue;
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability;
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability;
|
||||||
import ru.dbotthepony.mc.otm.capability.drive.DrivePool;
|
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.MatteryGUI;
|
||||||
import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel;
|
import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel;
|
||||||
import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel;
|
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.NORMAL, MatteryGUI.INSTANCE::onRenderGuiEvent);
|
||||||
EVENT_BUS.addListener(EventPriority.HIGH, MatteryGUI.INSTANCE::onLayerRenderEvent);
|
EVENT_BUS.addListener(EventPriority.HIGH, MatteryGUI.INSTANCE::onLayerRenderEvent);
|
||||||
|
|
||||||
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandler.INSTANCE::inputEvent);
|
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onMovementInputUpdate);
|
||||||
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandler.INSTANCE::screenOpen);
|
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onScreenOpen);
|
||||||
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandler.INSTANCE::postScreenInit);
|
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onPostScreenInit);
|
||||||
|
|
||||||
if (ModList.get().isLoaded("mekanism")) {
|
if (ModList.get().isLoaded("mekanism")) {
|
||||||
EVENT_BUS.addListener(EventPriority.NORMAL, TooltipsKt::tooltipEvent);
|
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.core.TranslatableComponent
|
||||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||||
|
|
||||||
object ClientEventHandler {
|
fun onMovementInputUpdate(event: MovementInputUpdateEvent) {
|
||||||
fun inputEvent(event: MovementInputUpdateEvent) {
|
val ply = event.entity
|
||||||
val ply = event.entity
|
val input = event.input
|
||||||
val input = event.input
|
|
||||||
|
|
||||||
val cap = ply.matteryPlayer ?: return
|
val cap = ply.matteryPlayer ?: return
|
||||||
|
|
||||||
if (!cap.isAndroid || cap.hasFeature(AndroidFeatures.AIR_BAGS))
|
if (!cap.isAndroid || cap.hasFeature(AndroidFeatures.AIR_BAGS))
|
||||||
return
|
return
|
||||||
|
|
||||||
if (ply.abilities.mayfly) {
|
if (ply.abilities.mayfly) {
|
||||||
cap.lastJumpTicks = 14
|
cap.lastJumpTicks = 14
|
||||||
} else {
|
} else {
|
||||||
if (ply.isInWater) {
|
if (ply.isInWater) {
|
||||||
if (ply.isOnGround) {
|
if (ply.isOnGround) {
|
||||||
cap.lastJumpTicks = 14
|
cap.lastJumpTicks = 14
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ply.isSwimming) {
|
if (ply.isSwimming) {
|
||||||
ply.isSwimming = false
|
ply.isSwimming = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cap.lastJumpTicks <= 0) {
|
if (cap.lastJumpTicks <= 0) {
|
||||||
input.jumping = false
|
input.jumping = false
|
||||||
input.up = false
|
input.up = false
|
||||||
} else {
|
} else {
|
||||||
cap.lastJumpTicks--
|
cap.lastJumpTicks--
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var shouldOpenVanillaInventory = false
|
var shouldOpenVanillaInventory = false
|
||||||
|
|
||||||
fun postScreenInit(event: ScreenEvent.Init.Post) {
|
fun onPostScreenInit(event: ScreenEvent.Init.Post) {
|
||||||
val player = minecraft.player?.matteryPlayer ?: return
|
val player = minecraft.player?.matteryPlayer ?: return
|
||||||
|
|
||||||
val screen = event.screen as? InventoryScreen ?: return
|
val screen = event.screen as? InventoryScreen ?: return
|
||||||
|
|
||||||
if (player.hasExoSuit) {
|
if (player.hasExoSuit) {
|
||||||
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,
|
skinElement = Widgets18.RETURN_ARROW_LEFT,
|
||||||
skinElementWinding = UVWindingOrder.FLOP,
|
skinElementWinding = UVWindingOrder.FLOP,
|
||||||
onPress = {
|
onPress = {
|
||||||
shouldOpenVanillaInventory = false
|
shouldOpenVanillaInventory = false
|
||||||
val mouseX = minecraft.mouseHandler.xpos()
|
val mouseX = minecraft.mouseHandler.xpos()
|
||||||
val mouseY = minecraft.mouseHandler.ypos()
|
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 onScreenOpen(event: ScreenEvent.Opening) {
|
||||||
if (shouldOpenVanillaInventory || minecraft.player?.isCreative == true) {
|
if (shouldOpenVanillaInventory || minecraft.player?.isCreative == true) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val player = minecraft.player?.matteryPlayer ?: return
|
val player = minecraft.player?.matteryPlayer ?: return
|
||||||
|
|
||||||
if (player.hasExoSuit && event.newScreen is InventoryScreen) {
|
if (player.hasExoSuit && event.newScreen is InventoryScreen) {
|
||||||
event.newScreen = ExoSuitInventoryScreen(player.exoSuitMenu)
|
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.platform.InputConstants
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen
|
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.client.render.Widgets18
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
import ru.dbotthepony.mc.otm.client.render.element
|
import ru.dbotthepony.mc.otm.client.render.element
|
||||||
import ru.dbotthepony.mc.otm.client.screen.panels.*
|
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.menu.ExoSuitInventoryMenu
|
||||||
import ru.dbotthepony.mc.otm.network.ExoSuitMenuOpen
|
import ru.dbotthepony.mc.otm.network.ExoSuitMenuOpen
|
||||||
import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel
|
import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel
|
||||||
@ -129,7 +129,7 @@ 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 = {
|
||||||
ClientEventHandler.shouldOpenVanillaInventory = true
|
shouldOpenVanillaInventory = true
|
||||||
val minecraft = minecraft!!
|
val minecraft = minecraft!!
|
||||||
|
|
||||||
val mouseX = minecraft.mouseHandler.xpos()
|
val mouseX = minecraft.mouseHandler.xpos()
|
||||||
|
Loading…
Reference in New Issue
Block a user