use of com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp in project Wizardry by TeamWizardry.
the class EntityCorruptionArea method onUpdate.
public void onUpdate() {
super.onUpdate();
float radius = this.getRadius();
if (duration < 0)
setDead();
duration--;
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, Constants.MISC.SPARKLE_BLURRED));
glitter.enableMotionCalculation();
glitter.setCollision(true);
glitter.setCanBounce(true);
glitter.setAcceleration(new Vec3d(0, -0.035, 0));
glitter.setColor(new Color(255, 0, 206));
glitter.setAlphaFunction(new InterpFadeInOut(0.5f, 0f));
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 1, 1, (i, build) -> {
double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
double r = getRadius() * RandUtil.nextFloat();
double x = r * MathHelper.cos((float) theta);
double z = r * MathHelper.sin((float) theta);
build.setPositionOffset(new Vec3d(x, 0, z));
build.addMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.15), 0));
});
}
});
radius += radiusPerTick;
setRadius(radius);
Iterator<Entry<Entity, Integer>> iter = this.reapplicationDelayMap.entrySet().iterator();
while (iter.hasNext()) {
Entry<Entity, Integer> entry = iter.next();
int timeLeft = entry.getValue();
if (timeLeft > 0)
entry.setValue(timeLeft - 1);
else
iter.remove();
}
List<EntityLivingBase> entityList = world.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox());
for (EntityLivingBase entity : entityList) {
if (entity instanceof EntityZachriel)
continue;
if (this.reapplicationDelayMap.containsKey(entity))
continue;
double xDiff = entity.posX - this.posX;
double zDiff = entity.posY - this.posY;
if (xDiff * xDiff + zDiff * zDiff <= radius * radius)
affectEntity(entity);
}
}
use of com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp 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(100) == 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, Constants.MISC.SPARKLE_BLURRED));
glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f));
glitter.setColor(new Color(0xf404d4));
RandUtilSeed seed = new RandUtilSeed(getDataManager().get(DATA_SHIFT_SEED));
Matrix4 matrix4 = new Matrix4();
matrix4.rotate(rotationYaw, new Vec3d(0, 1, 0));
Vec3d offset = new Vec3d(seed.nextDouble(-2, 2), seed.nextDouble(-2, 2), seed.nextDouble(-2, 2));
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().addVector(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, 0.03), 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.StaticInterp in project Wizardry by TeamWizardry.
the class EntityJumpPad method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
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, Constants.MISC.SPARKLE_BLURRED));
glitter.setAlphaFunction(new InterpFadeInOut(0.9f, 0.9f));
glitter.enableMotionCalculation();
Color color1 = new Color(RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255));
Color color2 = new Color(RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255));
glitter.setCollision(true);
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 1, 1, (i, build) -> {
if (RandUtil.nextBoolean())
glitter.setColor(color1);
else
glitter.setColor(color2);
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.3, z));
if (RandUtil.nextBoolean())
glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.2), 0));
});
if (RandUtil.nextInt(30) == 0)
LibParticles.AIR_THROTTLE(world, getPositionVector(), new Vec3d(0, RandUtil.nextDouble(0.5), 0), color1, color2, 0.5);
}
});
}
use of com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp in project Wizardry by TeamWizardry.
the class PacketDevilDustFizzle method handle.
@Override
public void handle(MessageContext messageContext) {
if (messageContext.side.isServer())
return;
World world = LibrarianLib.PROXY.getClientPlayer().world;
if (world == null)
return;
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
ParticleBuilder glitter = new ParticleBuilder(30);
glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
glitter.setMotionCalculationEnabled(true);
glitter.setCollision(true);
glitter.setCanBounce(true);
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), 15, RandUtil.nextInt(10), (i, builder) -> {
builder.setAcceleration(new Vec3d(0, RandUtil.nextDouble(-0.05, -0.01), 0));
builder.setColor(new Color(RandUtil.nextFloat(0.9f, 1), RandUtil.nextFloat(0, 0.25f), 0));
builder.setAlphaFunction(new InterpFadeInOut(0.0f, RandUtil.nextFloat(1f, 0.3f)));
builder.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.3f, 1f), RandUtil.nextFloat(0, 0.2f)));
Vec3d offset = new Vec3d(RandUtil.nextDouble(-0.3, 0.3), RandUtil.nextDouble(-0.3, 0), RandUtil.nextDouble(-0.3, 0.3));
builder.setPositionOffset(offset);
builder.setLifetime(RandUtil.nextInt(20, 60));
builder.setMotion(new Vec3d(RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(0.1, 0.5), RandUtil.nextDouble(-0.1, 0.1)));
});
}
});
}
Aggregations