mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-27 04:26:27 -04:00
Fix rotations and player positioning on the ground.
This commit is contained in:
+12
-10
@@ -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()
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user