Search in sources :

Example 26 with InterpFloatInOut

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

the class ModuleEffectZoom method renderSpell.

@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity entity = spell.getVictim(world);
    if (entity == null)
        return;
    Vec3d origin = spell.getData(ORIGINAL_LOC);
    if (origin == null)
        return;
    Vec3d to = entity.getPositionVector();
    ParticleBuilder glitter = new ParticleBuilder(10);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter.setAlphaFunction(new InterpFloatInOut(0.0f, 0.3f));
    glitter.enableMotionCalculation();
    glitter.disableRandom();
    glitter.setCollision(true);
    glitter.setTick(particle -> {
        if (particle.getAge() >= particle.getLifetime() / RandUtil.nextDouble(2, 5)) {
            if (particle.getAcceleration().y == 0)
                particle.setAcceleration(new Vec3d(0, RandUtil.nextDouble(-0.05, -0.01), 0));
        } else if (particle.getAcceleration().x != 0 || particle.getAcceleration().y != 0 || particle.getAcceleration().z != 0) {
            particle.setAcceleration(Vec3d.ZERO);
        }
    });
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(origin.add(0, entity.height / 2.0, 0)), 10, 0, (aFloat, particleBuilder) -> {
        glitter.setPositionOffset(new Vec3d(RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5)));
        ParticleSpawner.spawn(glitter, world, new InterpLine(origin.add(particleBuilder.getPositionOffset()), to.add(particleBuilder.getPositionOffset()).add(0, entity.height / 2.0, 0)), (int) origin.distanceTo(to) * 5, 0, (aFloat2, particleBuilder2) -> {
            glitter.setAlpha(RandUtil.nextFloat(0.5f, 0.8f));
            glitter.setScale(RandUtil.nextFloat(0.3f, 0.6f));
            glitter.setLifetime(RandUtil.nextInt(30, 50));
            glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
            glitter.setAlphaFunction(new InterpFloatInOut(0f, 1f));
        });
    });
}
Also used : Entity(net.minecraft.entity.Entity) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) InterpLine(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine) 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 27 with InterpFloatInOut

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

the class ModuleEffectDecay 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(30);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter.enableMotionCalculation();
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), 500, 0, (i, build) -> {
        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);
        build.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.1f, 1f), 1f));
        build.setMotion(new Vec3d(x, RandUtil.nextDouble(-radius, radius), z).normalize().scale(1.5 * RandUtil.nextFloat()));
        build.setAcceleration(Vec3d.ZERO);
        build.setLifetime(50);
        build.setDeceleration(new Vec3d(0.7, 0.7, 0.7));
        build.setAlphaFunction(new InterpFloatInOut(0f, 0.1f));
        build.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
        build.setTick(particle -> {
            if (particle.getAge() > 15) {
                particle.setAcceleration(new Vec3d(0, -0.015, 0));
                particle.setJitterChance(1);
                particle.setJitterMagnitude(new Vec3d(RandUtil.nextDouble(-0.05, 0.05), 0, RandUtil.nextDouble(-0.05, 0.05)));
            }
        });
    });
}
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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 28 with InterpFloatInOut

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

the class ModuleEffectAntiGravityWell method renderSpell.

@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Vec3d position = spell.getData(ORIGIN);
    if (position == null)
        return;
    double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell);
    double maxPotency = spellRing.getModule() != null ? spellRing.getModule().getAttributeRanges().get(AttributeRegistry.POTENCY).max : 1;
    ParticleBuilder glitter = new ParticleBuilder(0);
    glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), 10, 10, (aFloat, particleBuilder) -> {
        particleBuilder.setScale((float) RandUtil.nextDouble(0.3, 1));
        particleBuilder.setAlphaFunction(new InterpFloatInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
        particleBuilder.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        particleBuilder.setLifetime(RandUtil.nextInt(20, 30));
        particleBuilder.setScaleFunction(new InterpScale(1, 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);
        particleBuilder.setMotion(new Vec3d(x, RandUtil.nextDouble(-radius, radius), z).normalize().scale(RandUtil.nextFloat((float) ((maxPotency - potency) / maxPotency / 10.0))));
    });
}
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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 29 with InterpFloatInOut

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

the class ModuleShapeCone method renderSpell.

/**
 * {@inheritDoc}
 */
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
    if (overrides.onRenderCone(world, spell, spellRing))
        return;
    Vec3d target = spell.getTarget(world);
    if (target == null)
        return;
    Vec3d origin = spell.getOriginHand(world);
    if (origin == null)
        return;
    ParticleBuilder lines = new ParticleBuilder(10);
    lines.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    lines.setScaleFunction(new InterpScale(0.5f, 0));
    lines.setColorFunction(new InterpColorHSV(spellRing.getPrimaryColor(), spellRing.getSecondaryColor()));
    ParticleSpawner.spawn(lines, world, new InterpLine(origin, target), (int) target.distanceTo(origin) * 4, 0, (aFloat, particleBuilder) -> {
        lines.setAlphaFunction(new InterpFloatInOut(0.3f, 0.3f));
        lines.setLifetime(RandUtil.nextInt(10, 20));
    });
}
Also used : InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) InterpLine(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine) 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) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 30 with InterpFloatInOut

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

the class TileManaBattery method update.

@Override
public void update() {
    super.update();
    if (getBlockType() == ModBlocks.MANA_BATTERY && !((BlockManaBattery) getBlockType()).testStructure(getWorld(), getPos()).isEmpty())
        return;
    if (getStructurePos() != getPos()) {
        setStructurePos(getPos());
        markDirty();
    }
    if (getBlockType() != ModBlocks.CREATIVE_MANA_BATTERY) {
        for (BlockPos relative : poses) {
            BlockPos target = getPos().add(relative);
            TileEntity tile = world.getTileEntity(target);
            if (tile instanceof TileOrbHolder) {
                if (!((TileOrbHolder) tile).isPartOfStructure() || ((TileOrbHolder) tile).canSuckFromOutside() || !((TileOrbHolder) tile).canGiveToOutside()) {
                    ((TileOrbHolder) tile).setStructurePos(getPos());
                    ((TileOrbHolder) tile).setCanSuckFromOutside(false);
                    ((TileOrbHolder) tile).setCanGiveToOutside(true);
                    tile.markDirty();
                }
            }
        }
        if (world.getTotalWorldTime() % 20 == 0 && !ManaManager.forObject(getWizardryCap()).isManaFull()) {
            ManaManager.forObject(getWizardryCap()).addMana(5).removeBurnout(5).close();
            if (world.isRemote)
                ClientRunnable.run(new ClientRunnable() {

                    @Override
                    @SideOnly(Side.CLIENT)
                    public void runIfClient() {
                        Vec3d from = new Vec3d(getPos()).add(0.5, 1, 0.5);
                        Vec3d to = from.add(RandUtil.nextDouble(-1, 1), -3, RandUtil.nextDouble(-1, 1));
                        ParticleBuilder helix = new ParticleBuilder(200);
                        helix.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
                        helix.setAlphaFunction(new InterpFloatInOut(0.1f, 0.1f));
                        ParticleSpawner.spawn(helix, world, new StaticInterp<>(to), 5, 0, (someFloat, particleBuilder) -> {
                            particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(50, 200)));
                            particleBuilder.setScale(RandUtil.nextFloat(0.3f, 0.8f));
                            particleBuilder.setPositionFunction(new InterpBezier3D(Vec3d.ZERO, from.subtract(to), new Vec3d(0, 5, 0), new Vec3d(0, 1, 0)));
                            particleBuilder.setLifetime(RandUtil.nextInt(50, 60));
                        });
                    }
                });
        }
    } else {
        ManaManager.forObject(getWizardryCap()).setMana(ManaManager.getMaxMana(getWizardryCap())).setBurnout(0).close();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) InterpBezier3D(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D) BlockPos(net.minecraft.util.math.BlockPos) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

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