Magic shields now use the pony's horn colour and change shape when extending

This commit is contained in:
Sollace 2024-02-07 12:54:23 +00:00
parent 36e22f1ead
commit 7b78cbc49c
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
4 changed files with 30 additions and 5 deletions

View file

@ -11,11 +11,13 @@ import com.minelittlepony.unicopia.ability.magic.spell.Situation;
import com.minelittlepony.unicopia.ability.magic.spell.Spell; import com.minelittlepony.unicopia.ability.magic.spell.Spell;
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
import com.minelittlepony.unicopia.client.minelittlepony.MineLPDelegate;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.LightningBoltParticleEffect; import com.minelittlepony.unicopia.particle.LightningBoltParticleEffect;
import com.minelittlepony.unicopia.particle.MagicParticleEffect; import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.particle.ParticleUtils; import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.projectile.ProjectileUtil; import com.minelittlepony.unicopia.projectile.ProjectileUtil;
import com.minelittlepony.unicopia.util.ColorHelper;
import com.minelittlepony.unicopia.util.Lerp; import com.minelittlepony.unicopia.util.Lerp;
import com.minelittlepony.unicopia.util.shape.Sphere; import com.minelittlepony.unicopia.util.shape.Sphere;
@ -67,13 +69,18 @@ public class ShieldSpell extends AbstractSpell {
protected void generateParticles(Caster<?> source) { protected void generateParticles(Caster<?> source) {
Vec3d origin = getOrigin(source); Vec3d origin = getOrigin(source);
source.spawnParticles(origin, new Sphere(true, radius.getValue()), (int)(radius.getValue() * 6), pos -> { source.spawnParticles(origin, new Sphere(true, radius.getValue()), (int)(radius.getValue() * 2), pos -> {
source.addParticle(new MagicParticleEffect(getType().getColor()), pos, Vec3d.ZERO); int hornColor = MineLPDelegate.getInstance().getMagicColor(source.getOriginatingCaster().asEntity());
source.addParticle(new MagicParticleEffect(ColorHelper.lerp(0.6F, getType().getColor(), hornColor)), pos, Vec3d.ZERO);
if (source.asWorld().random.nextInt(10) == 0 && source.asWorld().random.nextFloat() < source.getCorruption().getScaled(1)) { if (source.asWorld().random.nextInt(10) == 0 && source.asWorld().random.nextFloat() < source.getCorruption().getScaled(1)) {
ParticleUtils.spawnParticle(source.asWorld(), new LightningBoltParticleEffect(true, 3, 2, 0.1F, Optional.empty()), pos, Vec3d.ZERO); ParticleUtils.spawnParticle(source.asWorld(), new LightningBoltParticleEffect(true, 3, 2, 0.1F, Optional.empty()), pos, Vec3d.ZERO);
} }
}); });
if (source.asWorld().random.nextInt(20) == 0 || !rangeMultiplier.isFinished() || !radius.isFinished()) {
source.asEntity().playSound(USounds.SPELL_CAST_SUCCESS, 0.05F, 1.5F);
}
} }
@Override @Override

View file

@ -10,6 +10,7 @@ import com.minelittlepony.api.model.*;
import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback; import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback;
import com.minelittlepony.api.model.gear.IGear; import com.minelittlepony.api.model.gear.IGear;
import com.minelittlepony.api.pony.IPony; import com.minelittlepony.api.pony.IPony;
import com.minelittlepony.api.pony.IPonyData;
import com.minelittlepony.unicopia.*; import com.minelittlepony.unicopia.*;
import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation; import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation;
import com.minelittlepony.unicopia.compat.trinkets.TrinketsDelegate; import com.minelittlepony.unicopia.compat.trinkets.TrinketsDelegate;
@ -93,6 +94,11 @@ public class Main extends MineLPDelegate implements ClientModInitializer {
} }
@Override
public int getMagicColor(Entity entity) {
return IPony.getManager().getPony(entity).map(IPony::metadata).map(IPonyData::getGlowColor).orElse(0);
}
@Override @Override
public Race getPlayerPonyRace(PlayerEntity player) { public Race getPlayerPonyRace(PlayerEntity player) {
return toUnicopiaRace(IPony.getManager().getPony(player).race()); return toUnicopiaRace(IPony.getManager().getPony(player).race());

View file

@ -31,4 +31,8 @@ public class MineLPDelegate {
public Race getRace(Entity entity) { public Race getRace(Entity entity) {
return Race.HUMAN; return Race.HUMAN;
} }
public int getMagicColor(Entity entity) {
return 0;
}
} }

View file

@ -4,6 +4,7 @@ import com.minelittlepony.common.util.Color;
import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.spell.effect.ShieldSpell; import com.minelittlepony.unicopia.ability.magic.spell.effect.ShieldSpell;
import com.minelittlepony.unicopia.client.gui.DrawableUtil; import com.minelittlepony.unicopia.client.gui.DrawableUtil;
import com.minelittlepony.unicopia.client.minelittlepony.MineLPDelegate;
import com.minelittlepony.unicopia.client.render.RenderLayers; import com.minelittlepony.unicopia.client.render.RenderLayers;
import com.minelittlepony.unicopia.client.render.model.SphereModel; import com.minelittlepony.unicopia.client.render.model.SphereModel;
import com.minelittlepony.unicopia.util.ColorHelper; import com.minelittlepony.unicopia.util.ColorHelper;
@ -26,8 +27,14 @@ public class ShieldSpellRenderer extends SpellRenderer<ShieldSpell> {
double height = caster.asEntity().getEyeY() - caster.getOriginVector().y; double height = caster.asEntity().getEyeY() - caster.getOriginVector().y;
matrices.translate(0, height, 0); matrices.translate(0, height, 0);
int color = ColorHelper.lerp(caster.getCorruption().getScaled(1) * (tickDelta / (1 + caster.asWorld().random.nextFloat())), spell.getType().getColor(), 0xFF000); int typeColor = spell.getType().getColor();
float[] colors = ColorHelper.changeSaturation(Color.r(color), Color.g(color), Color.b(color), 4); int ponyColor = MineLPDelegate.getInstance().getMagicColor(caster.getOriginatingCaster().asEntity());
int color = ColorHelper.lerp(caster.getCorruption().getScaled(1) * (tickDelta / (1 + caster.asWorld().random.nextFloat())),
ponyColor == 0 ? typeColor : ColorHelper.lerp(0.6F, ponyColor, typeColor),
0xFF000
);
float[] colors = ColorHelper.changeSaturation(Color.r(color), Color.g(color), Color.b(color), 2);
float radius = 0.35F + spell.getRadius(tickDelta) + MathHelper.sin(animationProgress / 30F) * 0.01F; float radius = 0.35F + spell.getRadius(tickDelta) + MathHelper.sin(animationProgress / 30F) * 0.01F;
VertexConsumer buffer = vertices.getBuffer(RenderLayers.getMagicShield()); VertexConsumer buffer = vertices.getBuffer(RenderLayers.getMagicShield());
@ -35,7 +42,7 @@ public class ShieldSpellRenderer extends SpellRenderer<ShieldSpell> {
boolean firstPerson = caster.asEntity() == client.player && client.options.getPerspective() == Perspective.FIRST_PERSON; boolean firstPerson = caster.asEntity() == client.player && client.options.getPerspective() == Perspective.FIRST_PERSON;
float thickness = 0.02F * MathHelper.sin(animationProgress / 30F); float thickness = 0.02F * MathHelper.sin(animationProgress / 30F);
float alpha = 1 - Math.abs(MathHelper.sin(animationProgress / 20F)) * 0.2F; float alpha = 1 - Math.abs(MathHelper.sin(animationProgress / 20F)) * 0.1F;
alpha *= MathHelper.clamp(radius - 1, 0, 1); alpha *= MathHelper.clamp(radius - 1, 0, 1);
if (firstPerson) { if (firstPerson) {
@ -44,6 +51,7 @@ public class ShieldSpellRenderer extends SpellRenderer<ShieldSpell> {
model.render(matrices, buffer, light, 1, radius, colors[0], colors[1], colors[2], alpha * 0.2F); model.render(matrices, buffer, light, 1, radius, colors[0], colors[1], colors[2], alpha * 0.2F);
} else { } else {
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180)); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180));
matrices.scale(1, radius == 0 ? 1 : 2.6F / radius, 1);
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.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, 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); SphereModel.SPHERE.render(matrices, buffer, light, 1, radius + thickness * 2, colors[0], colors[1], colors[2], alpha * 0.05F);