Search in sources :

Example 1 with ParticleBuilder

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

the class ModuleShapeCone method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Vec3d target = spell.getTarget();
    if (target == null)
        return;
    Vec3d origin = spell.getOriginHand();
    if (origin == null)
        return;
    ParticleBuilder lines = new ParticleBuilder(10);
    lines.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    lines.setScaleFunction(new InterpScale(0.5f, 0));
    lines.setColorFunction(new InterpColorHSV(spellRing.getPrimaryColor(), spellRing.getSecondaryColor()));
    ParticleSpawner.spawn(lines, spell.world, new InterpLine(origin, target), (int) target.distanceTo(origin) * 4, 0, (aFloat, particleBuilder) -> {
        lines.setAlphaFunction(new InterpFadeInOut(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) 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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with ParticleBuilder

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

the class ModuleShapeSelf method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity caster = spell.getCaster();
    if (caster == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(1);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    ParticleSpawner.spawn(glitter, spell.world, new InterpCircle(caster.getPositionVector().addVector(0, caster.height / 2.0, 0), new Vec3d(0, 1, 0), 1, 10), 50, RandUtil.nextInt(10, 15), (aFloat, particleBuilder) -> {
        if (RandUtil.nextBoolean()) {
            glitter.setColor(getPrimaryColor());
            glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.1), 0));
        } else {
            glitter.setColor(getSecondaryColor());
            glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(-0.1, -0.01), 0));
        }
        glitter.setLifetime(RandUtil.nextInt(20, 30));
        glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
        glitter.setAlphaFunction(new InterpFadeInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
        glitter.setLifetime(RandUtil.nextInt(10, 20));
        glitter.setScaleFunction(new InterpScale(1, 0));
    });
}
Also used : Entity(net.minecraft.entity.Entity) InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) 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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with ParticleBuilder

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

the class ModuleShapeTouch method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity targetEntity = spell.getVictim();
    if (targetEntity == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(1);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    ParticleSpawner.spawn(glitter, spell.world, new InterpCircle(targetEntity.getPositionVector().addVector(0, targetEntity.height / 2.0, 0), new Vec3d(0, 1, 0), 1, 10), 50, RandUtil.nextInt(10, 15), (aFloat, particleBuilder) -> {
        if (RandUtil.nextBoolean()) {
            glitter.setColor(getPrimaryColor());
            glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.1), 0));
        } else {
            glitter.setColor(getSecondaryColor());
            glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(-0.1, -0.01), 0));
        }
        glitter.setLifetime(RandUtil.nextInt(20, 30));
        glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
        glitter.setAlphaFunction(new InterpFadeInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
        glitter.setLifetime(RandUtil.nextInt(10, 20));
        glitter.setScaleFunction(new InterpScale(1, 0));
    });
}
Also used : Entity(net.minecraft.entity.Entity) InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) 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) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with ParticleBuilder

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

the class TileManaInteracter method suckManaFrom.

