diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt index 3ed27faeb..01ca2c77e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client import net.neoforged.neoforge.client.event.ClientPlayerNetworkEvent import net.neoforged.neoforge.client.event.ClientTickEvent import net.neoforged.neoforge.client.event.RenderFrameEvent +import org.apache.logging.log4j.LogManager import org.lwjgl.glfw.GLFW import ru.dbotthepony.mc.otm.core.util.IConditionalTickable import ru.dbotthepony.mc.otm.core.util.ITickable @@ -11,6 +12,7 @@ import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.isClient import java.util.function.LongSupplier +private val LOGGER = LogManager.getLogger() private val preTickList = TickList() private val postTickList = TickList() @@ -25,6 +27,12 @@ private var HAND_CURSOR by WriteOnce() private var NOT_ALLOWED_CURSOR by WriteOnce() private var CROSSHAIR_CURSOR by WriteOnce() +private inline fun check(cond: Boolean, error: () -> String) { + if (!cond) { + LOGGER.error(error.invoke(), RuntimeException(error.invoke())) + } +} + fun createCursors() { ARROW_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR) BEAM_CURSOR = GLFW.glfwCreateStandardCursor(GLFW.GLFW_IBEAM_CURSOR) @@ -43,6 +51,9 @@ enum class CursorType(val pointer: LongSupplier) { ARROW(::ARROW_CURSOR), BEAM(::BEAM_CURSOR), HAND(::HAND_CURSOR), NOT_ALLOWED(::NOT_ALLOWED_CURSOR), CROSSHAIR(::CROSSHAIR_CURSOR); fun setTo() { + if (pointer.asLong == 0L) + return + GLFW.glfwSetCursor(minecraft.window.window, pointer.asLong) MODIFIED_CURSOR = true MODIFIED_CURSOR_FRAMES = 2