use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable in project Wizardry by TeamWizardry.
the class EntityZachriel method onUpdate.
@Override
public void onUpdate() {
this.motionY = 0;
super.onUpdate();
// BATTLE
{
if (arena == null) {
HashSet<UUID> players = new HashSet<>();
arena = new Arena(getEntityWorld().provider.getDimension(), getPosition(), 50, 50, getEntityId(), players);
ArenaManager.INSTANCE.addArena(arena);
}
for (EntityLivingBase targeted : arena.getVictims()) nemezDrive.trackEntity(targeted);
if (burstTimer > 0) {
burstTimer--;
if (burstTimer == 0)
if (!world.isRemote)
for (EntityPlayer player : world.playerEntities) if (EntitySelectors.CAN_AI_TARGET.apply(player) && getDistanceSq(player) < 32 * 32) {
PotionEffect corruption = player.getActivePotionEffect(ModPotions.ZACH_CORRUPTION);
float bonusDamage = corruption == null ? 0 : burstDamage * (corruption.getAmplifier() + 1);
player.attackEntityFrom(DamageSource.causeMobDamage(this).setMagicDamage().setDamageBypassesArmor(), burstDamage + bonusDamage);
}
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(burstTimer > 0);
glitter.setCanBounce(burstTimer > 0);
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;
if (burstTimer > 0)
r = (getEntityBoundingBox().maxX - getEntityBoundingBox().minX) / 2 * RandUtil.nextFloat(0.01F, 1);
else
r = 32 * RandUtil.nextFloat();
double x = r * MathHelper.cos((float) theta);
double y = (getEntityBoundingBox().maxY - getEntityBoundingBox().minY) * RandUtil.nextFloat();
double z = r * MathHelper.sin((float) theta);
build.setPositionOffset(new Vec3d(x, y, z));
build.addMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.15), 0));
});
}
});
}
if (!world.isRemote) {
List<EntityCorruptionArea> corruptionList = world.getEntitiesWithinAABB(EntityCorruptionArea.class, new AxisAlignedBB(getPosition()).grow(2));
if (corruptionList.isEmpty()) {
EntityCorruptionArea corruption = new EntityCorruptionArea(world, posX, posY, posZ);
world.spawnEntity(corruption);
}
}
}
nemezDrive.endUpdate();
}
use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable 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.utilities.client.ClientRunnable 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.utilities.client.ClientRunnable in project Wizardry by TeamWizardry.
the class TileUnicornTrail method update.
@Override
public void update() {
RandUtilSeed seed = new RandUtilSeed(getPos().toLong());
if (System.currentTimeMillis() - savedTime >= seed.nextInt(3000, 5000)) {
getWorld().setBlockToAir(getPos());
} else {
if (RandUtil.nextInt(20) == 0)
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
ParticleBuilder builder = new ParticleBuilder(50);
builder.setRender(new ResourceLocation(Wizardry.MODID, SPARKLE_BLURRED));
builder.disableMotionCalculation();
builder.setAlphaFunction(new InterpFadeInOut(0.3f, 0f));
builder.setScaleFunction(new InterpScale(0.3f, 0f));
ParticleSpawner.spawn(builder, world, new StaticInterp<>(new Vec3d(getPos()).addVector(0.5, 0.5, 0.5)), 2, 0, (aFloat, particleBuilder) -> {
particleBuilder.setPositionOffset(new Vec3d(RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5)));
particleBuilder.setMotion(new Vec3d(RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.1, 0.1), RandUtil.nextDouble(-0.1, 0.1)));
});
}
});
}
}
use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable 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