Search in sources :

Example 46 with InterpFloatInOut

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

the class TileLightRenderer method render.

@Override
public void render(float partialTicks, int destroyStage, float alpha) {
    if (RandUtil.nextInt(4) == 0) {
        Color primaryColor;
        Color secondaryColor;
        if (te.getModule() != null) {
            primaryColor = te.getModule().getPrimaryColor();
            secondaryColor = te.getModule().getSecondaryColor();
        } else {
            // NOTE: Usually should never happen, if tile entity is initialized correctly in ModuleEffectLight.
            // Purple color.
            primaryColor = new Color(0xAA00AA);
            secondaryColor = new Color(0x000000);
        }
        ParticleBuilder glitter = new ParticleBuilder(30);
        glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        glitter.setAlphaFunction(new InterpFloatInOut(0.3f, 0.3f));
        glitter.setColorFunction(new InterpColorHSV(Color.CYAN, Color.BLUE));
        glitter.setScaleFunction(new InterpScale((float) RandUtil.nextDouble(1, 3), 0));
        ParticleSpawner.spawn(glitter, te.getWorld(), new StaticInterp<>(new Vec3d(te.getPos()).add(0.5, 0.5, 0.5)), 1, 0, (i, build) -> {
            build.setMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(0, 0.03), RandUtil.nextDouble(-0.01, 0.01)));
            if (RandUtil.nextBoolean()) {
                build.setColorFunction(new InterpColorHSV(primaryColor, secondaryColor));
            } else {
                build.setColorFunction(new InterpColorHSV(secondaryColor, primaryColor));
            }
        });
    }
}
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)

Example 47 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut 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 InterpFloatInOut(0f, 0.3f));
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.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 InterpFloatInOut(0f, 1f));
    glitter.setAlphaFunction(new InterpFloatInOut(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) 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)

Example 48 with InterpFloatInOut

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

the class ModuleEffectShatter 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.disableRandom();
    glitter.setDeceleration(new Vec3d(0.5, 0.5, 0.5));
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), 100, 0, (i, builder) -> {
        builder.setLifetime(RandUtil.nextInt(30, 60));
        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());
        builder.setAcceleration(new Vec3d(0, 0.001, 0));
        double radius = 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);
        builder.setMotion(new Vec3d(x, RandUtil.nextDouble(-radius, radius), z).normalize().scale(RandUtil.nextFloat(2)));
        builder.setTick(particle -> {
            if (particle.getAge() > 15) {
                particle.setAcceleration(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(0.01, 0.03), RandUtil.nextDouble(-0.01, 0.01)));
                particle.setJitterChance(1);
                particle.setJitterMagnitude(new Vec3d(RandUtil.nextDouble(-0.05, 0.05), 0, RandUtil.nextDouble(-0.05, 0.05)));
            }
        });
    });
}
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 49 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut 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, NBTConstants.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 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;
                        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) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Arena(com.teamwizardry.wizardry.api.arena.Arena) Vec3d(net.minecraft.util.math.Vec3d) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) 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 50 with InterpFloatInOut

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

the class ModuleEffectSonic method renderSpell.

@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity target = spell.getVictim(world);
    Vec3d look = spell.getData(SpellData.DefaultKeys.LOOK);
    if (target == null || look == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(30);
    glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.DIAMOND));
    glitter.setDeceleration(new Vec3d(0.5, 0.5, 0.5));
    glitter.setCollision(true);
    glitter.setCanBounce(true);
    glitter.setAcceleration(new Vec3d(0, RandUtil.nextDouble(-0.01, 0.01), 0));
    Vec3d entityOrigin = target.getPositionVector().add(target.width / 2.0, target.height / 2.0, target.width / 2.0);
    InterpCircle circle = new InterpCircle(Vec3d.ZERO, new Vec3d(0, 1, 0), target.width);
    double area = spellRing.getAttributeValue(world, AttributeRegistry.AREA, spell) / 2;
    for (Vec3d origin : circle.list(50)) {
        ParticleSpawner.spawn(glitter, world, new StaticInterp<>(entityOrigin.add(origin)), 5, 0, (aFloat, particleBuilder) -> {
            particleBuilder.setLifetime(RandUtil.nextInt(50, 100));
            particleBuilder.setScale(RandUtil.nextFloat(0.25f, 1));
            particleBuilder.setAlphaFunction(new InterpFloatInOut(0.1f, 0.5f));
            particleBuilder.setAcceleration(new Vec3d(0, RandUtil.nextDouble(-0.01, 0.01), 0));
            particleBuilder.setMotion(origin.normalize().scale(RandUtil.nextDouble(0, area / 2.0)));
            particleBuilder.setJitter(1, new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01)));
        });
    }
}
Also used : Entity(net.minecraft.entity.Entity) InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) 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