mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 02:15:34 -04:00
fix flip easter egg
This commit is contained in:
parent
f255d5278d
commit
d4361e20b8
@ -21,9 +21,11 @@ import de.bixilon.minosoft.data.entities.entities.player.SkinParts
|
||||
|
||||
object EntityEasterEggs {
|
||||
private val FLIPPED = setOf("Dinnerbone", "Grumm")
|
||||
val FLIP_ROTATION = Vec3(0.0f, 0.0f, 180.0f.rad)
|
||||
val FLIP_ROTATION = Vec3(0, 0.0f, 180.0f.rad)
|
||||
const val FLIP_ENABLED = true
|
||||
|
||||
fun Entity.isFlipped(): Boolean {
|
||||
if (!FLIP_ENABLED) return false
|
||||
var name = this.customName?.message
|
||||
if (name == null && this is PlayerEntity) {
|
||||
name = additional.name
|
||||
|
@ -17,6 +17,7 @@ import de.bixilon.kotlinglm.func.rad
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.minosoft.data.entities.EntityRotation
|
||||
import de.bixilon.minosoft.gui.rendering.entities.easteregg.EntityEasterEggs.isFlipped
|
||||
import de.bixilon.minosoft.gui.rendering.entities.renderer.EntityRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalModel
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.instance.SkeletalInstance
|
||||
@ -36,7 +37,7 @@ open class SkeletalFeature(
|
||||
|
||||
protected open fun updatePosition() {
|
||||
val renderInfo = renderer.info
|
||||
val yaw = renderInfo.rotation.yaw
|
||||
var yaw = renderInfo.rotation.yaw
|
||||
val position = renderInfo.position
|
||||
|
||||
var changes = 0
|
||||
@ -49,7 +50,9 @@ open class SkeletalFeature(
|
||||
this.yaw = yaw
|
||||
}
|
||||
if (changes == 0) return
|
||||
|
||||
if (renderer.entity.isFlipped()) {
|
||||
yaw *= -1.0f
|
||||
}
|
||||
val rotation = Vec3(0.0f, (EntityRotation.HALF_CIRCLE_DEGREE - yaw).rad, 0.0f)
|
||||
instance.update(rotation, renderer.matrix)
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.entities.model.human.animator
|
||||
|
||||
import de.bixilon.kotlinglm.func.rad
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.minosoft.gui.rendering.entities.easteregg.EntityEasterEggs.isFlipped
|
||||
import de.bixilon.minosoft.gui.rendering.entities.model.human.HumanModel
|
||||
import de.bixilon.minosoft.gui.rendering.skeletal.instance.TransformInstance
|
||||
import de.bixilon.minosoft.gui.rendering.util.mat.mat4.Mat4Util.rotateRadAssign
|
||||
@ -31,6 +32,9 @@ class HeadPosition(
|
||||
|
||||
val pitch = info.rotation.pitch
|
||||
this.rotation.x = -pitch.rad
|
||||
if (model.renderer.entity.isFlipped()) {
|
||||
this.rotation.x = -this.rotation.x // TODO: not 100% correct
|
||||
}
|
||||
transform.value
|
||||
.translateAssign(transform.pivot)
|
||||
.rotateRadAssign(this.rotation)
|
||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.gui.rendering.entities.feature.EntityRenderFeature
|
||||
import de.bixilon.minosoft.gui.rendering.entities.feature.FeatureManager
|
||||
import de.bixilon.minosoft.gui.rendering.entities.hitbox.HitboxFeature
|
||||
import de.bixilon.minosoft.gui.rendering.util.mat.mat4.Mat4Util.reset
|
||||
import de.bixilon.minosoft.gui.rendering.util.mat.mat4.Mat4Util.rotateDegreesAssign
|
||||
import de.bixilon.minosoft.gui.rendering.util.mat.mat4.Mat4Util.rotateRadAssign
|
||||
import de.bixilon.minosoft.util.interpolate.Interpolator
|
||||
|
||||
abstract class EntityRenderer<E : Entity>(
|
||||
@ -53,7 +53,9 @@ abstract class EntityRenderer<E : Entity>(
|
||||
matrix.translateAssign(position)
|
||||
|
||||
if (entity.isFlipped()) {
|
||||
matrix.rotateDegreesAssign(FLIP_ROTATION)
|
||||
matrix
|
||||
.translateAssign(Vec3(0.0f, entity.dimensions.y + 0.2f, 0.0f))
|
||||
.rotateRadAssign(FLIP_ROTATION)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,14 +60,15 @@ class SkeletalInstance(
|
||||
|
||||
fun update(position: Vec3, rotation: Vec3, pivot: Vec3 = Vec3.EMPTY_INSTANCE, matrix: Mat4? = null) {
|
||||
this.matrix.reset()
|
||||
if (matrix != null) {
|
||||
this.matrix = this.matrix * matrix
|
||||
}
|
||||
this.matrix
|
||||
.translateAssign(position)
|
||||
.translateAssign(pivot)
|
||||
.rotateRadAssign(rotation)
|
||||
.translateAssign(-pivot)
|
||||
|
||||
if (matrix != null) {
|
||||
this.matrix = matrix * this.matrix
|
||||
}
|
||||
}
|
||||
|
||||
fun update(rotation: Vec3, matrix: Mat4? = null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user