Search in sources :

Example 11 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut 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.SMOKE));
    glitter.setAlphaFunction(new InterpFloatInOut(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(1f, (float) RandUtil.nextDouble(4, 5)));
        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) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 12 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut 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 InterpFloatInOut(0.0f, 0.1f));
    builder.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED));
    builder.enableMotionCalculation();
    ParticleSpawner.spawn(builder, world, new InterpLine(pos, pos.add(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 InterpFloatInOut(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) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 13 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut 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 InterpFloatInOut(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 InterpFloatInOut(0, 1f));
        particleBuilder.setAlphaFunction(new InterpFloatInOut(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) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) InterpBezier3D(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 14 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut 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, NBTConstants.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 InterpFloatInOut(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, NBTConstants.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 InterpFloatInOut(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 InterpFloatInOut(0, 0.9f));
// //dust.setAlphaFunction(new InterpFloatInOut(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) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 15 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.

the class EntityBomb method onImpact.

@Override
protected void onImpact(RayTraceResult result) {
    if (getThrower() == null)
        return;
    if (result.entityHit != null && getThrower() != null && getThrower().getEntityId() == result.entityHit.getEntityId())
        return;
    int type = getDataManager().get(DATA_BOMB_TYPE);
    if (type == 0)
        PosUtils.boom(getEntityWorld(), getPositionVector(), null, 10, true);
    else
        PosUtils.boom(getEntityWorld(), getPositionVector(), null, 10, false);
    ClientRunnable.run(new ClientRunnable() {

        @SideOnly(Side.CLIENT)
        @Override
        public void runIfClient() {
            Color color, color2;
            if (type == 1) {
                color = Color.CYAN;
                color2 = Color.BLUE;
            } else {
                color = Color.RED;
                color2 = Color.ORANGE;
            }
            ParticleBuilder glitter = new ParticleBuilder(10);
            glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
            glitter.setCollision(true);
            glitter.setAcceleration(new Vec3d(0, RandUtil.nextDouble(-0.03, -0.04), 0));
            glitter.setCanBounce(true);
            glitter.enableMotionCalculation();
            ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 500, 0, (i, build) -> {
                build.setMotion(Vec3d.ZERO);
                build.setLifetime(RandUtil.nextInt(50, 100));
                build.setAlphaFunction(new InterpFloatInOut(RandUtil.nextFloat(), RandUtil.nextFloat()));
                build.setScale(RandUtil.nextFloat(0.2f, 1));
                if (type == 0) {
                    double radius = RandUtil.nextDouble(20, 40);
                    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);
                    build.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(-radius, radius), z));
                    build.addMotion(build.getPositionOffset().scale(-1.0 / RandUtil.nextDouble(10, 30)));
                } else {
                    double radius = RandUtil.nextDouble(1, 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);
                    build.addMotion(new Vec3d(x, RandUtil.nextDouble(-radius, radius), z));
                }
                if (RandUtil.nextBoolean())
                    build.setColor(color);
                else
                    build.setColor(color2);
            });
        }
    });
    setDead();
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityDataManager(net.minecraft.network.datasync.EntityDataManager) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) World(net.minecraft.world.World) Wizardry(com.teamwizardry.wizardry.Wizardry) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) DataParameter(net.minecraft.network.datasync.DataParameter) PosUtils(com.teamwizardry.wizardry.api.util.PosUtils) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) java.awt(java.awt) EntityThrowable(net.minecraft.entity.projectile.EntityThrowable) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) DataSerializers(net.minecraft.network.datasync.DataSerializers) Vec3d(net.minecraft.util.math.Vec3d) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Side(net.minecraftforge.fml.relauncher.Side) MathHelper(net.minecraft.util.math.MathHelper) ResourceLocation(net.minecraft.util.ResourceLocation) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

InterpFloatInOut (com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut)65 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)65 ResourceLocation (net.minecraft.util.ResourceLocation)65 Vec3d (net.minecraft.util.math.Vec3d)62 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)32 InterpScale (com.teamwizardry.wizardry.api.util.interp.InterpScale)30 InterpColorHSV (com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV)21 Entity (net.minecraft.entity.Entity)15 ClientRunnable (com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable)13 StaticInterp (com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp)11 ParticleSpawner (com.teamwizardry.librarianlib.features.particle.ParticleSpawner)11 Wizardry (com.teamwizardry.wizardry.Wizardry)11 NBTConstants (com.teamwizardry.wizardry.api.NBTConstants)11 RandUtil (com.teamwizardry.wizardry.api.util.RandUtil)11 Side (net.minecraftforge.fml.relauncher.Side)11 java.awt (java.awt)10 World (net.minecraft.world.World)10 MathHelper (net.minecraft.util.math.MathHelper)9 EntityLivingBase (net.minecraft.entity.EntityLivingBase)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8