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