use of hellfirepvp.astralsorcery.client.effect.EntityVisualFX in project AstralSorcery by HellFirePvP.
the class FXCrystal method renderNow.
@Override
public <T extends EntityVisualFX & EntityDynamicFX> void renderNow(BatchRenderContext<T> ctx, MatrixStack renderStack, IDrawRenderTypeBuffer drawBuffer, float pTicks) {
if (this.alternativeTexture != null) {
this.alternativeTexture.bindTexture();
}
int alpha = this.getAlpha(pTicks);
Color c = this.getColor(pTicks);
Vector3 vec = this.getRenderPosition(pTicks).subtract(RenderingVectorUtils.getStandardTranslationRemovalVector(pTicks));
float scale = this.getScale(pTicks);
if (this.lightRayColor != null) {
long seed = 0x515F1EB654AB915EL;
renderStack.push();
renderStack.translate(vec.getX(), vec.getY(), vec.getZ());
RenderingDrawUtils.renderLightRayFan(renderStack, drawBuffer, this.lightRayColor, seed, 5, 1F, 50);
renderStack.pop();
drawBuffer.draw();
}
renderStack.push();
renderStack.translate(vec.getX(), vec.getY() - 0.05F, vec.getZ());
renderStack.scale(scale, scale, scale);
renderStack.rotate(Vector3f.XP.rotationDegrees((float) rotation.getX()));
renderStack.rotate(Vector3f.YP.rotationDegrees((float) rotation.getY()));
renderStack.rotate(Vector3f.ZP.rotationDegrees((float) rotation.getZ()));
BufferDecoratorBuilder.withColor((r, g, b, a) -> new int[] { c.getRed(), c.getGreen(), c.getBlue(), alpha }).decorate(drawBuffer.getBuffer(ctx.getRenderType()), decorated -> ObjModelRender.renderCrystal(renderStack, decorated, drawBuffer::draw));
renderStack.pop();
if (this.alternativeTexture != null) {
ctx.getSprite().bindTexture();
}
}
use of hellfirepvp.astralsorcery.client.effect.EntityVisualFX 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));
}
use of hellfirepvp.astralsorcery.client.effect.EntityVisualFX 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.EntityVisualFX in project AstralSorcery by HellFirePvP.
the class TileCelestialGateway method setupGatewaySphere.
@OnlyIn(Dist.CLIENT)
private void setupGatewaySphere() {
if (!this.hasMultiblock() || !this.doesSeeSky()) {
if (clientGatewaySphereEffect != null) {
((EntityVisualFX) clientGatewaySphereEffect).requestRemoval();
clientGatewaySphereEffect = null;
}
return;
}
Vector3 at = new Vector3(this).add(0.5, 1.7, 0.5);
double distance = Vector3.atEntityCorner(Minecraft.getInstance().player).distance(at);
if (clientGatewaySphereEffect == null) {
clientGatewaySphereEffect = EffectHelper.of(EffectTemplatesAS.COLOR_SPHERE).spawn(at).setupSphere(Vector3.RotAxis.Y_AXIS, 6).setRemoveIfInvisible(true).setAlphaFadeDistance(4).setAlphaMultiplier(1).color(VFXColorFunction.BLACK).refresh(RefreshFunction.tileExistsAnd(this, (te, fx) -> te.doesSeeSky() && te.hasMultiblock()));
} else if (((EntityVisualFX) clientGatewaySphereEffect).isRemoved() && distance < 5) {
EffectHelper.refresh(((FXColorEffectSphere) clientGatewaySphereEffect), EffectTemplatesAS.COLOR_SPHERE);
}
if (distance < 5.5) {
Minecraft.getInstance().gameSettings.setPointOfView(PointOfView.FIRST_PERSON);
}
if (distance < 2.5) {
GatewayUIRenderHandler.getInstance().getOrCreateUI(this.getWorld(), this.getPos(), at);
}
}
use of hellfirepvp.astralsorcery.client.effect.EntityVisualFX in project AstralSorcery by HellFirePvP.
the class TileSpectralRelay method playAltarParticles.
@OnlyIn(Dist.CLIENT)
private void playAltarParticles() {
Vector3 pos = new Vector3(this).add(0.5, 0.35, 0.5);
Vector3 target = new Vector3(this.altarPos).add(0.5, 0.5, 0.5);
int maxAge = 30;
maxAge *= Math.max(pos.distance(target) / 3, 1);
EntityVisualFX vfx = EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(pos).alpha(VFXAlphaFunction.proximity(target::clone, 2F).andThen(VFXAlphaFunction.FADE_OUT)).motion(VFXMotionController.target(target::clone, 0.08F)).setMotion(Vector3.random().normalize().multiply(0.1F + rand.nextFloat() * 0.05F)).setScaleMultiplier(0.15F + rand.nextFloat() * 0.05F).setMaxAge(maxAge);
if (rand.nextBoolean()) {
vfx.color(VFXColorFunction.WHITE);
}
}
Aggregations