Search in sources :

Example 1 with InterpLine

use of com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine in project Wizardry by TeamWizardry.

the class ModuleShapeCone method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Vec3d target = spell.getTarget();
    if (target == null)
        return;
    Vec3d origin = spell.getOriginHand();
    if (origin == null)
        return;
    ParticleBuilder lines = new ParticleBuilder(10);
    lines.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    lines.setScaleFunction(new InterpScale(0.5f, 0));
    lines.setColorFunction(new InterpColorHSV(spellRing.getPrimaryColor(), spellRing.getSecondaryColor()));
    ParticleSpawner.spawn(lines, spell.world, new InterpLine(origin, target), (int) target.distanceTo(origin) * 4, 0, (aFloat, particleBuilder) -> {
        lines.setAlphaFunction(new InterpFadeInOut(0.3f, 0.3f));
        lines.setLifetime(RandUtil.nextInt(10, 20));
    });
}
Also used : InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) 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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with InterpLine

use of com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine 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 3 with InterpLine

use of com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine 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 4 with InterpLine

use of com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine in project Wizardry by TeamWizardry.

the class ModuleEffectZoom method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Entity entity = spell.getVictim();
    if (entity == null)
        return;
    Vec3d origin = spell.getData(ORIGINAL_LOC);
    if (origin == null)
        return;
    Vec3d to = entity.getPositionVector();
    ParticleBuilder glitter = new ParticleBuilder(10);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    glitter.setAlphaFunction(new InterpFadeInOut(0.0f, 0.3f));
    glitter.enableMotionCalculation();
    glitter.disableRandom();
    glitter.setCollision(true);
    glitter.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(glitter, world, new StaticInterp<>(origin.addVector(0, entity.height / 2.0, 0)), 10, 0, (aFloat, particleBuilder) -> {
        glitter.setPositionOffset(new Vec3d(RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5)));
        ParticleSpawner.spawn(glitter, world, new InterpLine(origin.add(particleBuilder.getPositionOffset()), to.add(particleBuilder.getPositionOffset()).addVector(0, entity.height / 2.0, 0)), (int) origin.distanceTo(to) * 5, 0, (aFloat2, particleBuilder2) -> {
            glitter.setAlpha(RandUtil.nextFloat(0.5f, 0.8f));
            glitter.setScale(RandUtil.nextFloat(0.3f, 0.6f));
            glitter.setLifetime(RandUtil.nextInt(30, 50));
            glitter.setColorFunction(new InterpColorHSV(getPrimaryColor(), getSecondaryColor()));
            glitter.setAlphaFunction(new InterpFadeInOut(0f, 1f));
        });
    });
}
Also used : Entity(net.minecraft.entity.Entity) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) InterpLine(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine) ResourceLocation(net.minecraft.util.ResourceLocation) World(net.minecraft.world.World) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

InterpLine (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine)4 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)4 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 Vec3d (net.minecraft.util.math.Vec3d)4 InterpColorHSV (com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 InterpBezier3D (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D)1 InterpScale (com.teamwizardry.wizardry.api.util.interp.InterpScale)1 Entity (net.minecraft.entity.Entity)1 World (net.minecraft.world.World)1