Search in sources :

Example 46 with InterpFadeInOut

use of com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut in project Wizardry by TeamWizardry.

the class RenderHaloEntity method doRenderLayer.

@Override
public void doRenderLayer(@Nonnull EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    if (BaublesSupport.getItem(entitylivingbaseIn, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO).isEmpty())
        return;
    ItemStack halo = BaublesSupport.getItem(entitylivingbaseIn, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO);
    // TODO: Remove these once we have a cosmetics system
    if (halo.getItem() == ModItems.FAKE_HALO && !ConfigValues.renderCrudeHalo)
        return;
    if (halo.getItem() == ModItems.REAL_HALO && !ConfigValues.renderRealHalo)
        return;
    if (halo.getItem() == ModItems.CREATIVE_HALO && !ConfigValues.renderCreativeHalo)
        return;
    if (halo.getItem() == ModItems.FAKE_HALO) {
        GlStateManager.pushMatrix();
        if (entitylivingbaseIn.isSneaking())
            GlStateManager.translate(0.0f, 0.2f, 0.0f);
        boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombieVillager;
        if (entitylivingbaseIn.isChild() && !(entitylivingbaseIn instanceof EntityVillager)) {
            GlStateManager.translate(0.0f, 0.5f * scale, 0.0f);
            GlStateManager.scale(0.7f, 0.7f, 0.7f);
            GlStateManager.translate(0.0f, 16.0f * scale, 0.0f);
        }
        if (flag)
            GlStateManager.translate(0.0f, 0.1875f, 0.0f);
        this.modelRenderer.postRender(0.0625f);
        GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
        GlStateManager.translate(0.0f, -0.25f, 0.0f);
        GlStateManager.rotate(180.0f, 0.0f, 1.0f, 0.0f);
        GlStateManager.scale(0.625f, -0.625f, -0.625f);
        Minecraft.getMinecraft().getItemRenderer().renderItem(entitylivingbaseIn, halo, ItemCameraTransforms.TransformType.HEAD);
        GlStateManager.popMatrix();
    } else {
        ParticleBuilder glitter = new ParticleBuilder(3);
        glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
        glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f));
        glitter.disableMotionCalculation();
        glitter.disableRandom();
        ParticleSpawner.spawn(glitter, entitylivingbaseIn.world, new InterpCircle(entitylivingbaseIn.getPositionVector().addVector(0, entitylivingbaseIn.height + (entitylivingbaseIn.isSneaking() ? 0.2 : 0.4), 0), new Vec3d(0, 1, 0), 0.3f, RandUtil.nextFloat(), RandUtil.nextFloat()), 10, 0, (aFloat, particleBuilder) -> {
            if (RandUtil.nextInt(10) != 0)
                if (halo.getItem() == ModItems.CREATIVE_HALO)
                    glitter.setColor(ColorUtils.changeColorAlpha(new Color(0xd600d2), RandUtil.nextInt(60, 100)));
                else
                    glitter.setColor(ColorUtils.changeColorAlpha(Color.YELLOW, RandUtil.nextInt(60, 100)));
            else
                glitter.setColor(ColorUtils.changeColorAlpha(Color.WHITE, RandUtil.nextInt(60, 100)));
            glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f));
            glitter.setLifetime(10);
            glitter.setScaleFunction(new InterpFadeInOut(0.5f, 0.5f));
            glitter.setMotion(new Vec3d(entitylivingbaseIn.motionX / 2.0, (entitylivingbaseIn.motionY + 0.0784) / 2.0, entitylivingbaseIn.motionZ / 2.0));
        });
    }
}
Also used : EntityZombieVillager(net.minecraft.entity.monster.EntityZombieVillager) InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) EntityVillager(net.minecraft.entity.passive.EntityVillager) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 47 with InterpFadeInOut

use of com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut in project Wizardry by TeamWizardry.

the class RenderHaloPlayer method doRenderLayer.

