Search in sources :

Example 21 with InterpFloatInOut

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

the class ModuleEffectLight method renderSpell.

@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    BlockPos position = spell.getTargetPos();
    EnumFacing facing = spell.getFaceHit();
    if (position == null)
        return;
    BlockPos finalPos = position;
    if (facing != null && world.isAirBlock(position.offset(facing)))
        finalPos = position.offset(facing);
    ParticleBuilder glitter = new ParticleBuilder(30);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter.setAlphaFunction(new InterpFloatInOut(0.3f, 0.3f));
    glitter.enableMotionCalculation();
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(new Vec3d(finalPos).add(0.5, 0.5, 0.5)), 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.2f, 1f), 0f));
        build.setMotion(new Vec3d(x, RandUtil.nextDouble(-radius, radius), z).normalize().scale(RandUtil.nextFloat()));
        build.setAcceleration(Vec3d.ZERO);
        build.setLifetime(20);
        build.setDeceleration(new Vec3d(0.4, 0.4, 0.4));
        if (RandUtil.nextBoolean()) {
            build.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
        } else {
            build.setColorFunction(new InterpColorHSV(instance.getSecondaryColor(), instance.getPrimaryColor()));
        }
    });
}
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) EnumFacing(net.minecraft.util.EnumFacing) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 22 with InterpFloatInOut

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

the class ModuleEffectSubstitution method renderSpell.

@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity caster = spell.getCaster(world);
    BlockPos targetBlock = spell.getTargetPos();
    Entity targetEntity = spell.getVictim(world);
    if (targetEntity != null && caster != null) {
        ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(20, 30));
        glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
        ParticleSpawner.spawn(glitter, world, new StaticInterp<>(new Vec3d(targetEntity.posX, targetEntity.posY, targetEntity.posZ)), 50, RandUtil.nextInt(20, 30), (aFloat, particleBuilder) -> {
            glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
            glitter.setAlphaFunction(new InterpFloatInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
            glitter.setLifetime(RandUtil.nextInt(10, 20));
            glitter.setScaleFunction(new InterpScale(1, 0));
            glitter.setPositionFunction(new InterpHelix(new Vec3d(0, 0, 0), new Vec3d(0, 2, 0), 0.5f, 0f, 1, RandUtil.nextFloat()));
        });
        glitter.setColorFunction(new InterpColorHSV(instance.getSecondaryColor(), instance.getPrimaryColor()));
        ParticleSpawner.spawn(glitter, world, new StaticInterp<>(new Vec3d(caster.posX, caster.posY, caster.posZ)), 50, RandUtil.nextInt(20, 30), (aFloat, particleBuilder) -> {
            glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
            glitter.setAlphaFunction(new InterpFloatInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
            glitter.setLifetime(RandUtil.nextInt(10, 20));
            glitter.setScaleFunction(new InterpScale(1, 0));
            glitter.setPositionFunction(new InterpHelix(new Vec3d(0, 0, 0), new Vec3d(0, 4, 0), 1f, 0f, 1, RandUtil.nextFloat()));
        });
    } else if (targetBlock != null) {
        ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(20, 30));
        glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
        ParticleSpawner.spawn(glitter, world, new StaticInterp<>(new Vec3d(targetBlock).add(0.5, 0.5, 0.5)), 20, 0, (aFloat, particleBuilder) -> {
            glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
            glitter.setAlphaFunction(new InterpFloatInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
            glitter.setLifetime(RandUtil.nextInt(10, 20));
            glitter.setScaleFunction(new InterpScale(1, 0));
            glitter.setMotion(new Vec3d(RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.1, 0.1)));
        });
    }
}
Also used : RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) Blocks(net.minecraft.init.Blocks) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) ModuleInstanceEffect(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceEffect) HashMap(java.util.HashMap) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) IProperty(net.minecraft.block.properties.IProperty) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) Map(java.util.Map) ModSounds(com.teamwizardry.wizardry.init.ModSounds) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) IModuleEffect(com.teamwizardry.wizardry.api.spell.module.IModuleEffect) SoundCategory(net.minecraft.util.SoundCategory) Nonnull(javax.annotation.Nonnull) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Entity(net.minecraft.entity.Entity) IBlockSelectable(com.teamwizardry.wizardry.api.spell.IBlockSelectable) World(net.minecraft.world.World) Wizardry(com.teamwizardry.wizardry.Wizardry) EnumFacing(net.minecraft.util.EnumFacing) Set(java.util.Set) InterpHelix(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpHelix) BlockPos(net.minecraft.util.math.BlockPos) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) ModuleRegistry(com.teamwizardry.wizardry.api.spell.module.ModuleRegistry) IBlockState(net.minecraft.block.state.IBlockState) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) BlockUtils(com.teamwizardry.wizardry.api.util.BlockUtils) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) NBTHelper(com.teamwizardry.librarianlib.features.helpers.NBTHelper) ResourceLocation(net.minecraft.util.ResourceLocation) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) ItemBlock(net.minecraft.item.ItemBlock) NotNull(org.jetbrains.annotations.NotNull) NBTUtil(net.minecraft.nbt.NBTUtil) Entity(net.minecraft.entity.Entity) InterpHelix(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpHelix) 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) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) BlockPos(net.minecraft.util.math.BlockPos) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 23 with InterpFloatInOut

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

the class ModuleEffectPoisonCloud 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(0);
    if (RandUtil.nextInt(5) != 0)
        glitter.setColor(instance.getPrimaryColor());
    else
        glitter.setColor(instance.getSecondaryColor());
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SMOKE));
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(position), 20, 0, (aFloat, particleBuilder) -> {
        particleBuilder.setLifetime(RandUtil.nextInt(10, 40));
        particleBuilder.setScale(RandUtil.nextFloat(5, 10));
        particleBuilder.setAlpha(RandUtil.nextFloat(0.3f, 0.5f));
        particleBuilder.setAlphaFunction(new InterpFloatInOut(0.3f, 0.4f));
        double area = spellRing.getAttributeValue(world, AttributeRegistry.AREA, spell);
        double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
        double r = area * RandUtil.nextFloat();
        double x = r * MathHelper.cos((float) theta);
        double z = r * MathHelper.sin((float) theta);
        particleBuilder.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(-r, r), z));
        particleBuilder.setMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01)));
    // particleBuilder.setAcceleration(new Vec3d(0, -0.015, 0));
    });
}
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 24 with InterpFloatInOut

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

the class ModuleEffectTimeSlow method renderSpell.

@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity victim = spell.getVictim(world);
    if (victim == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(30);
    glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter.setScaleFunction(new InterpScale(1, 0));
    glitter.setCollision(true);
    glitter.enableMotionCalculation();
    glitter.setAcceleration(new Vec3d(0, RandUtil.nextBoolean() ? -0.0001 : 0.0001, 0));
    glitter.disableRandom();
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(victim.getPositionVector().add(0, victim.height / 2, 0)), 5, 0, (aFloat, particleBuilder) -> {
        glitter.setLifetime(RandUtil.nextInt(40, 80));
        glitter.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.5f, 1f), 0f));
        glitter.setAlphaFunction(new InterpFloatInOut(0.5f, 0.5f));
        double radius = RandUtil.nextDouble(0, 2);
        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);
        Vec3d dest = new Vec3d(x, RandUtil.nextDouble(-radius, radius), z);
        glitter.setPositionOffset(dest);
        glitter.setMotion(new Vec3d(RandUtil.nextDouble(-0.001, 0.001), 0, RandUtil.nextDouble(-0.001, 0.001)));
    // glitter.setPositionFunction(new InterpSlowDown(Vec3d.ZERO, new Vec3d(0, RandUtil.nextDouble(-1, 1), 0)));
    // glitter.setPositionFunction(new InterpBezier3D(Vec3d.ZERO, position.subtract(dest), dest.scale(2), new Vec3d(position.x, radius, position.z)));
    });
}
Also used : Entity(net.minecraft.entity.Entity) 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) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 25 with InterpFloatInOut

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

the class ModuleEffectGravityWell 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;
    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.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(-radius, radius), z).normalize().scale(RandUtil.nextFloat((float) ((maxPotency - potency) / maxPotency / 10.0))));
        particleBuilder.addMotion(particleBuilder.getPositionOffset().scale(-1.0 / RandUtil.nextDouble(10, 30)));
    });
}
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)

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