use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.
the class EntitySpiritBlight method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (world.isRemote)
return;
if (isAIDisabled())
return;
if (RandUtil.nextInt(10) == 0) {
setShiftseed(RandUtil.nextInt(1000, 100000000));
playSound(ModSounds.ZAP, 0.3f, RandUtil.nextFloat(1.5f, 2f));
}
if ((ticksExisted % RandUtil.nextInt(100, 200)) == 0)
playSound(ModSounds.HALLOWED_SPIRIT, RandUtil.nextFloat(), RandUtil.nextFloat());
// if (world.getTotalWorldTime() % 30 == 0) {
// playSound(ModSounds.ELECTRIC_WHITE_NOISE, RandUtil.nextFloat(0.2f, 0.3f), RandUtil.nextFloat(0.1f, 0.3f));
// }
fallDistance = 0;
EntityPlayer farPlayer = world.getNearestPlayerNotCreative(this, 300);
setAttackTarget(farPlayer);
if (getAttackTarget() != null) {
noClip = true;
Vec3d direction = getPositionVector().subtract(getAttackTarget().getPositionVector()).normalize();
motionX = direction.x * -0.05;
motionY = direction.y * -0.05;
motionZ = direction.z * -0.05;
rotationYaw = (float) (((-MathHelper.atan2(direction.x, direction.z) * 180) / Math.PI) - 180) / 2;
} else {
if (!collidedVertically) {
motionY = 0;
}
noClip = false;
}
EntityPlayer player = getAttackTarget() == null ? null : world.getNearestPlayerNotCreative(this, 2);
EntityPlayer closePlayer = getAttackTarget() == null ? null : world.getNearestPlayerNotCreative(this, 30);
boolean angry = player != null;
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
ParticleBuilder glitter = new ParticleBuilder(30);
glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
glitter.setAlphaFunction(new InterpFloatInOut(1f, 1f));
glitter.setColor(new Color(0xf404d4));
RandUtilSeed seed = new RandUtilSeed(getDataManager().get(DATA_SHIFT_SEED));
Vec3d offset = new Vec3d(seed.nextDouble(-3, 3), seed.nextDouble(-3, 3), seed.nextDouble(-3, 3));
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().add(0, getEyeHeight(), 0).add(offset)), 10, 0, (i, build) -> {
double radius = 0.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);
glitter.setLifetime(RandUtil.nextInt(10, 40));
glitter.setScaleFunction(new InterpScale(0, (float) RandUtil.nextDouble(3, 4)));
glitter.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(0, 0.2), z));
if (RandUtil.nextInt(15) == 0)
glitter.addMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.03, 0), RandUtil.nextDouble(-0.01, 0.01)));
});
}
});
if (angry) {
player.attackEntityFrom(DamageSource.MAGIC, 0.15f);
player.hurtResistantTime = 0;
}
}
use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.
the class EntityJumpPad method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (isDead)
return;
if (ticksExisted > 100)
setDead();
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(30, 50));
glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
glitter.setAlphaFunction(new InterpFloatInOut(0.9f, 0.9f));
glitter.disableMotionCalculation();
Color color1 = new Color(RandUtil.nextInt(70, 255), RandUtil.nextInt(70, 255), RandUtil.nextInt(70, 255), RandUtil.nextInt(70, 255));
glitter.setCollision(true);
glitter.setColor(color1);
glitter.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.8f, 1f), 0f));
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 1, 1, (i, build) -> {
double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
double r = 1 * RandUtil.nextFloat();
double x = r * MathHelper.cos((float) theta);
double z = r * MathHelper.sin((float) theta);
glitter.setPositionOffset(new Vec3d(x, 0.1, z));
if (RandUtil.nextBoolean())
glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.05), 0));
});
}
});
}
use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.
the class RenderHaloEntity method doRenderLayer.
@Override
public void doRenderLayer(@Nonnull EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
if (BaublesSupport.getItem(entitylivingbaseIn, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO).isEmpty())
return;
ItemStack halo = BaublesSupport.getItem(entitylivingbaseIn, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO);
// TODO: Remove these once we have a cosmetics system
if (halo.getItem() == ModItems.FAKE_HALO && !ClientConfigValues.renderCrudeHalo)
return;
if (halo.getItem() == ModItems.REAL_HALO && !ClientConfigValues.renderRealHalo)
return;
if (halo.getItem() == ModItems.CREATIVE_HALO && !ClientConfigValues.renderCreativeHalo)
return;
if (halo.getItem() == ModItems.FAKE_HALO) {
GlStateManager.pushMatrix();
if (entitylivingbaseIn.isSneaking())
GlStateManager.translate(0.0f, 0.2f, 0.0f);
boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombieVillager;
if (entitylivingbaseIn.isChild() && !(entitylivingbaseIn instanceof EntityVillager)) {
GlStateManager.translate(0.0f, 0.5f * scale, 0.0f);
GlStateManager.scale(0.7f, 0.7f, 0.7f);
GlStateManager.translate(0.0f, 16.0f * scale, 0.0f);
}
if (flag)
GlStateManager.translate(0.0f, 0.1875f, 0.0f);
this.modelRenderer.postRender(0.0625f);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
GlStateManager.translate(0.0f, -0.25f, 0.0f);
GlStateManager.rotate(180.0f, 0.0f, 1.0f, 0.0f);
GlStateManager.scale(0.625f, -0.625f, -0.625f);
Minecraft.getMinecraft().getItemRenderer().renderItem(entitylivingbaseIn, halo, ItemCameraTransforms.TransformType.HEAD);
GlStateManager.popMatrix();
} else {
Entity entity = entitylivingbaseIn;
Vec3d entityOrigin = entity.getPositionVector().add(0, entity.height + (entity.isSneaking() ? 0.2 : 0.4), 0);
InterpCircle circle = new InterpCircle(Vec3d.ZERO, new Vec3d(0, 1, 0), 0.3f, RandUtil.nextFloat(), RandUtil.nextFloat());
for (Vec3d origin : circle.list(5)) {
RenderFunction baseRenderFunction = new RenderFunctionBasic(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED), false);
ParticleBuilder glitter = new ParticleBuilder(3);
glitter.setAlphaFunction(new InterpFloatInOut(1f, 1f));
glitter.disableMotionCalculation();
glitter.disableRandom();
ParticleSpawner.spawn(glitter, entity.world, new StaticInterp<>(entityOrigin.add(origin)), 1, 0, (aFloat, particleBuilder) -> {
if (RandUtil.nextInt(10) != 0)
if (halo.getItem() == ModItems.CREATIVE_HALO)
glitter.setColor(ColorUtils.changeColorAlpha(new Color(0xd600d2), RandUtil.nextInt(60, 100)));
else
glitter.setColor(ColorUtils.changeColorAlpha(Color.YELLOW, RandUtil.nextInt(60, 100)));
else
glitter.setColor(ColorUtils.changeColorAlpha(Color.WHITE, RandUtil.nextInt(60, 100)));
glitter.setAlphaFunction(new InterpFloatInOut(0.5f, 0.5f));
glitter.setLifetime(10);
glitter.setScaleFunction(new InterpFloatInOut(0.5f, 0.5f));
glitter.setRenderFunction(new RenderFunction(ParticleRenderManager.getLAYER_BLOCK_MAP_ADDITIVE()) {
@Override
public void render(float i, @NotNull ParticleBase particle, @NotNull Color color, float alpha, @NotNull BufferBuilder worldRendererIn, @Nullable Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ, float scale, float rotation, @NotNull Vec3d pos, int skyLight, int blockLight) {
Vec3d interpPos = new Vec3d(// ClientTickHandler.interpPartialTicks(entity.prevPosZ, entity.posZ) - Particle.interpPosZ
entity.prevPosX + (entity.posX - entity.prevPosX) * ClientTickHandler.getPartialTicks() - Particle.interpPosX, entity.prevPosY + (entity.posY - entity.prevPosY) * ClientTickHandler.getPartialTicks() - Particle.interpPosY, entity.prevPosZ + (entity.posZ - entity.prevPosZ) * ClientTickHandler.getPartialTicks() - Particle.interpPosZ);
Vec3d newPos = interpPos.add(0, entity.height + (entity.isSneaking() ? 0.2 : 0.4), 0).add(origin);
baseRenderFunction.render(i, particle, color, alpha, worldRendererIn, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ, scale, rotation, newPos, skyLight, blockLight);
}
});
});
}
}
}
use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.
the class TileManaNode method suckManaFrom.
public double suckManaFrom(TileManaNode interacterFrom, SuckRule suckRule, IManaCapability cap) {
if (cap == null || interacterFrom.getWizardryCap() == null)
return 0;
if (!suckRule.condition.test(this, interacterFrom))
return 0;
try (ManaManager.CapManagerBuilder thisMgr = ManaManager.forObject(cap)) {
try (ManaManager.CapManagerBuilder theirMgr = ManaManager.forObject(interacterFrom.getWizardryCap())) {
if (thisMgr.isManaFull())
return 0;
if (theirMgr.isManaEmpty())
return 0;
if (suckRule.equalize && Math.abs(thisMgr.getMana() - theirMgr.getMana()) <= suckRule.idealAmount)
return 0;
double ratio = theirMgr.getMana() / thisMgr.getMana();
if (suckRule.equalize && Double.isFinite(ratio) && ratio <= 1.2)
return 0;
double amount = interacterFrom.drainMana(suckRule.idealAmount);
if (amount <= 0)
return 0;
ManaManager.forObject(cap).addMana(amount).close();
if (world.isRemote)
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
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<>(new Vec3d(interacterFrom.getPos()).add(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 amount;
}
}
}
use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.
the class ModuleShapeSelf 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.onRenderSelf(world, spell, spellRing))
return;
Entity caster = spell.getCaster(world);
if (caster == null)
return;
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<>(caster.getPositionVector()), 50, 5, (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.setPositionOffset(new Vec3d(RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5)));
build.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.2f, 1f), 0f));
build.setMotion(new Vec3d(x, RandUtil.nextDouble(radius / 2.0, radius), z).normalize().scale(RandUtil.nextFloat()));
build.setAcceleration(Vec3d.ZERO);
build.setLifetime(50);
build.setDeceleration(new Vec3d(0.8, 0.8, 0.8));
if (RandUtil.nextBoolean()) {
build.setColorFunction(new InterpColorHSV(spellRing.getPrimaryColor(), spellRing.getSecondaryColor()));
} else {
build.setColorFunction(new InterpColorHSV(spellRing.getSecondaryColor(), spellRing.getPrimaryColor()));
}
});
}
Aggregations