use of hellfirepvp.astralsorcery.client.effect.function.VFXScaleFunction in project AstralSorcery by HellFirePvP.
the class EntityShootingStar method spawnEffects.
@OnlyIn(Dist.CLIENT)
private void spawnEffects() {
float maxRenderPosDist = 96F;
VFXRenderOffsetFunction<FXFacingParticle> renderFn = (fx, iPos, pTicks) -> {
PlayerEntity pl = Minecraft.getInstance().player;
if (pl == null) {
return iPos;
}
Vector3 v = fx.getPosition().clone().subtract(Vector3.atEntityCorner(pl));
if (v.length() <= maxRenderPosDist) {
return iPos;
}
return Vector3.atEntityCorner(pl).add(v.normalize().multiply(maxRenderPosDist));
};
VFXScaleFunction<EntityVisualFX> scaleFn = (fx, scaleIn, pTicks) -> {
PlayerEntity pl = Minecraft.getInstance().player;
if (pl == null) {
return scaleIn;
}
Vector3 v = fx.getPosition().clone().subtract(Vector3.atEntityCorner(pl));
float mul = v.length() <= maxRenderPosDist ? 1 : (float) (maxRenderPosDist / (v.length()));
return (scaleIn * 0.25F) + ((mul * scaleIn) - (scaleIn * 0.25F));
};
Vector3 thisPosition = Vector3.atEntityCorner(this);
for (int i = 0; i < 4; i++) {
if (rand.nextFloat() > 0.75F)
continue;
Vector3 dir = new Vector3(this.getMotion()).clone().multiply(rand.nextFloat() * -0.6F);
dir.setX(dir.getX() + rand.nextFloat() * 0.008 * (rand.nextBoolean() ? 1 : -1));
dir.setZ(dir.getZ() + rand.nextFloat() * 0.008 * (rand.nextBoolean() ? 1 : -1));
EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(thisPosition).color(VFXColorFunction.WHITE).setMotion(dir).setAlphaMultiplier(0.85F).setScaleMultiplier(1.2F + rand.nextFloat() * 0.5F).scale(VFXScaleFunction.SHRINK.andThen(scaleFn)).alpha(VFXAlphaFunction.FADE_OUT).renderOffset(renderFn).setMaxAge(90 + rand.nextInt(40));
}
float scale = 4F + rand.nextFloat() * 3F;
int age = 5 + rand.nextInt(2);
Random effectSeed = new Random(this.getEffectSeed());
EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(thisPosition).color(VFXColorFunction.constant(Color.getHSBColor(effectSeed.nextFloat() * 360F, 1F, 1F))).setScaleMultiplier(scale).scale(VFXScaleFunction.SHRINK.andThen(scaleFn)).renderOffset(renderFn).alpha(VFXAlphaFunction.FADE_OUT).setMaxAge(age);
EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(thisPosition).color(VFXColorFunction.WHITE).setScaleMultiplier(scale * 0.6F).scale(VFXScaleFunction.SHRINK.andThen(scaleFn)).renderOffset(renderFn).alpha(VFXAlphaFunction.FADE_OUT).setMaxAge(Math.round(age * 1.5F));
}
Aggregations