mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Set up a proper render layer for shields
This commit is contained in:
parent
7fb9543dbe
commit
3827deb235
3 changed files with 18 additions and 21 deletions
|
@ -11,12 +11,9 @@ 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.Trait;
|
||||
import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
|
||||
import com.minelittlepony.unicopia.particle.ParticleHandle.Attachment;
|
||||
import com.minelittlepony.unicopia.particle.LightningBoltParticleEffect;
|
||||
import com.minelittlepony.unicopia.particle.ParticleHandle;
|
||||
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||
import com.minelittlepony.unicopia.particle.SphereParticleEffect;
|
||||
import com.minelittlepony.unicopia.particle.UParticles;
|
||||
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
||||
import com.minelittlepony.unicopia.projectile.ProjectileDelegate;
|
||||
import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||
|
@ -113,16 +110,11 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
|
|||
return EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.test(entity) && getAttractiveForce(source, entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroyed(Caster<?> caster) {
|
||||
particlEffect.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateParticles(Caster<?> source) {
|
||||
super.generateParticles(source);
|
||||
|
||||
float radius = (float)getEventHorizonRadius();
|
||||
/*float radius = (float)getEventHorizonRadius();
|
||||
|
||||
particlEffect.update(getUuid(), source, spawner -> {
|
||||
spawner.addParticle(new SphereParticleEffect(UParticles.SPHERE, 0x000000, 0.99F, radius, SPHERE_OFFSET), source.getOriginVector(), Vec3d.ZERO);
|
||||
|
@ -134,7 +126,7 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
|
|||
spawner.addParticle(new SphereParticleEffect(UParticles.DISK, 0xAAAAAA, 0.4F, radius + 1, SPHERE_OFFSET), getOrigin(source), Vec3d.ZERO);
|
||||
}).ifPresent(p -> {
|
||||
p.setAttribute(Attachment.ATTR_RADIUS, radius * 0F);
|
||||
});
|
||||
});*/
|
||||
|
||||
source.spawnParticles(ParticleTypes.SMOKE, 3);
|
||||
}
|
||||
|
@ -185,7 +177,7 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
|
|||
// 2. max force (at dist 0) is taken from accumulated mass
|
||||
// 3. force reaches 0 at distance of drawDropOffRange
|
||||
|
||||
private double getEventHorizonRadius() {
|
||||
public double getEventHorizonRadius() {
|
||||
return Math.sqrt(Math.max(0.001, getMass() - 12));
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,15 @@ public final class RenderLayers extends RenderLayer {
|
|||
.target(TRANSLUCENT_TARGET)
|
||||
.build(false));
|
||||
|
||||
private static final RenderLayer MAGIC_SHIELD = of("magic_shield", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL,
|
||||
VertexFormat.DrawMode.QUADS, 256, true, true, MultiPhaseParameters.builder()
|
||||
.program(COLOR_PROGRAM)
|
||||
.transparency(TRANSLUCENT_TRANSPARENCY)
|
||||
.target(TRANSLUCENT_TARGET)
|
||||
.cull(DISABLE_CULLING)
|
||||
.writeMaskState(COLOR_MASK)
|
||||
.build(false));
|
||||
|
||||
private static final Function<Integer, RenderLayer> MAGIC_COLORIN_FUNC = Util.memoize(color -> {
|
||||
return of("magic_colored_" + color,
|
||||
VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL,
|
||||
|
@ -72,15 +81,11 @@ public final class RenderLayers extends RenderLayer {
|
|||
}
|
||||
|
||||
public static RenderLayer getMagicNoColor() {
|
||||
//return MAGIC_NO_COLOR;
|
||||
return of("magic_no_color", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL,
|
||||
VertexFormat.DrawMode.QUADS, 256, true, true, MultiPhaseParameters.builder()
|
||||
.program(COLOR_PROGRAM)
|
||||
.transparency(TRANSLUCENT_TRANSPARENCY)
|
||||
.target(TRANSLUCENT_TARGET)
|
||||
.cull(DISABLE_CULLING)
|
||||
.writeMaskState(COLOR_MASK)
|
||||
.build(false));
|
||||
return MAGIC_NO_COLOR;
|
||||
}
|
||||
|
||||
public static RenderLayer getMagicShield() {
|
||||
return MAGIC_SHIELD;
|
||||
}
|
||||
|
||||
public static RenderLayer getMagicColored() {
|
||||
|
|
|
@ -28,7 +28,7 @@ public class ShieldSpellRenderer implements SpellRenderer<ShieldSpell> {
|
|||
float[] colors = ColorHelper.changeSaturation(Color.r(color), Color.g(color), Color.b(color), 4);
|
||||
float radius = 0.35F + spell.getRadius(tickDelta) + MathHelper.sin(animationProgress / 30F) * 0.01F;
|
||||
|
||||
VertexConsumer buffer = vertices.getBuffer(RenderLayers.getMagicNoColor());
|
||||
VertexConsumer buffer = vertices.getBuffer(RenderLayers.getMagicShield());
|
||||
|
||||
float thickness = 0.02F * MathHelper.sin(animationProgress / 30F);
|
||||
float alpha = 1 - Math.abs(MathHelper.sin(animationProgress / 20F)) * 0.2F;
|
||||
|
|
Loading…
Reference in a new issue