use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.
the class EntitySpiritBlight method onDeath.
@Override
public void onDeath(DamageSource cause) {
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(100, 150));
glitter.setColor(Color.WHITE);
glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
glitter.setAlphaFunction(new InterpFloatInOut(0.1f, 0.1f));
glitter.setAcceleration(Vec3d.ZERO);
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().add(0, height, 0)), 1000, 0, (i, build) -> {
double radius = 0.2;
build.setDeceleration(new Vec3d(RandUtil.nextDouble(0.8, 0.95), RandUtil.nextDouble(0.8, 0.95), RandUtil.nextDouble(0.8, 0.95)));
build.addMotion(new Vec3d(RandUtil.nextDouble(-radius, radius), RandUtil.nextDouble(-radius, radius), RandUtil.nextDouble(-radius, radius)));
build.setLifetime(RandUtil.nextInt(200, 250));
build.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.6f, 1.5f), 0));
if (RandUtil.nextBoolean())
build.setColor(Color.WHITE);
else
build.setColor(new Color(0xf404d4));
});
}
});
playSound(ModSounds.BASS_BOOM, 3, 0.5f);
playSound(ModSounds.BASS_BOOM, 1, RandUtil.nextFloat(1, 1.5f));
super.onDeath(cause);
}
use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.
the class EntitySpiritWight method onDeath.
@Override
public void onDeath(DamageSource cause) {
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(100, 150));
glitter.setColor(Color.WHITE);
glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
glitter.setAlphaFunction(new InterpFloatInOut(0.1f, 0.1f));
glitter.setAcceleration(Vec3d.ZERO);
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().add(0, height, 0)), 1000, 0, (i, build) -> {
double radius = 0.2;
build.setDeceleration(new Vec3d(RandUtil.nextDouble(0.8, 0.95), RandUtil.nextDouble(0.8, 0.95), RandUtil.nextDouble(0.8, 0.95)));
build.addMotion(new Vec3d(RandUtil.nextDouble(-radius, radius), RandUtil.nextDouble(-radius, radius), RandUtil.nextDouble(-radius, radius)));
build.setLifetime(RandUtil.nextInt(200, 250));
build.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.6f, 1.5f), 0));
if (RandUtil.nextBoolean())
build.setColor(Color.WHITE);
else
build.setColor(Color.YELLOW);
});
}
});
playSound(ModSounds.BASS_BOOM, 3, 0.5f);
playSound(ModSounds.BASS_BOOM, 1, RandUtil.nextFloat(1, 1.5f));
super.onDeath(cause);
}
use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.
the class ModuleEffectPhase method renderSpell.
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
EnumFacing faceHit = spell.getFaceHit();
Set<BlockPos> blockSet = spell.getDataWithFallback(SpellData.DefaultKeys.BLOCK_SET, new BlockSet(new HashSet<>())).getBlockSet();
Map<BlockPos, IBlockState> blockStateCache = spell.getDataWithFallback(SpellData.DefaultKeys.BLOCKSTATE_CACHE, new BlockStateCache(new HashMap<>())).getBlockStateCache();
HashMap<BlockPos, IBlockState> tmpCache = new HashMap<>(blockStateCache);
double duration = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 20;
PhasedBlockRenderer.addPhase(world, blockSet, (int) duration);
if (faceHit != null) {
for (Map.Entry<BlockPos, IBlockState> entry : tmpCache.entrySet()) {
IBlockState thisState = entry.getValue();
if (thisState.getBlock() != ModBlocks.FAKE_AIR)
continue;
ParticleBuilder glitter2 = new ParticleBuilder(10);
glitter2.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
glitter2.disableRandom();
ParticleSpawner.spawn(glitter2, world, new StaticInterp<>(new Vec3d(entry.getKey()).add(0.5, 0.5, 0.5)), 5, (int) duration, (aFloat, build) -> {
build.setColor(Color.CYAN);
// build.setAlphaFunction(new InterpFloatInOut(1f, 0.1f));
build.setAlpha(RandUtil.nextFloat(0.05f, 0.2f));
build.setPositionOffset(new Vec3d(RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5)));
build.setMotion(new Vec3d(RandUtil.nextDouble(-0.001, 0.001), RandUtil.nextDouble(-0.001, 0.001), RandUtil.nextDouble(-0.001, 0.001)));
build.setLifetime(RandUtil.nextInt(20, 40));
build.setScaleFunction(new InterpFloatInOut(0.9f, 0.9f));
build.setScale(RandUtil.nextFloat(0.1f, 0.3f));
});
BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(entry.getKey());
for (EnumFacing facing : EnumFacing.VALUES) {
mutable.move(facing);
IBlockState adjState;
if (!blockStateCache.containsKey(mutable)) {
adjState = world.getBlockState(mutable);
blockStateCache.put(mutable.toImmutable(), adjState);
} else
adjState = blockStateCache.get(mutable);
if (adjState.getBlock() != Blocks.AIR && adjState.getBlock() != ModBlocks.FAKE_AIR) {
Vec3d directionOffsetVec = new Vec3d(facing.getOpposite().getDirectionVec()).scale(0.5);
Vec3d adjPos = new Vec3d(mutable).add(0.5, 0.5, 0.5).add(directionOffsetVec);
for (EnumFacing subFacing : getPerpendicularFacings(facing)) {
mutable.move(subFacing);
IBlockState subState;
if (!blockStateCache.containsKey(mutable)) {
subState = world.getBlockState(mutable);
blockStateCache.put(mutable.toImmutable(), subState);
} else
subState = blockStateCache.get(mutable);
if (BlockUtils.isAnyAir(subState)) {
Vec3d subPos = new Vec3d(mutable).add(0.5, 0.5, 0.5).add(directionOffsetVec);
Vec3d midPointVec = new Vec3d((adjPos.x + subPos.x) / 2.0, (adjPos.y + subPos.y) / 2.0, (adjPos.z + subPos.z) / 2.0);
Vec3d sub = subPos.subtract(adjPos);
EnumFacing adjSubFacing = EnumFacing.getFacingFromVector((float) sub.x, (float) sub.y, (float) sub.z);
Vec3d cross = new Vec3d(adjSubFacing.getDirectionVec()).crossProduct(new Vec3d(facing.getDirectionVec())).normalize().scale(0.5);
ParticleBuilder glitter = new ParticleBuilder(10);
glitter.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
glitter.disableRandom();
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(midPointVec), 50, (int) duration, (aFloat, build) -> {
build.setColor(Color.CYAN);
// build.setAlphaFunction(new InterpFloatInOut(1f, 0.1f));
build.setAlpha(RandUtil.nextFloat(0.3f, 0.7f));
build.setPositionOffset(cross.scale(RandUtil.nextFloat(-1, 1)));
build.setLifetime(RandUtil.nextInt(20, 40));
build.setScaleFunction(new InterpFloatInOut(0.9f, 0.9f));
build.setScale(RandUtil.nextFloat(0.2f, 0.5f));
});
}
mutable.move(subFacing.getOpposite());
}
}
mutable.move(facing.getOpposite());
}
}
}
}
use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.
the class ModuleShapeTouch method renderSpell.
@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.onRenderTouch(world, spell, spellRing))
return;
Entity targetEntity = spell.getVictim(world);
if (targetEntity == null)
return;
ParticleBuilder glitter = new ParticleBuilder(1);
glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
ParticleSpawner.spawn(glitter, world, new InterpCircle(targetEntity.getPositionVector().add(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(spellRing.getPrimaryColor());
glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.1), 0));
} else {
glitter.setColor(spellRing.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 InterpFloatInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
glitter.setLifetime(RandUtil.nextInt(10, 20));
glitter.setScaleFunction(new InterpScale(1, 0));
});
}
use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.
the class ModuleEffectGrace method renderSpell.
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
Entity target = spell.getVictim(world);
if (!(target instanceof EntityLivingBase))
return;
if (!((EntityLivingBase) target).isPotionActive(ModPotions.GRACE))
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.disableRandom();
ParticleSpawner.spawn(glitter, world, new InterpCircle(target.getPositionVector().add(0, target.height / 2.0, 0), new Vec3d(Math.cos(world.getTotalWorldTime() / 10.0), 1, Math.cos(world.getTotalWorldTime() / 10.0)), 2), 15, 0, (aFloat, particleBuilder) -> {
particleBuilder.setLifetime(RandUtil.nextInt(20, 25));
particleBuilder.setScaleFunction(new InterpScale(RandUtil.nextFloat(1f, 1.5f), 0f));
particleBuilder.setAlphaFunction(new InterpFloatInOut(aFloat, aFloat));
});
}
Aggregations