mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
fix crash in chunk border renderer, rename "mouse catch" to "cursor mode"
This commit is contained in:
parent
17ee5ad834
commit
de6e1b8ff6
@ -0,0 +1,7 @@
|
||||
package de.bixilon.minosoft.config.profile.profiles.connection
|
||||
|
||||
import de.bixilon.minosoft.modding.event.events.Event
|
||||
|
||||
class ConnectionProfileSelectEvent(
|
||||
val profile: ConnectionProfile,
|
||||
) : Event
|
@ -50,7 +50,7 @@ class RenderWindowInputHandler(
|
||||
val interactionManager = InteractionManager(renderWindow)
|
||||
|
||||
init {
|
||||
registerKeyCallback("minosoft:debug_mouse_catch".toResourceLocation(),
|
||||
registerKeyCallback("minosoft:debug_change_cursor_mode".toResourceLocation(),
|
||||
KeyBinding(
|
||||
mutableMapOf(
|
||||
KeyAction.MODIFIER to mutableSetOf(KeyCodes.KEY_F4),
|
||||
@ -64,7 +64,7 @@ class RenderWindowInputHandler(
|
||||
CursorModes.HIDDEN -> CursorModes.NORMAL
|
||||
}
|
||||
renderWindow.window.cursorMode = nextMode
|
||||
renderWindow.sendDebugMessage("Mouse catch: ${nextMode.format()}")
|
||||
renderWindow.sendDebugMessage("Cursor mode: ${nextMode.format()}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,11 +38,11 @@ class ChunkBorderRenderer(
|
||||
) : Renderer, OpaqueDrawable {
|
||||
private val profile = connection.profiles.rendering
|
||||
override val renderSystem: RenderSystem = renderWindow.renderSystem
|
||||
private var lastChunkPosition: Vec2i? = null
|
||||
private var lastMesh: LineMesh? = null
|
||||
private var chunkPosition: Vec2i? = null
|
||||
private var mesh: LineMesh? = null
|
||||
|
||||
override val skipOpaque: Boolean
|
||||
get() = !profile.chunkBorder.enabled
|
||||
get() = mesh == null || !profile.chunkBorder.enabled
|
||||
|
||||
override fun init() {
|
||||
renderWindow.inputHandler.registerKeyCallback(CHUNK_BORDER_TOGGLE_KEY_COMBINATION,
|
||||
@ -59,14 +59,15 @@ class ChunkBorderRenderer(
|
||||
|
||||
override fun prepareDraw() {
|
||||
if (!profile.chunkBorder.enabled) {
|
||||
lastMesh?.unload()
|
||||
mesh?.unload()
|
||||
this.mesh = null
|
||||
return
|
||||
}
|
||||
val chunkPosition = renderWindow.connection.player.positionInfo.chunkPosition
|
||||
if (chunkPosition == lastChunkPosition && lastMesh != null) {
|
||||
if (chunkPosition == this.chunkPosition && mesh != null) {
|
||||
return
|
||||
}
|
||||
lastMesh?.unload()
|
||||
mesh?.unload()
|
||||
val mesh = LineMesh(renderWindow)
|
||||
|
||||
val dimension = renderWindow.connection.world.dimension ?: return
|
||||
@ -133,8 +134,8 @@ class ChunkBorderRenderer(
|
||||
}
|
||||
|
||||
mesh.load()
|
||||
this.lastMesh = mesh
|
||||
this.lastChunkPosition = chunkPosition
|
||||
this.mesh = mesh
|
||||
this.chunkPosition = chunkPosition
|
||||
}
|
||||
|
||||
override fun setupOpaque() {
|
||||
@ -143,7 +144,7 @@ class ChunkBorderRenderer(
|
||||
}
|
||||
|
||||
override fun drawOpaque() {
|
||||
lastMesh?.draw()
|
||||
mesh?.draw()
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user