Search in sources :

Example 16 with InterpScale

use of com.teamwizardry.wizardry.api.util.interp.InterpScale in project Wizardry by TeamWizardry.

the class RenderBomb method doRender.

@Override
public void doRender(@Nonnull EntityBomb entity, double x, double y, double z, float entityYaw, float partialTicks) {
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
    int type = entity.getDataManager().get(DATA_BOMB_TYPE);
    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.setAlphaFunction(new InterpFadeInOut(0f, 0.3f));
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    glitter.enableMotionCalculation();
    glitter.setCollision(true);
    glitter.setCanBounce(true);
    glitter.setAcceleration(new Vec3d(0, -0.015, 0));
    ParticleSpawner.spawn(glitter, entity.world, new StaticInterp<>(entity.getPositionVector().add(new Vec3d(entity.motionX, entity.motionY, entity.motionZ))), 5, 0, (aFloat, particleBuilder) -> {
        particleBuilder.setScaleFunction(new InterpScale((float) RandUtil.nextDouble(0.3, 0.8), 0));
        particleBuilder.setLifetime(RandUtil.nextInt(40, 60));
        particleBuilder.addMotion(new Vec3d(RandUtil.nextDouble(-0.03, 0.03), RandUtil.nextDouble(-0.01, 0.05), RandUtil.nextDouble(-0.03, 0.03)));
        if (RandUtil.nextBoolean()) {
            particleBuilder.setColor(color);
        } else {
            particleBuilder.setColor(color2);
        }
    });
    glitter.disableMotionCalculation();
    glitter.setMotion(Vec3d.ZERO);
    glitter.setLifetime(20);
    glitter.setScaleFunction(new InterpFadeInOut(0f, 1f));
    glitter.setAlphaFunction(new InterpFadeInOut(0f, 1f));
    ParticleSpawner.spawn(glitter, entity.world, new StaticInterp<>(entity.getPositionVector()), 5, 0, (aFloat, particleBuilder) -> {
        particleBuilder.setScale(RandUtil.nextFloat(0.5f, 2));
        particleBuilder.setLifetime(RandUtil.nextInt(5, 10));
    // particleBuilder.addMotion()
    });
}
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 InterpScale

use of com.teamwizardry.wizardry.api.util.interp.InterpScale in project Wizardry by TeamWizardry.

the class ModuleEffectFreeze method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Vec3d position = spell.getTarget();
    if (position == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(1);
    glitter.setAlphaFunction(new InterpFadeInOut(0.0f, 0.1f));
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.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) 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)

Example 18 with InterpScale

use of com.teamwizardry.wizardry.api.util.interp.InterpScale in project Wizardry by TeamWizardry.

the class ModuleEffectGravityWell method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Vec3d position = spell.getTarget();
    if (position == null)
        return;
    if (RandUtil.nextInt(10) != 0)
        return;
    ParticleBuilder glitter = new ParticleBuilder(0);
    glitter.setColorFunction(new InterpColorHSV(getPrimaryColor(), getSecondaryColor()));
    ParticleSpawner.spawn(glitter, spell.world, new StaticInterp<>(position), 5, 0, (aFloat, particleBuilder) -> {
        glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
        glitter.setAlphaFunction(new InterpFadeInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
        glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
        glitter.setLifetime(RandUtil.nextInt(20, 40));
        glitter.setScaleFunction(new InterpScale(1, 0));
        if (RandUtil.nextBoolean())
            glitter.setPositionFunction(new InterpHelix(new Vec3d(0, 0, 0), new Vec3d(0, 2, 0), 0.5f, 0, 1, RandUtil.nextFloat()));
        else
            glitter.setPositionFunction(new InterpHelix(new Vec3d(0, 0, 0), new Vec3d(0, -2, 0), 0.5f, 0, 1, RandUtil.nextFloat()));
    });
}
Also used : InterpHelix(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpHelix) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) 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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 19 with InterpScale

use of com.teamwizardry.wizardry.api.util.interp.InterpScale in project Wizardry by TeamWizardry.

the class ModuleEffectLowGravity method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Vec3d position = spell.getTarget();
    if (position == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(1);
    glitter.setAlphaFunction(new InterpFadeInOut(0.0f, 0.1f));
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.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) 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)

Example 20 with InterpScale

use of com.teamwizardry.wizardry.api.util.interp.InterpScale in project Wizardry by TeamWizardry.

