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));
});
});
}
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)));
}
});
});
}
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))));
});
}
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));
});
}
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();
}
}
Aggregations