aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/events/WorldRenderLastEvent.kt5
-rw-r--r--src/main/kotlin/keybindings/FirmamentKeyboardState.kt7
-rw-r--r--src/main/kotlin/keybindings/GenericInputButton.kt6
-rw-r--r--src/main/kotlin/util/render/RenderInWorldContext.kt9
4 files changed, 16 insertions, 11 deletions
diff --git a/src/main/kotlin/events/WorldRenderLastEvent.kt b/src/main/kotlin/events/WorldRenderLastEvent.kt
index 93d7e8c..e9d44fe 100644
--- a/src/main/kotlin/events/WorldRenderLastEvent.kt
+++ b/src/main/kotlin/events/WorldRenderLastEvent.kt
@@ -5,6 +5,7 @@ package moe.nea.firmament.events
import net.minecraft.client.render.Camera
import net.minecraft.client.render.RenderTickCounter
import net.minecraft.client.render.VertexConsumerProvider
+import net.minecraft.client.render.state.CameraRenderState
import net.minecraft.client.util.math.MatrixStack
/**
@@ -12,8 +13,8 @@ import net.minecraft.client.util.math.MatrixStack
*/
data class WorldRenderLastEvent(
val matrices: MatrixStack,
- val tickCounter: RenderTickCounter,
- val camera: Camera,
+ val tickCounter: Int,
+ val camera: CameraRenderState,
val vertexConsumers: VertexConsumerProvider.Immediate,
) : FirmamentEvent() {
companion object : FirmamentEventBus<WorldRenderLastEvent>()
diff --git a/src/main/kotlin/keybindings/FirmamentKeyboardState.kt b/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
index 65288bc..dc20630 100644
--- a/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
+++ b/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
@@ -2,6 +2,7 @@ package moe.nea.firmament.keybindings
import java.util.BitSet
import org.lwjgl.glfw.GLFW
+import net.minecraft.client.input.KeyInput
object FirmamentKeyboardState {
@@ -14,10 +15,10 @@ object FirmamentKeyboardState {
}
@Synchronized
- fun maintainState(key: Int, scancode: Int, action: Int, modifiers: Int) {
+ fun maintainState(keyInput: KeyInput, action: Int) {
when (action) {
- GLFW.GLFW_PRESS -> pressedScancodes.set(scancode)
- GLFW.GLFW_RELEASE -> pressedScancodes.clear(scancode)
+ GLFW.GLFW_PRESS -> pressedScancodes.set(keyInput.scancode)
+ GLFW.GLFW_RELEASE -> pressedScancodes.clear(keyInput.scancode)
}
}
}
diff --git a/src/main/kotlin/keybindings/GenericInputButton.kt b/src/main/kotlin/keybindings/GenericInputButton.kt
index a352ce0..3876573 100644
--- a/src/main/kotlin/keybindings/GenericInputButton.kt
+++ b/src/main/kotlin/keybindings/GenericInputButton.kt
@@ -15,7 +15,9 @@ import kotlinx.serialization.json.int
import kotlinx.serialization.json.put
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.Click
+import net.minecraft.client.input.AbstractInput
import net.minecraft.client.input.KeyInput
+import net.minecraft.client.input.MouseInput
import net.minecraft.client.util.InputUtil
import net.minecraft.client.util.MacWindowUtil
import net.minecraft.text.Text
@@ -195,6 +197,8 @@ sealed interface GenericInputAction {
fun mouse(click: Click): GenericInputAction = mouse(click.button())
@JvmStatic
+ fun of(input: net.minecraft.client.input.MouseInput): GenericInputAction = mouse(input.button)
+ @JvmStatic
fun of(input: KeyInput): GenericInputAction = key(input.keycode, input.scancode)
@JvmStatic
@@ -276,7 +280,7 @@ data class InputModifiers(
fun of(modifiers: Int) = InputModifiers(modifiers)
@JvmStatic
- fun of(input: KeyInput) = InputModifiers(input.modifiers)
+ fun of(input: AbstractInput) = InputModifiers(input.modifiers())
fun none(): InputModifiers {
return InputModifiers(0)
diff --git a/src/main/kotlin/util/render/RenderInWorldContext.kt b/src/main/kotlin/util/render/RenderInWorldContext.kt
index b1ba9d0..116ae5d 100644
--- a/src/main/kotlin/util/render/RenderInWorldContext.kt
+++ b/src/main/kotlin/util/render/RenderInWorldContext.kt
@@ -12,6 +12,7 @@ import net.minecraft.client.render.RenderTickCounter
import net.minecraft.client.render.TexturedRenderLayers
import net.minecraft.client.render.VertexConsumer
import net.minecraft.client.render.VertexConsumerProvider
+import net.minecraft.client.render.state.CameraRenderState
import net.minecraft.client.texture.Sprite
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.text.Text
@@ -26,8 +27,7 @@ import moe.nea.firmament.util.MC
@RenderContextDSL
class RenderInWorldContext private constructor(
val matrixStack: MatrixStack,
- private val camera: Camera,
- private val tickCounter: RenderTickCounter,
+ private val camera: CameraRenderState,
val vertexConsumers: VertexConsumerProvider.Immediate,
) {
fun block(blockPos: BlockPos, color: Int) {
@@ -105,7 +105,7 @@ class RenderInWorldContext private constructor(
val distanceToMoveTowardsCamera = if (actualCameraDistance < 10) 0.0 else -(actualCameraDistance - 10.0)
val vec = position.subtract(camera.pos).multiply(distanceToMoveTowardsCamera / actualCameraDistance)
matrixStack.translate(vec.x, vec.y, vec.z)
- matrixStack.multiply(camera.rotation)
+ matrixStack.multiply(camera.orientation)
matrixStack.scale(0.025F, -0.025F, 1F)
FacingThePlayerContext(this).run(block)
@@ -176,7 +176,7 @@ class RenderInWorldContext private constructor(
}
fun tracer(toWhere: Vec3d, color: Int, lineWidth: Float = 3f) {
- val cameraForward = Vector3f(0f, 0f, -1f).rotate(camera.rotation)
+ val cameraForward = Vector3f(0f, 0f, -1f).rotate(camera.orientation)
line(camera.pos.add(Vec3d(cameraForward)), toWhere, color = color, lineWidth = lineWidth)
}
@@ -301,7 +301,6 @@ class RenderInWorldContext private constructor(
val ctx = RenderInWorldContext(
event.matrices,
event.camera,
- event.tickCounter,
event.vertexConsumers
)