Search in sources :

Example 51 with InterpFloatInOut

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

the class ModuleEffectFrost 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(1);
    glitter.setAlphaFunction(new InterpFloatInOut(0.0f, 0.1f));
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter.enableMotionCalculation();
    glitter.setScaleFunction(new InterpScale(1, 0));
    glitter.setAcceleration(new Vec3d(0, -0.02, 0));
    glitter.setCollision(true);
    glitter.setCanBounce(true);
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), RandUtil.nextInt(5, 15), 0, (aFloat, particleBuilder) -> {
        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);
        glitter.setScale(RandUtil.nextFloat());
        glitter.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(-2, 2), z));
        glitter.setLifetime(RandUtil.nextInt(50, 100));
        Vec3d direction = position.add(glitter.getPositionOffset()).subtract(position).normalize().scale(1 / 5);
        glitter.addMotion(direction.scale(RandUtil.nextDouble(0.5, 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) 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 52 with InterpFloatInOut

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

the class ModuleEffectLeech 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(10);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter.setCollision(true);
    glitter.setCanBounce(true);
    glitter.enableMotionCalculation();
    glitter.setAcceleration(new Vec3d(0, RandUtil.nextDouble(-0.05, -0.035), 0));
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), 80, 0, (i, builder) -> {
        builder.setLifetime(RandUtil.nextInt(30, 60));
        builder.addMotion(new Vec3d(RandUtil.nextDouble(-0.05, 0.05), RandUtil.nextDouble(0.01, 0.02), RandUtil.nextDouble(-0.05, 0.05)));
        builder.setScale((float) RandUtil.nextDouble(0.3, 0.5));
        builder.setAlphaFunction(new InterpFloatInOut(0.0f, 0.3f));
        builder.setColor(RandUtil.nextBoolean() ? spellRing.getPrimaryColor() : spellRing.getSecondaryColor());
    });
}
Also used : 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 53 with InterpFloatInOut

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

the class ModuleEffectLowGravity 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(1);
    glitter.setAlphaFunction(new InterpFloatInOut(0.0f, 0.1f));
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter.enableMotionCalculation();
    glitter.setScaleFunction(new InterpScale(1, 0));
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), RandUtil.nextInt(5, 15), 0, (aFloat, particleBuilder) -> {
        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);
        glitter.setScale(RandUtil.nextFloat());
        glitter.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(-2, 2), z));
        glitter.setLifetime(RandUtil.nextInt(30, 40));
        Vec3d direction = position.add(glitter.getPositionOffset()).subtract(position).normalize();
        glitter.setMotion(direction.scale(RandUtil.nextDouble(0.5, 1.3)));
    });
}
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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 54 with InterpFloatInOut

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

the class EntityCorruptionArea method onUpdate.

public void onUpdate() {
    super.onUpdate();
    float radius = this.getRadius();
    if (duration < 0)
        setDead();
    duration--;
    ClientRunnable.run(new ClientRunnable() {

        @Override
        @SideOnly(Side.CLIENT)
        public void runIfClient() {
            ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(30, 50));
            glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
            glitter.enableMotionCalculation();
            glitter.setCollision(true);
            glitter.setCanBounce(true);
            glitter.setAcceleration(new Vec3d(0, -0.035, 0));
            glitter.setColor(new Color(255, 0, 206));
            glitter.setAlphaFunction(new InterpFloatInOut(0.5f, 0f));
            ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 1, 1, (i, build) -> {
                double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
                double r = getRadius() * RandUtil.nextFloat();
                double x = r * MathHelper.cos((float) theta);
                double z = r * MathHelper.sin((float) theta);
                build.setPositionOffset(new Vec3d(x, 0, z));
                build.addMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.15), 0));
            });
        }
    });
    radius += radiusPerTick;
    setRadius(radius);
    Iterator<Entry<Entity, Integer>> iter = this.reapplicationDelayMap.entrySet().iterator();
    while (iter.hasNext()) {
        Entry<Entity, Integer> entry = iter.next();
        int timeLeft = entry.getValue();
        if (timeLeft > 0)
            entry.setValue(timeLeft - 1);
        else
            iter.remove();
    }
    List<EntityLivingBase> entityList = world.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox());
    for (EntityLivingBase entity : entityList) {
        if (entity instanceof EntityZachriel)
            continue;
        if (this.reapplicationDelayMap.containsKey(entity))
            continue;
        double xDiff = entity.posX - this.posX;
        double zDiff = entity.posY - this.posY;
        if (xDiff * xDiff + zDiff * zDiff <= radius * radius)
            affectEntity(entity);
    }
}
Also used : EntityDataManager(net.minecraft.network.datasync.EntityDataManager) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) HashMap(java.util.HashMap) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) PotionEffect(net.minecraft.potion.PotionEffect) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Save(com.teamwizardry.librarianlib.features.saving.Save) EnumPushReaction(net.minecraft.block.material.EnumPushReaction) Entity(net.minecraft.entity.Entity) Iterator(java.util.Iterator) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) World(net.minecraft.world.World) Wizardry(com.teamwizardry.wizardry.Wizardry) ModPotions(com.teamwizardry.wizardry.init.ModPotions) BlockPos(net.minecraft.util.math.BlockPos) DataParameter(net.minecraft.network.datasync.DataParameter) java.awt(java.awt) List(java.util.List) DataSerializers(net.minecraft.network.datasync.DataSerializers) EntityLivingBase(net.minecraft.entity.EntityLivingBase) MathHelper(net.minecraft.util.math.MathHelper) ResourceLocation(net.minecraft.util.ResourceLocation) Entry(java.util.Map.Entry) EntityMod(com.teamwizardry.librarianlib.features.base.entity.EntityMod) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) Entity(net.minecraft.entity.Entity) 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) Entry(java.util.Map.Entry) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 55 with InterpFloatInOut

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

the class ModuleEffectBackup 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(1);
    glitter.setAlphaFunction(new InterpFloatInOut(0.0f, 0.1f));
    glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
    glitter.enableMotionCalculation();
    glitter.setScaleFunction(new InterpScale(1, 0));
    glitter.setAcceleration(new Vec3d(0, -0.05, 0));
    glitter.setCollision(true);
    glitter.setCanBounce(true);
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), RandUtil.nextInt(20, 30), 0, (aFloat, particleBuilder) -> {
        if (RandUtil.nextInt(5) == 0) {
            glitter.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        } else {
            glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        }
        glitter.setScale(RandUtil.nextFloat());
        glitter.setLifetime(RandUtil.nextInt(50, 100));
        glitter.addMotion(new Vec3d(RandUtil.nextDouble(-0.05, 0.05), RandUtil.nextDouble(0.01, 0.05), RandUtil.nextDouble(-0.05, 0.05)));
    });
}
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)

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