public boolean suckManaFrom(TileManaInteracter interacterFrom, SuckRule suckRule) {
    if (getWizardryCap() == null || interacterFrom.getWizardryCap() == null)
        return false;
    if (!isAllowOutsideSucking() && interacterFrom.isAllowOutsideSucking())
        return false;
    if (!suckRule.condition.test(this, interacterFrom))
        return false;
    CapManager thisManager = new CapManager(getWizardryCap());
    CapManager theirManager = new CapManager(interacterFrom.getWizardryCap());
    if (thisManager.isManaFull())
        return false;
    if (theirManager.isManaEmpty())
        return false;
    if (suckRule.equalize && Math.abs(thisManager.getMana() - theirManager.getMana()) <= suckRule.idealAmount)
        return false;
    Vec3d thisPos = new Vec3d(getPos()).addVector(0.5, 0.5, 0.5);
    Vec3d theirPos = new Vec3d(interacterFrom.getPos()).addVector(0.5, 0.5, 0.5);
    // DEBUG
    // ParticleBuilder helix = new ParticleBuilder(200);
    // helix.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    // helix.setAlphaFunction(new InterpFadeInOut(0.1f, 0.1f));
    // ParticleSpawner.spawn(helix, world, new StaticInterp<>(thisPos), 1, 0, (someFloat, particleBuilder) -> {
    // particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0xFF0000), RandUtil.nextInt(50, 200)));
    // particleBuilder.setScale(RandUtil.nextFloat(0.3f, 0.8f));
    // particleBuilder.disableRandom();
    // particleBuilder.setPositionFunction(new InterpLine(Vec3d.ZERO, theirPos.subtract(thisPos)));
    // particleBuilder.setLifetime(RandUtil.nextInt(50, 60));
    // });
    double ratio = theirManager.getMana() / thisManager.getMana();
    if (suckRule.equalize && Double.isFinite(ratio) && ratio <= 1.2)
        return false;
    if (getCachedDistanceSq(interacterFrom) > ConfigValues.networkLinkDistance * ConfigValues.networkLinkDistance)
        return false;
    if (!suckRule.ignoreTrace) {
        Vec3d thisSub = theirPos.subtract(thisPos.add(getOffset()));
        Vec3d thisNorm = thisSub.normalize();
        RayTraceResult trace = new RayTrace(world, thisNorm, thisPos.add(getOffset() == Vec3d.ZERO ? thisNorm : getOffset()), ConfigValues.networkLinkDistance * ConfigValues.networkLinkDistance).setSkipEntities(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
        if (!trace.getBlockPos().equals(interacterFrom.getPos()))
            return false;
    }
    double amount = interacterFrom.drainMana(suckRule.idealAmount);
    if (amount <= 0)
        return false;
    thisManager.addMana(amount);
    ClientRunnable.run(new ClientRunnable() {

        @Override
        @SideOnly(Side.CLIENT)
        public void runIfClient() {
            ParticleBuilder helix = new ParticleBuilder(200);
            helix.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
            helix.setAlphaFunction(new InterpFadeInOut(0.1f, 0.1f));
            ParticleSpawner.spawn(helix, world, new StaticInterp<>(new Vec3d(interacterFrom.getPos()).addVector(0.5, 1, 0.5)), 1, 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, new Vec3d(getPos().subtract(interacterFrom.getPos())), new Vec3d(0, 5, 0), new Vec3d(0, -5, 0)));
                particleBuilder.setLifetime(RandUtil.nextInt(50, 60));
            });
        }
    });
    return true;
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager) java.util(java.util) 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) RayTraceResult(net.minecraft.util.math.RayTraceResult) BiPredicate(java.util.function.BiPredicate) Module(com.teamwizardry.librarianlib.features.saving.Module) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) ITickable(net.minecraft.util.ITickable) TilePearlHolder(com.teamwizardry.wizardry.common.tile.TilePearlHolder) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) Save(com.teamwizardry.librarianlib.features.saving.Save) Nullable(javax.annotation.Nullable) ConfigValues(com.teamwizardry.wizardry.api.ConfigValues) InterpBezier3D(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D) TileCraftingPlate(com.teamwizardry.wizardry.common.tile.TileCraftingPlate) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) IWizardryCapability(com.teamwizardry.wizardry.api.capability.IWizardryCapability) Wizardry(com.teamwizardry.wizardry.Wizardry) TileMod(com.teamwizardry.librarianlib.features.base.block.tile.TileMod) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) BlockPos(net.minecraft.util.math.BlockPos) ColorUtils(com.teamwizardry.wizardry.api.util.ColorUtils) CustomWizardryCapability(com.teamwizardry.wizardry.api.capability.CustomWizardryCapability) java.awt(java.awt) ManaModule(com.teamwizardry.wizardry.api.capability.ManaModule) TileManaBattery(com.teamwizardry.wizardry.common.tile.TileManaBattery) MathHelper(net.minecraft.util.math.MathHelper) ResourceLocation(net.minecraft.util.ResourceLocation) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) Constants(com.teamwizardry.wizardry.api.Constants) RayTraceResult(net.minecraft.util.math.RayTraceResult) 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) CapManager(com.teamwizardry.wizardry.api.capability.CapManager) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) ResourceLocation(net.minecraft.util.ResourceLocation) InterpBezier3D(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D)

Example 5 with ParticleBuilder

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

the class Arena method tick.

public void tick(long timeMillis) {
    if (timeMillis % 500 == 0)
        ClientRunnable.run(new ClientRunnable() {

            @Override
            @SideOnly(Side.CLIENT)
            public void runIfClient() {
                ParticleBuilder glitter = new ParticleBuilder(10);
                glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
                glitter.setAlphaFunction(new InterpFadeInOut(0.3f, 0.3f));
                glitter.setCollision(true);
                glitter.enableMotionCalculation();
                ParticleSpawner.spawn(glitter, getWorld(), new InterpCircle(new Vec3d(getCenter()).addVector(0.5, getHeight(), 0.5), new Vec3d(0, 1, 0), (float) getRadius(), 1, RandUtil.nextFloat()), 10, RandUtil.nextInt(10), (aFloat, particleBuilder) -> {
                    particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(100, 255)));
                    particleBuilder.setScale(RandUtil.nextFloat(0.5f, 1));
                    particleBuilder.addMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01)));
                    particleBuilder.setLifetime(RandUtil.nextInt(30, 60));
                });
                glitter.disableMotionCalculation();
                ParticleSpawner.spawn(glitter, getWorld(), new InterpCircle(new Vec3d(getCenter()).addVector(0.5, 0, 0.5), new Vec3d(0, 1, 0), (float) getRadius(), 1, RandUtil.nextFloat()), 10, RandUtil.nextInt(10), (aFloat, particleBuilder) -> {
                    particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(100, 255)));
                    particleBuilder.setScale(RandUtil.nextFloat(0.5f, 1));
                    particleBuilder.addMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(0.01, 0.02), RandUtil.nextDouble(-0.01, 0.01)));
                    particleBuilder.setLifetime(RandUtil.nextInt(30, 60));
                });
            }
        });
}
Also used : InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) ResourceLocation(net.minecraft.util.ResourceLocation) 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

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