mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fixed rendering wackyness when the timer is displayed for timed spells
This commit is contained in:
parent
45fe1f943a
commit
6567d48ea2
1 changed files with 24 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
package com.minelittlepony.unicopia.client.render.spell;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.Spell;
|
||||
|
@ -13,6 +15,8 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EntityPose;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
|
@ -37,6 +41,8 @@ public class SpellRenderer<T extends Spell> {
|
|||
|
||||
private void renderGemstone(MatrixStack matrices, VertexConsumerProvider vertices, T spell, Caster<?> caster, int light, float tickDelta, float animationProgress) {
|
||||
matrices.push();
|
||||
float scale = 1/8F;
|
||||
matrices.scale(scale, scale, scale);
|
||||
|
||||
transformGemstone(matrices, vertices, spell, caster, animationProgress);
|
||||
matrices.push();
|
||||
|
@ -46,6 +52,22 @@ public class SpellRenderer<T extends Spell> {
|
|||
matrices.pop();
|
||||
|
||||
if (spell instanceof TimedSpell timed) {
|
||||
if (caster.asEntity() instanceof LivingEntity l && !l.isInPose(EntityPose.SLEEPING)) {
|
||||
float bodyYaw = MathHelper.lerpAngleDegrees(tickDelta, l.prevBodyYaw, l.bodyYaw);
|
||||
float headYaw = MathHelper.lerpAngleDegrees(tickDelta, l.prevHeadYaw, l.headYaw);
|
||||
float yawDifference = headYaw - bodyYaw;
|
||||
if (l.hasVehicle() && l.getVehicle() instanceof LivingEntity vehicle) {
|
||||
bodyYaw = MathHelper.lerpAngleDegrees(tickDelta, vehicle.prevBodyYaw, vehicle.bodyYaw);
|
||||
yawDifference = headYaw - bodyYaw;
|
||||
float clampedYawDifference = MathHelper.clamp(MathHelper.wrapDegrees(yawDifference), -85, 85);
|
||||
bodyYaw = headYaw - clampedYawDifference;
|
||||
if (clampedYawDifference * clampedYawDifference > 2500) {
|
||||
bodyYaw += clampedYawDifference * 0.2F;
|
||||
}
|
||||
yawDifference = headYaw - bodyYaw;
|
||||
}
|
||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180 - bodyYaw));
|
||||
}
|
||||
renderCountdown(matrices, timed, tickDelta);
|
||||
}
|
||||
|
||||
|
@ -53,7 +75,7 @@ public class SpellRenderer<T extends Spell> {
|
|||
}
|
||||
|
||||
protected void renderCountdown(MatrixStack matrices, TimedSpell spell, float tickDelta) {
|
||||
matrices.multiply(client.getEntityRenderDispatcher().getRotation().invert());
|
||||
matrices.multiply(client.getEntityRenderDispatcher().getRotation().invert(new Quaternionf()));
|
||||
float radius = 0.6F;
|
||||
float timeRemaining = spell.getTimer().getPercentTimeRemaining(tickDelta);
|
||||
|
||||
|
@ -67,6 +89,6 @@ public class SpellRenderer<T extends Spell> {
|
|||
if (caster.asEntity() instanceof CastSpellEntity) {
|
||||
y = 1F;
|
||||
}
|
||||
matrices.translate(0, y + MathHelper.sin(animationProgress / 3F) * 0.2F, 0);
|
||||
matrices.translate(0, y * 8 + MathHelper.sin(animationProgress / 3F) * 0.2F, 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue