Search in sources :

Example 16 with ParticleBuilder

use of com.teamwizardry.librarianlib.features.particle.ParticleBuilder in project Wizardry by TeamWizardry.

the class LibParticles method SPIRIT_WIGHT_FLAME_NORMAL.

public static void SPIRIT_WIGHT_FLAME_NORMAL(World world, Vec3d pos) {
    ParticleBuilder glitter = new ParticleBuilder(30);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED));
    glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f));
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), 10, 0, (i, build) -> {
        double radius = 0.1;
        double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
        double r = radius * RandUtil.nextFloat();
        double x = r * MathHelper.cos((float) theta);
        double z = r * MathHelper.sin((float) theta);
        glitter.setLifetime(RandUtil.nextInt(10, 40));
        glitter.setColor(new Color(0x4DFFFFFF, true));
        glitter.setScaleFunction(new InterpScale(0, (float) RandUtil.nextDouble(3, 4)));
        glitter.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(0, 0.2), z));
        if (RandUtil.nextInt(15) == 0)
            glitter.addMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(0, 0.03), RandUtil.nextDouble(-0.01, 0.01)));
    });
}
Also used : InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ResourceLocation(net.minecraft.util.ResourceLocation) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 17 with ParticleBuilder

use of com.teamwizardry.librarianlib.features.particle.ParticleBuilder in project Wizardry by TeamWizardry.

the class LibParticles method SHAPE_BEAM.

public static void SHAPE_BEAM(World world, Vec3d target, Vec3d origin, Color color) {
    ParticleBuilder beam = new ParticleBuilder(10);
    beam.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED));
    beam.setAlphaFunction(new InterpFadeInOut(0.3f, 1f));
    // beam.disableRandom();
    beam.setColor(ColorUtils.shiftColorHueRandomly(color, 10));
    beam.setCollision(true);
    Vec3d look = target.subtract(origin).normalize();
    double dist = target.distanceTo(origin);
    ParticleSpawner.spawn(beam, world, new StaticInterp<>(origin), 1, 0, (aFloat1, particleBuilder1) -> {
        particleBuilder1.setPositionOffset(look.scale(RandUtil.nextDouble(0, dist)));
        particleBuilder1.setScale(RandUtil.nextFloat(0.1f, 0.5f));
        final int life = RandUtil.nextInt(50, 60);
        particleBuilder1.setLifetime(life);
        particleBuilder1.enableMotionCalculation();
        particleBuilder1.setCollision(true);
        particleBuilder1.setCanBounce(true);
        particleBuilder1.setAcceleration(new Vec3d(0, -0.03, 0));
        double radius = 2;
        double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
        double r = radius * RandUtil.nextFloat();
        double x = r * MathHelper.cos((float) theta);
        double z = r * MathHelper.sin((float) theta);
        Vec3d dest = new Vec3d(x, RandUtil.nextDouble(-1, 2), z);
        particleBuilder1.setPositionFunction(new InterpBezier3D(Vec3d.ZERO, dest, dest.scale(2), new Vec3d(dest.x, RandUtil.nextDouble(-2, 2), dest.z)));
        particleBuilder1.setTick(particle -> {
            if (particle.getAge() >= particle.getLifetime() / RandUtil.nextDouble(2, 5)) {
                if (particle.getAcceleration().y == 0)
                    particle.setAcceleration(new Vec3d(0, RandUtil.nextDouble(-0.05, -0.01), 0));
            } else if (particle.getAcceleration().x != 0 || particle.getAcceleration().y != 0 || particle.getAcceleration().z != 0) {
                particle.setAcceleration(Vec3d.ZERO);
            }
        });
    });
    ParticleSpawner.spawn(beam, world, new StaticInterp<>(origin), 10, 0, (aFloat, particleBuilder) -> {
        particleBuilder.setTick(particle -> particle.setAcceleration(Vec3d.ZERO));
        particleBuilder.setScaleFunction(new InterpFadeInOut(0, 1f));
        particleBuilder.setAlphaFunction(new InterpFadeInOut(0.3f, 0.2f));
        particleBuilder.setScale(RandUtil.nextFloat(0.5f, 1.5f));
        particleBuilder.setLifetime(RandUtil.nextInt(10, 20));
        particleBuilder.disableMotionCalculation();
        particleBuilder.setMotion(Vec3d.ZERO);
        particleBuilder.setCanBounce(false);
        particleBuilder.setPositionOffset(Vec3d.ZERO);
        particleBuilder.setPositionFunction(new InterpLine(Vec3d.ZERO, target.subtract(origin)));
    });
}
Also used : InterpLine(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine) ResourceLocation(net.minecraft.util.ResourceLocation) InterpBezier3D(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 18 with ParticleBuilder

use of com.teamwizardry.librarianlib.features.particle.ParticleBuilder in project Wizardry by TeamWizardry.

the class LibParticles method CRAFTING_ALTAR_PEARL_EXPLODE.

public static void CRAFTING_ALTAR_PEARL_EXPLODE(World world, Vec3d pos) {
    ParticleBuilder builder = new ParticleBuilder(1);
    builder.setAlphaFunction(new InterpFadeInOut(0.0f, 0.1f));
    builder.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED));
    builder.enableMotionCalculation();
    ParticleSpawner.spawn(builder, world, new InterpLine(pos, pos.addVector(0, 100, 0)), RandUtil.nextInt(400, 500), 0, (aFloat, particleBuilder) -> {
        builder.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(200, 255)));
        double radius = 1;
        double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
        double r = radius * RandUtil.nextFloat();
        double x = r * MathHelper.cos((float) theta);
        double z = r * MathHelper.sin((float) theta);
        builder.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(-0.1, 0.1), z));
        builder.setScale(RandUtil.nextFloat());
        builder.setMotion(new Vec3d(x, 0, z));
        builder.setLifetime(RandUtil.nextInt(400, 600));
    });
    ParticleBuilder shockwave = new ParticleBuilder(1);
    shockwave.setAlphaFunction(new InterpFadeInOut(0.0f, 0.1f));
    shockwave.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED));
    shockwave.setCollision(true);
    shockwave.enableMotionCalculation();
    ParticleSpawner.spawn(shockwave, world, new StaticInterp<>(pos), RandUtil.nextInt(200, 300), 0, (aFloat, particleBuilder) -> {
        shockwave.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(200, 255)));
        double radius = 2;
        double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
        double r = radius * RandUtil.nextFloat();
        double x = r * MathHelper.cos((float) theta);
        double z = r * MathHelper.sin((float) theta);
        shockwave.setScale(RandUtil.nextFloat());
        shockwave.setMotion(new Vec3d(x, RandUtil.nextDouble(0.5), z));
        shockwave.setLifetime(RandUtil.nextInt(50, 100));
    });
}
Also used : InterpLine(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine) ResourceLocation(net.minecraft.util.ResourceLocation) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 19 with ParticleBuilder

use of com.teamwizardry.librarianlib.features.particle.ParticleBuilder in project Wizardry by TeamWizardry.

the class LibParticles method EFFECT_BURN.

public static void EFFECT_BURN(World world, @Nonnull Vec3d pos, Color color) {
    ParticleBuilder glitter = new ParticleBuilder(3);
    glitter.setScale(1);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), 4, 0, (aFloat, particleBuilder) -> {
        glitter.setColor(ColorUtils.changeColorAlpha(color, RandUtil.nextInt(200, 255)));
        glitter.setLifetime(RandUtil.nextInt(10, 30));
        glitter.setScaleFunction(new InterpScale((float) RandUtil.nextDouble(3, 10), 0f));
        glitter.setAlphaFunction(new InterpFadeInOut(0.3f, RandUtil.nextFloat()));
        glitter.addMotion(new Vec3d(RandUtil.nextDouble(-0.05, 0.05), RandUtil.nextDouble(0.05), RandUtil.nextDouble(-0.05, 0.05)));
        glitter.setPositionOffset(new Vec3d(RandUtil.nextDouble(-0.3, 0.3), RandUtil.nextDouble(-0.3, 0.3), RandUtil.nextDouble(-0.3, 0.3)));
    });
    ParticleBuilder dust = new ParticleBuilder(3);
    dust.setScale(1);
    dust.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    ParticleSpawner.spawn(dust, world, new StaticInterp<>(pos), 3, 0, (aFloat, particleBuilder) -> {
        dust.setLifetime(RandUtil.nextInt(10, 30));
        dust.setScaleFunction(new InterpScale(3f, 0.5f));
        dust.setAlphaFunction(new InterpFadeInOut(1, 1));
        dust.setColor(Color.DARK_GRAY);
        dust.addMotion(new Vec3d(RandUtil.nextDouble(-0.05, 0.05), RandUtil.nextDouble(0.05), RandUtil.nextDouble(-0.05, 0.05)));
    });
// ParticleBuilder dust = new ParticleBuilder(3);
// dust.setScale(1);
// dust.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
// 
// ParticleSpawner.spawn(dust, world, new StaticInterp<>(pos), 10, 0, (aFloat, particleBuilder) -> {
// dust.setColor(Color.DARK_GRAY);
// dust.setLifetime(RandUtil.nextInt(20, 30));
// dust.setScale(1);
// dust.setScaleFunction(new InterpFadeInOut(0, 0.9f));
// //dust.setAlphaFunction(new InterpFadeInOut(0.3f, RandUtil.nextFloat()));
// double x = RandUtil.nextDouble(-4, 4),
// z = RandUtil.nextDouble(-4, 4);
// dust.setPositionFunction(new InterpBezier3D(Vec3d.ZERO,
// new Vec3d(x, RandUtil.nextDouble(4), z),
// new Vec3d(x, -5, z), new Vec3d(0, 1, 0)));
// 
// //double radius = 3;
// //double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
// //double r = radius * RandUtil.nextFloat();
// //double x = r * MathHelper.cos((float) theta);
// //double z = r * MathHelper.sin((float) theta);
// //Vec3d dest = new Vec3d(x, RandUtil.nextDouble(-1, 1), z);
// //glitter.setPositionFunction(new InterpBezier3D(Vec3d.ZERO, dest,
// //		new Vec3d(0, RandUtil.nextDouble(0, 1), 0),
// //		new Vec3d(0, RandUtil.nextDouble(-2, 0), 0)));
// });
}
Also used : InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ResourceLocation(net.minecraft.util.ResourceLocation) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 20 with ParticleBuilder

use of com.teamwizardry.librarianlib.features.particle.ParticleBuilder in project Wizardry by TeamWizardry.

the class LibParticles method FAIRY_TRAIL.

public static void FAIRY_TRAIL(World world, Vec3d pos, Color color, boolean sad, int age) {
    if (((age / 4) >= (age / 2)) || (age == 0))
        return;
    ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(age / 8, age / 4));
    glitter.setColor(color);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED));
    glitter.setAlphaFunction(new InterpFadeInOut(0.2f, 1f));
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), RandUtil.nextInt(1, 3), 0, (i, build) -> {
        glitter.setMotion(new Vec3d(RandUtil.nextDouble(-0.02, 0.02), RandUtil.nextDouble(-0.02, 0.02), RandUtil.nextDouble(-0.02, 0.02)));
        if (sad) {
            glitter.setCollision(true);
            glitter.enableMotionCalculation();
        }
    });
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)62 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)62 ResourceLocation (net.minecraft.util.ResourceLocation)61 Vec3d (net.minecraft.util.math.Vec3d)59 InterpScale (com.teamwizardry.wizardry.api.util.interp.InterpScale)25 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)22 World (net.minecraft.world.World)15 InterpColorHSV (com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV)14 ClientRunnable (com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable)11 StaticInterp (com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp)9 ParticleSpawner (com.teamwizardry.librarianlib.features.particle.ParticleSpawner)9 Wizardry (com.teamwizardry.wizardry.Wizardry)9 Constants (com.teamwizardry.wizardry.api.Constants)9 RandUtil (com.teamwizardry.wizardry.api.util.RandUtil)9 Entity (net.minecraft.entity.Entity)9 Side (net.minecraftforge.fml.relauncher.Side)9 java.awt (java.awt)8 InterpCircle (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle)7 MathHelper (net.minecraft.util.math.MathHelper)7 InterpHelix (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpHelix)6