Search in sources :

Example 61 with InterpFloatInOut

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

the class ModuleShapeZone method renderSpell.

/**
 * {@inheritDoc}
 */
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
    if (overrides.onRenderZone(world, spell, spellRing))
        return;
    Vec3d target = spell.getTarget(world);
    if (target == null)
        return;
    if (RandUtil.nextInt(10) != 0)
        return;
    double aoe = spellRing.getAttributeValue(world, AttributeRegistry.AREA, spell);
    ParticleBuilder glitter = new ParticleBuilder(10);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter.setScaleFunction(new InterpScale(1, 0));
    glitter.setCollision(true);
    ParticleSpawner.spawn(glitter, world, new InterpCircle(target, new Vec3d(0, 1, 0), (float) aoe, 1, RandUtil.nextFloat()), (int) (aoe * 25), 10, (aFloat, particleBuilder) -> {
        glitter.setAlphaFunction(new InterpFloatInOut(0.3f, 0.3f));
        glitter.setLifetime(RandUtil.nextInt(30, 50));
        glitter.setColorFunction(new InterpColorHSV(spellRing.getPrimaryColor(), spellRing.getSecondaryColor()));
        glitter.setMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.01, 0.01)));
    });
}
Also used : InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) 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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 62 with InterpFloatInOut

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

the class PacketDevilDustFizzle method handle.

@Override
public void handle(MessageContext messageContext) {
    if (messageContext.side.isServer())
        return;
    World world = LibrarianLib.PROXY.getClientPlayer().world;
    if (world == null)
        return;
    ClientRunnable.run(new ClientRunnable() {

        @Override
        @SideOnly(Side.CLIENT)
        public void runIfClient() {
            ParticleBuilder glitter = new ParticleBuilder(30);
            glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
            glitter.setMotionCalculationEnabled(true);
            glitter.setCollision(true);
            glitter.setCanBounce(true);
            ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), 15, RandUtil.nextInt(10), (i, builder) -> {
                builder.setAcceleration(new Vec3d(0, RandUtil.nextDouble(-0.05, -0.01), 0));
                builder.setColor(new Color(RandUtil.nextFloat(0.9f, 1), RandUtil.nextFloat(0, 0.25f), 0));
                builder.setAlphaFunction(new InterpFloatInOut(0.0f, RandUtil.nextFloat(1f, 0.3f)));
                builder.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.3f, 1f), RandUtil.nextFloat(0, 0.2f)));
                Vec3d offset = new Vec3d(RandUtil.nextDouble(-0.3, 0.3), RandUtil.nextDouble(-0.3, 0), RandUtil.nextDouble(-0.3, 0.3));
                builder.setPositionOffset(offset);
                builder.setLifetime(RandUtil.nextInt(20, 60));
                builder.setMotion(new Vec3d(RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(0.1, 0.5), RandUtil.nextDouble(-0.1, 0.1)));
            });
        }
    });
}
Also used : InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) 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) LibrarianLib(com.teamwizardry.librarianlib.core.LibrarianLib) PacketBase(com.teamwizardry.librarianlib.features.network.PacketBase) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) java.awt(java.awt) Vec3d(net.minecraft.util.math.Vec3d) MessageContext(net.minecraftforge.fml.common.network.simpleimpl.MessageContext) Side(net.minecraftforge.fml.relauncher.Side) 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) Save(com.teamwizardry.librarianlib.features.saving.Save) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) 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) World(net.minecraft.world.World) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 63 with InterpFloatInOut

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

the class ModuleEffectTelekinesis method renderSpell.

@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Vec3d position = spell.getTarget(world);
    if (position == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(50);
    glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
    glitter.setScale(1);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), 5, 0, (aFloat, particleBuilder) -> {
        glitter.setLifetime(RandUtil.nextInt(10, 20));
        glitter.setScale(RandUtil.nextFloat());
        glitter.setScaleFunction(new InterpScale(1, 0));
        glitter.setAlphaFunction(new InterpFloatInOut(0.3f, RandUtil.nextFloat()));
        glitter.setMotion(new Vec3d(RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.1, 0.1)));
    });
}
Also used : InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) 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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 64 with InterpFloatInOut

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

the class ModuleEffectBouncing method renderSpell.

@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity target = spell.getVictim(world);
    if (ClientTickHandler.getTicks() % 10 == 0)
        return;
    if (target instanceof EntityLivingBase && ((EntityLivingBase) target).isPotionActive(ModPotions.BOUNCING)) {
        ParticleBuilder glitter = new ParticleBuilder(30);
        glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
        glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        glitter.enableMotionCalculation();
        glitter.setCollision(true);
        ParticleSpawner.spawn(glitter, world, new StaticInterp<>(target.getPositionVector().add(RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(0, target.height / 3.0), RandUtil.nextDouble(-0.5, 0.5))), 1, 0, (aFloat, particleBuilder) -> {
            particleBuilder.setLifetime(RandUtil.nextInt(20, 25));
            particleBuilder.setScaleFunction(new InterpScale(RandUtil.nextFloat(1f, 1.5f), 0f));
            particleBuilder.setAlphaFunction(new InterpFloatInOut(0.3f, 0.3f));
            particleBuilder.setAcceleration(new Vec3d(0, RandUtil.nextDouble(-0.005, -0.01), 0));
        });
    }
}
Also used : Entity(net.minecraft.entity.Entity) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 65 with InterpFloatInOut

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

the class TileUnicornTrail method update.

@Override
public void update() {
    RandUtilSeed seed = new RandUtilSeed(getPos().toLong());
    if (System.currentTimeMillis() - savedTime >= seed.nextInt(3000, 5000)) {
        getWorld().setBlockToAir(getPos());
    } else {
        if (RandUtil.nextInt(20) == 0)
            ClientRunnable.run(new ClientRunnable() {

                @Override
                @SideOnly(Side.CLIENT)
                public void runIfClient() {
                    ParticleBuilder builder = new ParticleBuilder(50);
                    builder.setRender(new ResourceLocation(Wizardry.MODID, SPARKLE_BLURRED));
                    builder.disableMotionCalculation();
                    builder.setAlphaFunction(new InterpFloatInOut(0.3f, 0f));
                    builder.setScaleFunction(new InterpScale(0.3f, 0f));
                    ParticleSpawner.spawn(builder, world, new StaticInterp<>(new Vec3d(getPos()).add(0.5, 0.5, 0.5)), 2, 0, (aFloat, particleBuilder) -> {
                        particleBuilder.setPositionOffset(new Vec3d(RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5)));
                        particleBuilder.setMotion(new Vec3d(RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.1, 0.1)));
                    });
                }
            });
    }
}
Also used : InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) RandUtilSeed(com.teamwizardry.wizardry.api.util.RandUtilSeed) 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