Search in sources :

Example 6 with StaticInterp

use of com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp 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, Constants.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 InterpFadeInOut(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) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) 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) 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) Constants(com.teamwizardry.wizardry.api.Constants) 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) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) Entry(java.util.Map.Entry) ResourceLocation(net.minecraft.util.ResourceLocation) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 7 with StaticInterp

use of com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp 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)

Example 8 with StaticInterp

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

the class EntityJumpPad method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (ticksExisted > 100)
        setDead();
    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, Constants.MISC.SPARKLE_BLURRED));
            glitter.setAlphaFunction(new InterpFadeInOut(0.9f, 0.9f));
            glitter.enableMotionCalculation();
            Color color1 = new Color(RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255));
            Color color2 = new Color(RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255));
            glitter.setCollision(true);
            ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 1, 1, (i, build) -> {
                if (RandUtil.nextBoolean())
                    glitter.setColor(color1);
                else
                    glitter.setColor(color2);
                double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
                double r = 1 * RandUtil.nextFloat();
                double x = r * MathHelper.cos((float) theta);
                double z = r * MathHelper.sin((float) theta);
                glitter.setPositionOffset(new Vec3d(x, 0.3, z));
                if (RandUtil.nextBoolean())
                    glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.2), 0));
            });
            if (RandUtil.nextInt(30) == 0)
                LibParticles.AIR_THROTTLE(world, getPositionVector(), new Vec3d(0, RandUtil.nextDouble(0.5), 0), color1, color2, 0.5);
        }
    });
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Entity(net.minecraft.entity.Entity) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) 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) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SharedMonsterAttributes(net.minecraft.entity.SharedMonsterAttributes) java.awt(java.awt) Vec3d(net.minecraft.util.math.Vec3d) EntityLiving(net.minecraft.entity.EntityLiving) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Side(net.minecraftforge.fml.relauncher.Side) LibParticles(com.teamwizardry.wizardry.client.fx.LibParticles) MathHelper(net.minecraft.util.math.MathHelper) ResourceLocation(net.minecraft.util.ResourceLocation) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Constants(com.teamwizardry.wizardry.api.Constants) 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) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 9 with StaticInterp

use of com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp 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, Constants.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 InterpFadeInOut(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) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) 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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Save(com.teamwizardry.librarianlib.features.saving.Save) Constants(com.teamwizardry.wizardry.api.Constants) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) 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) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

StaticInterp (com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp)9 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)9 ParticleSpawner (com.teamwizardry.librarianlib.features.particle.ParticleSpawner)9 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)9 Wizardry (com.teamwizardry.wizardry.Wizardry)9 Constants (com.teamwizardry.wizardry.api.Constants)9 RandUtil (com.teamwizardry.wizardry.api.util.RandUtil)9 ResourceLocation (net.minecraft.util.ResourceLocation)9 Vec3d (net.minecraft.util.math.Vec3d)9 Side (net.minecraftforge.fml.relauncher.Side)9 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)9 ClientRunnable (com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable)8 java.awt (java.awt)8 World (net.minecraft.world.World)8 MathHelper (net.minecraft.util.math.MathHelper)7 Entity (net.minecraft.entity.Entity)6 InterpScale (com.teamwizardry.wizardry.api.util.interp.InterpScale)5 Nonnull (javax.annotation.Nonnull)5 EntityLivingBase (net.minecraft.entity.EntityLivingBase)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5