mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Fix shields not rendering in first person and change shields to be a semi-circle (since the rest will just clip into the ground)
This commit is contained in:
parent
885bf6d1c4
commit
bbe9eb0068
3 changed files with 36 additions and 4 deletions
|
@ -49,6 +49,9 @@ public class ShieldSpell extends AbstractSpell {
|
|||
private float rangeMultiplier;
|
||||
private float targetRangeMultiplier;
|
||||
|
||||
private int prevTicksDying;
|
||||
private int ticksDying;
|
||||
|
||||
protected ShieldSpell(CustomisedSpellType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
@ -102,6 +105,14 @@ public class ShieldSpell extends AbstractSpell {
|
|||
return !isDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickDying(Caster<?> caster) {
|
||||
prevTicksDying = ticksDying;
|
||||
if (ticksDying++ > 25) {
|
||||
super.tickDying(caster);
|
||||
}
|
||||
}
|
||||
|
||||
protected void consumeManage(Caster<?> source, long costMultiplier, float knowledge) {
|
||||
double cost = 2 - source.getLevel().getScaled(2);
|
||||
|
||||
|
@ -115,7 +126,9 @@ public class ShieldSpell extends AbstractSpell {
|
|||
}
|
||||
|
||||
public float getRadius(float tickDelta) {
|
||||
return MathHelper.lerp(tickDelta, prevRadius, radius);
|
||||
float base = MathHelper.lerp(tickDelta, prevRadius, radius);
|
||||
float scale = MathHelper.clamp(MathHelper.lerp(tickDelta, prevTicksDying, ticksDying), 0, 1);
|
||||
return base * scale;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,6 +57,10 @@ public class AccessoryFeatureRenderer<
|
|||
}
|
||||
|
||||
public boolean beforeRenderArms(ArmRenderer sender, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, T entity, int light) {
|
||||
Caster<?> caster = Caster.of(entity).orElse(null);
|
||||
if (caster != null) {
|
||||
SpellEffectsRenderDispatcher.INSTANCE.render(matrices, vertexConsumers, light, caster, 0, 0, tickDelta, entity.age + tickDelta, 0, 0);
|
||||
}
|
||||
boolean cancelled = false;
|
||||
for (var feature : features) {
|
||||
cancelled |= feature.beforeRenderArms(sender, tickDelta, matrices, vertexConsumers, entity, light);
|
||||
|
|
|
@ -3,16 +3,21 @@ package com.minelittlepony.unicopia.client.render.spell;
|
|||
import com.minelittlepony.common.util.Color;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.ShieldSpell;
|
||||
import com.minelittlepony.unicopia.client.gui.DrawableUtil;
|
||||
import com.minelittlepony.unicopia.client.render.RenderLayers;
|
||||
import com.minelittlepony.unicopia.client.render.model.SphereModel;
|
||||
import com.minelittlepony.unicopia.util.ColorHelper;
|
||||
|
||||
import net.minecraft.client.option.Perspective;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
public class ShieldSpellRenderer extends SpellRenderer<ShieldSpell> {
|
||||
private final SphereModel model = new SphereModel(40, 40, DrawableUtil.PI);
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertices, ShieldSpell spell, Caster<?> caster, int light, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
|
||||
super.render(matrices, vertices, spell, caster, light, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch);
|
||||
|
@ -27,11 +32,21 @@ public class ShieldSpellRenderer extends SpellRenderer<ShieldSpell> {
|
|||
|
||||
VertexConsumer buffer = vertices.getBuffer(RenderLayers.getMagicShield());
|
||||
|
||||
boolean firstPerson = caster.asEntity() == client.player && client.options.getPerspective() == Perspective.FIRST_PERSON;
|
||||
|
||||
float thickness = 0.02F * MathHelper.sin(animationProgress / 30F);
|
||||
float alpha = 1 - Math.abs(MathHelper.sin(animationProgress / 20F)) * 0.2F;
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, radius + thickness, colors[0], colors[1], colors[2], alpha * 0.08F);
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, radius - thickness, colors[0], colors[1], colors[2], alpha * 0.05F);
|
||||
SphereModel.SPHERE.render(matrices, buffer, light, 1, radius + thickness * 2, colors[0], colors[1], colors[2], alpha * 0.05F);
|
||||
|
||||
if (firstPerson) {
|
||||
matrices.translate(0, -1.75F, 0);
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(client.cameraEntity.getPitch(tickDelta)));
|
||||
model.render(matrices, buffer, light, 1, radius, colors[0], colors[1], colors[2], alpha * 0.2F);
|
||||
} else {
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180));
|
||||
model.render(matrices, buffer, light, 1, radius + thickness, colors[0], colors[1], colors[2], alpha * 0.08F);
|
||||
model.render(matrices, buffer, light, 1, radius - thickness, colors[0], colors[1], colors[2], alpha * 0.05F);
|
||||
model.render(matrices, buffer, light, 1, radius + thickness * 2, colors[0], colors[1], colors[2], alpha * 0.05F);
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue