use of com.teamwizardry.librarianlib.features.math.Matrix4 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;
}
}
Aggregations