use of hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction in project AstralSorcery by HellFirePvP.
the class TypeStarHalo method spawnHaloParticles.
@OnlyIn(Dist.CLIENT)
private void spawnHaloParticles(PlayerEntity player) {
Vector3 headPos = Vector3.atEntityCorner(player).addY(player.getEyeHeight(player.getPose()));
for (int i = 0; i < 3; i++) {
Vector3 offset = MiscUtils.getRandomCirclePosition(new Vector3(), Vector3.RotAxis.Y_AXIS, 0.3F);
float scale = 0.16F + rand.nextFloat() * 0.12F;
int age = 20 + rand.nextInt(10);
MiscUtils.applyRandomOffset(offset, rand, 0.02F);
FXFacingParticle particle = EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(headPos.clone().addY(0.4F).add(offset)).setAlphaMultiplier(0.8F).alpha(((VFXAlphaFunction<EntityVisualFX>) (fx, alphaIn, pTicks) -> {
if (shouldDoEffect(player) && Minecraft.getInstance().gameSettings.getPointOfView().func_243192_a()) {
if (player.rotationPitch < -30) {
return MathHelper.clamp(1F - (Math.abs(player.rotationPitch) - 30F) / 15F, 0, 1F) * alphaIn;
}
}
return alphaIn;
}).andThen(VFXAlphaFunction.PYRAMID)).color(VFXColorFunction.constant(ColorsAS.CONSTELLATION_TYPE_WEAK)).setScaleMultiplier(scale).setMaxAge(age);
if (rand.nextInt(3) == 0) {
particle.color(VFXColorFunction.constant(ColorsAS.CONSTELLATION_VICIO));
}
FXFacingParticle starParticle = null;
if (rand.nextInt(5) == 0) {
starParticle = EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(headPos.clone().addY(0.4F).add(offset)).setAlphaMultiplier(0.8F).color(VFXColorFunction.WHITE).alpha(((VFXAlphaFunction<EntityVisualFX>) (fx, alphaIn, pTicks) -> {
if (shouldDoEffect(player) && Minecraft.getInstance().gameSettings.getPointOfView().func_243192_a()) {
if (player.rotationPitch < -30) {
return MathHelper.clamp(1F - (Math.abs(player.rotationPitch) - 30F) / 15F, 0, 1F) * alphaIn;
}
}
return alphaIn;
}).andThen(VFXAlphaFunction.PYRAMID)).setScaleMultiplier(scale * 0.6F).setMaxAge(age);
}
if (rand.nextInt(4) != 0) {
particle.position(new VFXPositionController<EntityVisualFX>() {
@Nonnull
@Override
public Vector3 updatePosition(@Nonnull EntityVisualFX fx, @Nonnull Vector3 position, @Nonnull Vector3 motionToBeMoved) {
if (shouldDoEffect(player)) {
Vector3 diff = new Vector3(player.prevPosX - player.getPosX(), player.prevPosY - player.getPosY(), player.prevPosZ - player.getPosZ());
diff.divide(4);
return Vector3.atEntityCorner(player).add(diff).addY(player.getEyeHeight(player.getPose())).addY(0.4F).add(offset);
}
return new Vector3();
}
});
if (starParticle != null) {
starParticle.position(new VFXPositionController<EntityVisualFX>() {
@Nonnull
@Override
public Vector3 updatePosition(@Nonnull EntityVisualFX fx, @Nonnull Vector3 position, @Nonnull Vector3 motionToBeMoved) {
if (shouldDoEffect(player)) {
Vector3 diff = new Vector3(player.prevPosX - player.getPosX(), player.prevPosY - player.getPosY(), player.prevPosZ - player.getPosZ());
diff.divide(4);
return Vector3.atEntityCorner(player).add(diff).addY(player.getEyeHeight(player.getPose())).addY(0.4F).add(offset);
}
return new Vector3();
}
});
}
}
}
}
use of hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction in project AstralSorcery by HellFirePvP.
the class TypeNebulaCloud method spawnCloudParticles.
@OnlyIn(Dist.CLIENT)
private void spawnCloudParticles(PlayerEntity player) {
Vector3 playerPos = Vector3.atEntityCorner(player).addY(0.1F);
for (int i = 0; i < 3; i++) {
float oX = (rand.nextFloat() - rand.nextFloat()) * 2F;
float oZ = (rand.nextFloat() - rand.nextFloat()) * 2F;
Vector3 offset = new Vector3(oX, rand.nextFloat() * 0.1F, oZ);
EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(playerPos.clone().add(offset)).setAlphaMultiplier(0.8F).alpha(((VFXAlphaFunction<EntityVisualFX>) (fx, alphaIn, pTicks) -> {
if (shouldDoEffect(player) && Minecraft.getInstance().gameSettings.getPointOfView().func_243192_a()) {
if (player.rotationPitch > 40) {
return MathHelper.clamp(1F - (player.rotationPitch - 40F) / 20F, 0, 1F) * alphaIn;
}
}
return alphaIn;
}).andThen(VFXAlphaFunction.FADE_OUT)).color(VFXColorFunction.WHITE).setScaleMultiplier(0.2F + rand.nextFloat() * 0.3F).setMaxAge(40 + rand.nextInt(20));
}
if (rand.nextInt(16) == 0) {
Vector3 from = Vector3.random().setY(0).normalize().multiply(rand.nextFloat() * 2F).addY(rand.nextFloat() * 0.1F);
Vector3 to = Vector3.random().setY(0).normalize().multiply(rand.nextFloat() * 2F).addY(rand.nextFloat() * 0.1F);
EffectHelper.of(EffectTemplatesAS.LIGHTNING).spawn(playerPos.clone().add(from)).makeDefault(playerPos.clone().add(to)).color(VFXColorFunction.WHITE).alpha((fx, alphaIn, pTicks) -> {
if (shouldDoEffect(player) && Minecraft.getInstance().gameSettings.getPointOfView().func_243192_a()) {
if (player.rotationPitch > 40) {
return MathHelper.clamp(1F - (Math.abs(player.rotationPitch) - 40F) / 20F, 0, 1F) * alphaIn;
}
}
return alphaIn;
});
}
}
Aggregations