the class EntitySpiritBlight method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (world.isRemote)
        return;
    if (isAIDisabled())
        return;
    if (RandUtil.nextInt(100) == 0) {
        setShiftseed(RandUtil.nextInt(1000, 100000000));
        playSound(ModSounds.ZAP, 0.3f, RandUtil.nextFloat(1.5f, 2f));
    }
    if ((ticksExisted % RandUtil.nextInt(100, 200)) == 0)
        playSound(ModSounds.HALLOWED_SPIRIT, RandUtil.nextFloat(), RandUtil.nextFloat());
    // if (world.getTotalWorldTime() % 30 == 0) {
    // playSound(ModSounds.ELECTRIC_WHITE_NOISE, RandUtil.nextFloat(0.2f, 0.3f), RandUtil.nextFloat(0.1f, 0.3f));
    // }
    fallDistance = 0;
    EntityPlayer farPlayer = world.getNearestPlayerNotCreative(this, 300);
    setAttackTarget(farPlayer);
    if (getAttackTarget() != null) {
        noClip = true;
        Vec3d direction = getPositionVector().subtract(getAttackTarget().getPositionVector()).normalize();
        motionX = direction.x * -0.05;
        motionY = direction.y * -0.05;
        motionZ = direction.z * -0.05;
        rotationYaw = (float) (((-MathHelper.atan2(direction.x, direction.z) * 180) / Math.PI) - 180) / 2;
    } else {
        if (!collidedVertically) {
            motionY = 0;
        }
        noClip = false;
    }
    EntityPlayer player = getAttackTarget() == null ? null : world.getNearestPlayerNotCreative(this, 2);
    EntityPlayer closePlayer = getAttackTarget() == null ? null : world.getNearestPlayerNotCreative(this, 30);
    boolean angry = player != null;
    ClientRunnable.run(new ClientRunnable() {

        @Override
        @SideOnly(Side.CLIENT)
        public void runIfClient() {
            ParticleBuilder glitter = new ParticleBuilder(30);
            glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
            glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f));
            glitter.setColor(new Color(0xf404d4));
            RandUtilSeed seed = new RandUtilSeed(getDataManager().get(DATA_SHIFT_SEED));
            Matrix4 matrix4 = new Matrix4();
            matrix4.rotate(rotationYaw, new Vec3d(0, 1, 0));
            Vec3d offset = new Vec3d(seed.nextDouble(-2, 2), seed.nextDouble(-2, 2), seed.nextDouble(-2, 2));
            ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().addVector(0, getEyeHeight(), 0).add(offset)), 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.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)));
            });
        }
    });
    if (angry) {
        player.attackEntityFrom(DamageSource.MAGIC, 0.15f);
        player.hurtResistantTime = 0;
    }
}
Also used : Matrix4(com.teamwizardry.librarianlib.features.math.Matrix4) EntityDataManager(net.minecraft.network.datasync.EntityDataManager) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) RandUtilSeed(com.teamwizardry.wizardry.api.util.RandUtilSeed) ModSounds(com.teamwizardry.wizardry.init.ModSounds) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Entity(net.minecraft.entity.Entity) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) World(net.minecraft.world.World) Wizardry(com.teamwizardry.wizardry.Wizardry) DataParameter(net.minecraft.network.datasync.DataParameter) DamageSource(net.minecraft.util.DamageSource) SharedMonsterAttributes(net.minecraft.entity.SharedMonsterAttributes) java.awt(java.awt) DataSerializers(net.minecraft.network.datasync.DataSerializers) EntityMob(net.minecraft.entity.monster.EntityMob) LibParticles(com.teamwizardry.wizardry.client.fx.LibParticles) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) ResourceLocation(net.minecraft.util.ResourceLocation) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) Constants(com.teamwizardry.wizardry.api.Constants) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) RandUtilSeed(com.teamwizardry.wizardry.api.util.RandUtilSeed) Vec3d(net.minecraft.util.math.Vec3d) Matrix4(com.teamwizardry.librarianlib.features.math.Matrix4) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ResourceLocation(net.minecraft.util.ResourceLocation) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)25 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)25 InterpScale (com.teamwizardry.wizardry.api.util.interp.InterpScale)25 ResourceLocation (net.minecraft.util.ResourceLocation)25 Vec3d (net.minecraft.util.math.Vec3d)24 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)16 InterpColorHSV (com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV)10 World (net.minecraft.world.World)10 Entity (net.minecraft.entity.Entity)6 StaticInterp (com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp)5 ParticleSpawner (com.teamwizardry.librarianlib.features.particle.ParticleSpawner)5 ClientRunnable (com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable)5 Wizardry (com.teamwizardry.wizardry.Wizardry)5 Constants (com.teamwizardry.wizardry.api.Constants)5 RandUtil (com.teamwizardry.wizardry.api.util.RandUtil)5 Side (net.minecraftforge.fml.relauncher.Side)5 ModSounds (com.teamwizardry.wizardry.init.ModSounds)4 java.awt (java.awt)4 Nonnull (javax.annotation.Nonnull)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4