From e44eb3f77f146b7cd231c3e062f7659d1ec6473a Mon Sep 17 00:00:00 2001 From: JPAK Date: Thu, 23 Jan 2025 13:46:30 -0600 Subject: [PATCH] Fix rotations and player positioning on the ground. --- .../client/render/pokemon/PokemonRenderer.kt | 22 ++++++++++--------- .../common/entity/pokemon/PokemonEntity.kt | 6 +++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokemon/PokemonRenderer.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokemon/PokemonRenderer.kt index 9187abc736..641f5e1324 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokemon/PokemonRenderer.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/render/pokemon/PokemonRenderer.kt @@ -167,19 +167,21 @@ class PokemonRenderer( val driver = entity.firstPassenger ?: return val rollable = driver as? Rollable ?: return - val camera = Minecraft.getInstance().gameRenderer.mainCamera - val isThirdPerson = camera.isDetached + //val camera = Minecraft.getInstance().gameRenderer.mainCamera + //val isThirdPerson = camera.isDetached - val vehicleOrigin = entity.position() - val driverOrigin = if (isThirdPerson) driver.position() else driver.eyePosition + //val vehicleOrigin = entity.position() + //val driverOrigin = if (isThirdPerson) driver.position() else driver.eyePosition - val offset = driverOrigin.subtract(vehicleOrigin) + //val offset = driverOrigin.subtract(vehicleOrigin) poseMatrix.pushPose() - val yaw = Mth.rotLerp(partialTicks, entity.yBodyRotO, entity.yBodyRot) - val matrix = poseMatrix.last().pose() - if(!DISABLE_ROLLING_DEBUG){ + if(!DISABLE_ROLLING_DEBUG && rollable.shouldRoll()){ + val yaw = Mth.rotLerp(partialTicks, entity.yBodyRotO, entity.yBodyRot) + + val matrix = poseMatrix.last().pose() + val center = Vector3f(0f, entity.bbHeight/2, 0f) val transformationMatrix = Matrix4f() @@ -191,9 +193,9 @@ class PokemonRenderer( transformationMatrix.translate(center.negate(Vector3f())) matrix.mul(transformationMatrix) - } - poseMatrix.mulPose(Axis.YP.rotationDegrees(-(180.0f - yaw))) + poseMatrix.mulPose(Axis.YP.rotationDegrees(-(180.0f - yaw))) + } super.render(entity, 0f, partialTicks, poseMatrix, buffer, packedLight) poseMatrix.popPose() diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/entity/pokemon/PokemonEntity.kt b/common/src/main/kotlin/com/cobblemon/mod/common/entity/pokemon/PokemonEntity.kt index 9e2a7f7cbf..81f27ae4f1 100755 --- a/common/src/main/kotlin/com/cobblemon/mod/common/entity/pokemon/PokemonEntity.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/entity/pokemon/PokemonEntity.kt @@ -85,6 +85,7 @@ import com.cobblemon.mod.common.pokemon.evolution.variants.ItemInteractionEvolut import com.cobblemon.mod.common.pokemon.feature.StashHandler import com.cobblemon.mod.common.pokemon.properties.UncatchableProperty import com.cobblemon.mod.common.util.* +import com.cobblemon.mod.common.util.math.geometry.toRadians import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules import com.mojang.serialization.Codec import java.util.* @@ -1674,14 +1675,15 @@ open class PokemonEntity( } override fun positionRider(passenger: Entity, positionUpdater: MoveFunction) { - if (this.hasPassenger(passenger) && passenger is Rollable) { + if (this.hasPassenger(passenger)) { val index = passengers.indexOf(passenger).takeIf { it >= 0 && it < seats.size } ?: return val seat = seats[index] val seatOffset = seat.getOffset(getCurrentPoseType()).toVector3f() val center = Vector3f(0f, this.bbHeight/2, 0f) val seatToCenter = center.sub(seatOffset, Vector3f()) - val orientation = (passengers.first() as Rollable).orientation ?: Matrix3f() + + val orientation = (passengers.first() as Rollable).orientation ?: Matrix3f().rotate(-(180f + passenger.yRot).toRadians(), Vector3f(0f, 1f, 0f)) val rotatedOffset = orientation.transform(seatToCenter, Vector3f()).add(center).sub(Vector3f(0f, passenger.bbHeight/2, 0f))