Search in sources :

Example 16 with ClientRunnable

use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable in project Wizardry by TeamWizardry.

the class EntityZachriel method onUpdate.

@Override
public void onUpdate() {
    this.motionY = 0;
    super.onUpdate();
    // BATTLE
    {
        if (arena == null) {
            HashSet<UUID> players = new HashSet<>();
            arena = new Arena(getEntityWorld().provider.getDimension(), getPosition(), 50, 50, getEntityId(), players);
            ArenaManager.INSTANCE.addArena(arena);
        }
        for (EntityLivingBase targeted : arena.getVictims()) nemezDrive.trackEntity(targeted);
        if (burstTimer > 0) {
            burstTimer--;
            if (burstTimer == 0)
                if (!world.isRemote)
                    for (EntityPlayer player : world.playerEntities) if (EntitySelectors.CAN_AI_TARGET.apply(player) && getDistanceSq(player) < 32 * 32) {
                        PotionEffect corruption = player.getActivePotionEffect(ModPotions.ZACH_CORRUPTION);
                        float bonusDamage = corruption == null ? 0 : burstDamage * (corruption.getAmplifier() + 1);
                        player.attackEntityFrom(DamageSource.causeMobDamage(this).setMagicDamage().setDamageBypassesArmor(), burstDamage + bonusDamage);
                    }
            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(burstTimer > 0);
                    glitter.setCanBounce(burstTimer > 0);
                    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;
                        if (burstTimer > 0)
                            r = (getEntityBoundingBox().maxX - getEntityBoundingBox().minX) / 2 * RandUtil.nextFloat(0.01F, 1);
                        else
                            r = 32 * RandUtil.nextFloat();
                        double x = r * MathHelper.cos((float) theta);
                        double y = (getEntityBoundingBox().maxY - getEntityBoundingBox().minY) * RandUtil.nextFloat();
                        double z = r * MathHelper.sin((float) theta);
                        build.setPositionOffset(new Vec3d(x, y, z));
                        build.addMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.15), 0));
                    });
                }
            });
        }
        if (!world.isRemote) {
            List<EntityCorruptionArea> corruptionList = world.getEntitiesWithinAABB(EntityCorruptionArea.class, new AxisAlignedBB(getPosition()).grow(2));
            if (corruptionList.isEmpty()) {
                EntityCorruptionArea corruption = new EntityCorruptionArea(world, posX, posY, posZ);
                world.spawnEntity(corruption);
            }
        }
    }
    nemezDrive.endUpdate();
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PotionEffect(net.minecraft.potion.PotionEffect) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Arena(com.teamwizardry.wizardry.api.arena.Arena) Vec3d(net.minecraft.util.math.Vec3d) ResourceLocation(net.minecraft.util.ResourceLocation) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List) HashSet(java.util.HashSet)

Example 17 with ClientRunnable

use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable 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 18 with ClientRunnable

use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable 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 19 with ClientRunnable

use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable 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 InterpFadeInOut(0.3f, 0f));
                    builder.setScaleFunction(new InterpScale(0.3f, 0f));
                    ParticleSpawner.spawn(builder, world, new StaticInterp<>(new Vec3d(getPos()).addVector(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) ResourceLocation(net.minecraft.util.ResourceLocation) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) RandUtilSeed(com.teamwizardry.wizardry.api.util.RandUtilSeed) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 20 with ClientRunnable

use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable 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

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