@Override
public void doRenderLayer(@Nonnull EntityPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    if (BaublesSupport.getItem(player, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO).isEmpty())
        return;
    ItemStack halo = BaublesSupport.getItem(player, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO);
    // TODO: Remove these once we have a cosmetics system
    if (halo.getItem() == ModItems.FAKE_HALO && !ConfigValues.renderCrudeHalo)
        return;
    if (halo.getItem() == ModItems.REAL_HALO && !ConfigValues.renderRealHalo)
        return;
    if (halo.getItem() == ModItems.CREATIVE_HALO && !ConfigValues.renderCreativeHalo)
        return;
    if (halo.getItem() == ModItems.FAKE_HALO) {
        GlStateManager.pushMatrix();
        if (player.isSneaking())
            GlStateManager.translate(0.0f, 0.2f, 0.0f);
        this.modelRenderer.postRender(0.0625f);
        GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
        GlStateManager.translate(0.0f, -0.25f, 0.0f);
        GlStateManager.rotate(180.0f, 0.0f, 1.0f, 0.0f);
        GlStateManager.scale(0.625f, -0.625f, -0.625f);
        Minecraft.getMinecraft().getItemRenderer().renderItem(player, halo, ItemCameraTransforms.TransformType.HEAD);
        GlStateManager.popMatrix();
    } else {
        Vec3d playerOrigin = player.getPositionVector().addVector(0, player.height + (player.isSneaking() ? 0.2 : 0.4), 0);
        InterpCircle circle = new InterpCircle(Vec3d.ZERO, new Vec3d(0, 1, 0), 0.3f, RandUtil.nextFloat(), RandUtil.nextFloat());
        for (Vec3d origin : circle.list(10)) {
            ParticleBuilder glitter = new ParticleBuilder(3);
            glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
            glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f));
            glitter.disableMotionCalculation();
            glitter.disableRandom();
            ParticleSpawner.spawn(glitter, player.world, new StaticInterp<>(playerOrigin.add(origin)), 1, 0, (aFloat, particleBuilder) -> {
                if (RandUtil.nextInt(10) != 0)
                    if (halo.getItem() == ModItems.CREATIVE_HALO)
                        glitter.setColor(ColorUtils.changeColorAlpha(new Color(0xd600d2), RandUtil.nextInt(60, 100)));
                    else
                        glitter.setColor(ColorUtils.changeColorAlpha(Color.YELLOW, RandUtil.nextInt(60, 100)));
                else
                    glitter.setColor(ColorUtils.changeColorAlpha(Color.WHITE, RandUtil.nextInt(60, 100)));
                glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f));
                glitter.setLifetime(10);
                glitter.setScaleFunction(new InterpFadeInOut(0.5f, 0.5f));
                // glitter.setMotion(new Vec3d(player.motionX / 2.0, (player.motionY + (player.capabilities.isFlying ? 0 : 0.0784)) / 2.0, player.motionZ / 2.0));
                glitter.setTick(particle -> {
                    Vec3d newOrigin = player.getPositionVector().addVector(0, player.height + (player.isSneaking() ? 0.2 : 0.4), 0);
                    particle.setPos(newOrigin.add(origin));
                });
            });
        }
    }
}
Also used : InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 48 with InterpFadeInOut

use of com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut 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 49 with InterpFadeInOut

use of com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut 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 50 with InterpFadeInOut

use of com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut 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)

Aggregations

ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)62 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)62 ResourceLocation (net.minecraft.util.ResourceLocation)61 Vec3d (net.minecraft.util.math.Vec3d)59 InterpScale (com.teamwizardry.wizardry.api.util.interp.InterpScale)25 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)22 World (net.minecraft.world.World)15 InterpColorHSV (com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV)14 ClientRunnable (com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable)11 StaticInterp (com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp)9 ParticleSpawner (com.teamwizardry.librarianlib.features.particle.ParticleSpawner)9 Wizardry (com.teamwizardry.wizardry.Wizardry)9 Constants (com.teamwizardry.wizardry.api.Constants)9 RandUtil (com.teamwizardry.wizardry.api.util.RandUtil)9 Entity (net.minecraft.entity.Entity)9 Side (net.minecraftforge.fml.relauncher.Side)9 java.awt (java.awt)8 InterpCircle (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle)7 MathHelper (net.minecraft.util.math.MathHelper)7 InterpHelix (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpHelix)6