Search in sources :

Example 1 with EntityVisualFX

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();
    }
}
Also used : EntityDynamicFX(hellfirepvp.astralsorcery.client.effect.EntityDynamicFX) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) TextureQuery(hellfirepvp.astralsorcery.client.resource.query.TextureQuery) ObjModelRender(hellfirepvp.astralsorcery.client.render.ObjModelRender) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder) RenderingDrawUtils(hellfirepvp.astralsorcery.client.util.RenderingDrawUtils) BufferDecoratorBuilder(hellfirepvp.observerlib.client.util.BufferDecoratorBuilder) java.awt(java.awt) IDrawRenderTypeBuffer(hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer) Vector3f(net.minecraft.util.math.vector.Vector3f) AbstractRenderableTexture(hellfirepvp.astralsorcery.client.resource.AbstractRenderableTexture) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) EntityVisualFX(hellfirepvp.astralsorcery.client.effect.EntityVisualFX) RenderingVectorUtils(hellfirepvp.astralsorcery.client.util.RenderingVectorUtils) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) BatchRenderContext(hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3)

Example 2 with EntityVisualFX

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));
}
Also used : EntityType(net.minecraft.entity.EntityType) EntityDataManager(net.minecraft.network.datasync.EntityDataManager) EntityTypesAS(hellfirepvp.astralsorcery.common.lib.EntityTypesAS) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) VFXScaleFunction(hellfirepvp.astralsorcery.client.effect.function.VFXScaleFunction) Random(java.util.Random) Dist(net.minecraftforge.api.distmarker.Dist) EffectTemplatesAS(hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS) Minecraft(net.minecraft.client.Minecraft) IPacket(net.minecraft.network.IPacket) VFXRenderOffsetFunction(hellfirepvp.astralsorcery.client.effect.function.VFXRenderOffsetFunction) NetworkHooks(net.minecraftforge.fml.network.NetworkHooks) ThrowableEntity(net.minecraft.entity.projectile.ThrowableEntity) FXFacingParticle(hellfirepvp.astralsorcery.client.effect.vfx.FXFacingParticle) VFXAlphaFunction(hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction) ASDataSerializers(hellfirepvp.astralsorcery.common.util.data.ASDataSerializers) PlayerEntity(net.minecraft.entity.player.PlayerEntity) World(net.minecraft.world.World) DataParameter(net.minecraft.network.datasync.DataParameter) EffectHelper(hellfirepvp.astralsorcery.client.effect.handler.EffectHelper) java.awt(java.awt) Vector3d(net.minecraft.util.math.vector.Vector3d) VFXColorFunction(hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction) MathHelper(net.minecraft.util.math.MathHelper) EntityVisualFX(hellfirepvp.astralsorcery.client.effect.EntityVisualFX) Random(java.util.Random) FXFacingParticle(hellfirepvp.astralsorcery.client.effect.vfx.FXFacingParticle) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) EntityVisualFX(hellfirepvp.astralsorcery.client.effect.EntityVisualFX) PlayerEntity(net.minecraft.entity.player.PlayerEntity) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 3 with EntityVisualFX

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();
                    }
                });
            }
        }
    }
}
Also used : VFXAlphaFunction(hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction) Nonnull(javax.annotation.Nonnull) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) FXFacingParticle(hellfirepvp.astralsorcery.client.effect.vfx.FXFacingParticle) EntityVisualFX(hellfirepvp.astralsorcery.client.effect.EntityVisualFX) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 4 with EntityVisualFX

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);
    }
}
Also used : EntityVisualFX(hellfirepvp.astralsorcery.client.effect.EntityVisualFX) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 5 with EntityVisualFX

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);
    }
}
Also used : Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) EntityVisualFX(hellfirepvp.astralsorcery.client.effect.EntityVisualFX) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

EntityVisualFX (hellfirepvp.astralsorcery.client.effect.EntityVisualFX)10 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)9 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)7 java.awt (java.awt)3 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)2 BatchRenderContext (hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext)2 VFXAlphaFunction (hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction)2 FXFacingParticle (hellfirepvp.astralsorcery.client.effect.vfx.FXFacingParticle)2 RenderingVectorUtils (hellfirepvp.astralsorcery.client.util.RenderingVectorUtils)2 BufferDecoratorBuilder (hellfirepvp.observerlib.client.util.BufferDecoratorBuilder)2 Vector3f (net.minecraft.util.math.vector.Vector3f)2 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 EntityDynamicFX (hellfirepvp.astralsorcery.client.effect.EntityDynamicFX)1 VFXColorFunction (hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction)1 VFXRenderOffsetFunction (hellfirepvp.astralsorcery.client.effect.function.VFXRenderOffsetFunction)1 VFXScaleFunction (hellfirepvp.astralsorcery.client.effect.function.VFXScaleFunction)1 EffectHelper (hellfirepvp.astralsorcery.client.effect.handler.EffectHelper)1 EffectTemplatesAS (hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS)1 IDrawRenderTypeBuffer (hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer)1