aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/gui/entity/EntityRenderer.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-12-31 17:13:16 +0100
committerLinnea Gräf <nea@nea.moe>2024-12-31 17:13:16 +0100
commit7424fe24993c3697a51c28b4a861c9c9174d8181 (patch)
tree0dfc8d4ee6cd57024039ae7cd4c6f31247925d28 /src/main/kotlin/gui/entity/EntityRenderer.kt
parenta892a5f90b87b530331a7652dd4eb5bc07bf1c03 (diff)
downloadFirmament-7424fe24993c3697a51c28b4a861c9c9174d8181.tar.gz
Firmament-7424fe24993c3697a51c28b4a861c9c9174d8181.tar.bz2
Firmament-7424fe24993c3697a51c28b4a861c9c9174d8181.zip
fix: Entity viewer in REI
Diffstat (limited to 'src/main/kotlin/gui/entity/EntityRenderer.kt')
-rw-r--r--src/main/kotlin/gui/entity/EntityRenderer.kt27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/main/kotlin/gui/entity/EntityRenderer.kt b/src/main/kotlin/gui/entity/EntityRenderer.kt
index 9a09fc6..fd7a0c4 100644
--- a/src/main/kotlin/gui/entity/EntityRenderer.kt
+++ b/src/main/kotlin/gui/entity/EntityRenderer.kt
@@ -112,10 +112,13 @@ object EntityRenderer {
posX: Int,
posY: Int,
// TODO: Add width, height properties here
+ width: Double,
+ height: Double,
mouseX: Double,
- mouseY: Double
+ mouseY: Double,
+ entityScale: Double = (height - 10.0) / 2.0
) {
- var bottomOffset = 0.0F
+ var bottomOffset = 0.0
var currentEntity = entity
val maxSize = entity.iterate { it.firstPassenger as? LivingEntity }
.map { it.height }
@@ -126,9 +129,9 @@ object EntityRenderer {
renderContext,
posX,
posY,
- posX + 50,
- posY + 80,
- minOf(2F / maxSize, 1F) * 30,
+ (posX + width).toInt(),
+ (posY + height).toInt(),
+ minOf(2F / maxSize, 1F) * entityScale,
-bottomOffset,
mouseX,
mouseY,
@@ -147,8 +150,8 @@ object EntityRenderer {
y1: Int,
x2: Int,
y2: Int,
- size: Float,
- bottomOffset: Float,
+ size: Double,
+ bottomOffset: Double,
mouseX: Double,
mouseY: Double,
entity: LivingEntity
@@ -156,8 +159,10 @@ object EntityRenderer {
context.enableScissorWithTranslation(x1.toFloat(), y1.toFloat(), x2.toFloat(), y2.toFloat())
val centerX = (x1 + x2) / 2f
val centerY = (y1 + y2) / 2f
- val targetYaw = atan(((centerX - mouseX) / 40.0f)).toFloat()
- val targetPitch = atan(((centerY - mouseY) / 40.0f)).toFloat()
+ val hw = (x2 - x1) / 2
+ val hh = (y2 - y1) / 2
+ val targetYaw = atan(((centerX - mouseX) / hw)).toFloat()
+ val targetPitch = atan(((centerY - mouseY) / hh)).toFloat()
val rotateToFaceTheFront = Quaternionf().rotateZ(Math.PI.toFloat())
val rotateToFaceTheCamera = Quaternionf().rotateX(targetPitch * 20.0f * (Math.PI.toFloat() / 180))
rotateToFaceTheFront.mul(rotateToFaceTheCamera)
@@ -171,12 +176,12 @@ object EntityRenderer {
entity.pitch = -targetPitch * 20.0f
entity.headYaw = entity.yaw
entity.prevHeadYaw = entity.yaw
- val vector3f = Vector3f(0.0f, entity.height / 2.0f + bottomOffset, 0.0f)
+ val vector3f = Vector3f(0.0f, (entity.height / 2.0f + bottomOffset).toFloat(), 0.0f)
InventoryScreen.drawEntity(
context,
centerX,
centerY,
- size,
+ size.toFloat(),
vector3f,
rotateToFaceTheFront,
rotateToFaceTheCamera,