use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable in project Wizardry by TeamWizardry.
the class PacketExplode 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() {
LibParticles.EXPLODE(world, pos, color1, color2, strengthSideways, strengthUpwards, amount, lifeTime, lifeTimeRange, bounce);
}
});
}
use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable in project Wizardry by TeamWizardry.
the class TileManaInteracter method suckManaFrom.
public boolean suckManaFrom(TileManaInteracter interacterFrom, SuckRule suckRule) {
if (getWizardryCap() == null || interacterFrom.getWizardryCap() == null)
return false;
if (!isAllowOutsideSucking() && interacterFrom.isAllowOutsideSucking())
return false;
if (!suckRule.condition.test(this, interacterFrom))
return false;
CapManager thisManager = new CapManager(getWizardryCap());
CapManager theirManager = new CapManager(interacterFrom.getWizardryCap());
if (thisManager.isManaFull())
return false;
if (theirManager.isManaEmpty())
return false;
if (suckRule.equalize && Math.abs(thisManager.getMana() - theirManager.getMana()) <= suckRule.idealAmount)
return false;
Vec3d thisPos = new Vec3d(getPos()).addVector(0.5, 0.5, 0.5);
Vec3d theirPos = new Vec3d(interacterFrom.getPos()).addVector(0.5, 0.5, 0.5);
// DEBUG
// ParticleBuilder helix = new ParticleBuilder(200);
// helix.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
// helix.setAlphaFunction(new InterpFadeInOut(0.1f, 0.1f));
// ParticleSpawner.spawn(helix, world, new StaticInterp<>(thisPos), 1, 0, (someFloat, particleBuilder) -> {
// particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0xFF0000), RandUtil.nextInt(50, 200)));
// particleBuilder.setScale(RandUtil.nextFloat(0.3f, 0.8f));
// particleBuilder.disableRandom();
// particleBuilder.setPositionFunction(new InterpLine(Vec3d.ZERO, theirPos.subtract(thisPos)));
// particleBuilder.setLifetime(RandUtil.nextInt(50, 60));
// });
double ratio = theirManager.getMana() / thisManager.getMana();
if (suckRule.equalize && Double.isFinite(ratio) && ratio <= 1.2)
return false;
if (getCachedDistanceSq(interacterFrom) > ConfigValues.networkLinkDistance * ConfigValues.networkLinkDistance)
return false;
if (!suckRule.ignoreTrace) {
Vec3d thisSub = theirPos.subtract(thisPos.add(getOffset()));
Vec3d thisNorm = thisSub.normalize();
RayTraceResult trace = new RayTrace(world, thisNorm, thisPos.add(getOffset() == Vec3d.ZERO ? thisNorm : getOffset()), ConfigValues.networkLinkDistance * ConfigValues.networkLinkDistance).setSkipEntities(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
if (!trace.getBlockPos().equals(interacterFrom.getPos()))
return false;
}
double amount = interacterFrom.drainMana(suckRule.idealAmount);
if (amount <= 0)
return false;
thisManager.addMana(amount);
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
ParticleBuilder helix = new ParticleBuilder(200);
helix.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
helix.setAlphaFunction(new InterpFadeInOut(0.1f, 0.1f));
ParticleSpawner.spawn(helix, world, new StaticInterp<>(new Vec3d(interacterFrom.getPos()).addVector(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 true;
}
use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable in project Wizardry by TeamWizardry.
the class Arena method tick.
public void tick(long timeMillis) {
if (timeMillis % 500 == 0)
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
ParticleBuilder glitter = new ParticleBuilder(10);
glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
glitter.setAlphaFunction(new InterpFadeInOut(0.3f, 0.3f));
glitter.setCollision(true);
glitter.enableMotionCalculation();
ParticleSpawner.spawn(glitter, getWorld(), new InterpCircle(new Vec3d(getCenter()).addVector(0.5, getHeight(), 0.5), new Vec3d(0, 1, 0), (float) getRadius(), 1, RandUtil.nextFloat()), 10, RandUtil.nextInt(10), (aFloat, particleBuilder) -> {
particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(100, 255)));
particleBuilder.setScale(RandUtil.nextFloat(0.5f, 1));
particleBuilder.addMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01)));
particleBuilder.setLifetime(RandUtil.nextInt(30, 60));
});
glitter.disableMotionCalculation();
ParticleSpawner.spawn(glitter, getWorld(), new InterpCircle(new Vec3d(getCenter()).addVector(0.5, 0, 0.5), new Vec3d(0, 1, 0), (float) getRadius(), 1, RandUtil.nextFloat()), 10, RandUtil.nextInt(10), (aFloat, particleBuilder) -> {
particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(100, 255)));
particleBuilder.setScale(RandUtil.nextFloat(0.5f, 1));
particleBuilder.addMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(0.01, 0.02), RandUtil.nextDouble(-0.01, 0.01)));
particleBuilder.setLifetime(RandUtil.nextInt(30, 60));
});
}
});
}
use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable in project Wizardry by TeamWizardry.
the class IExplodable method explode.
default void explode(Entity entityIn) {
if (potions.isEmpty()) {
potions.add(1);
potions.add(3);
potions.add(5);
potions.add(8);
potions.add(11);
potions.add(12);
potions.add(21);
}
Random rand = new Random();
int range = 5;
List<EntityLivingBase> entitys = entityIn.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(entityIn.posX - range, entityIn.posY - range, entityIn.posZ - range, entityIn.posX + range, entityIn.posY + range, entityIn.posZ + range));
for (EntityLivingBase e : entitys) e.addPotionEffect(new PotionEffect(Potion.getPotionById(potions.get(rand.nextInt(potions.size()))), rand.nextInt(30) * 20, rand.nextInt(2) + 1));
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
LibParticles.FIZZING_EXPLOSION(entityIn.world, entityIn.getPositionVector());
}
});
}
use of com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable in project Wizardry by TeamWizardry.
the class EntityBomb method onImpact.
@Override
protected void onImpact(RayTraceResult result) {
if (getThrower() == null)
return;
if (result.entityHit != null && getThrower() != null && getThrower().getEntityId() == result.entityHit.getEntityId())
return;
int type = getDataManager().get(DATA_BOMB_TYPE);
if (type == 0)
PosUtils.boom(getEntityWorld(), getPositionVector(), null, 10, true);
else
PosUtils.boom(getEntityWorld(), getPositionVector(), null, 10, false);
ClientRunnable.run(new ClientRunnable() {
@SideOnly(Side.CLIENT)
@Override
public void runIfClient() {
Color color, color2;
if (type == 1) {
color = Color.CYAN;
color2 = Color.BLUE;
} else {
color = Color.RED;
color2 = Color.ORANGE;
}
ParticleBuilder glitter = new ParticleBuilder(10);
glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
glitter.setCollision(true);
glitter.setAcceleration(new Vec3d(0, RandUtil.nextDouble(-0.03, -0.04), 0));
glitter.setCanBounce(true);
glitter.enableMotionCalculation();
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 500, 0, (i, build) -> {
build.setMotion(Vec3d.ZERO);
build.setLifetime(RandUtil.nextInt(50, 100));
build.setAlphaFunction(new InterpFadeInOut(RandUtil.nextFloat(), RandUtil.nextFloat()));
build.setScale(RandUtil.nextFloat(0.2f, 1));
if (type == 0) {
double radius = RandUtil.nextDouble(20, 40);
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(x, RandUtil.nextDouble(-radius, radius), z));
build.addMotion(build.getPositionOffset().scale(-1.0 / RandUtil.nextDouble(10, 30)));
} else {
double radius = RandUtil.nextDouble(1, 3);
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.addMotion(new Vec3d(x, RandUtil.nextDouble(-radius, radius), z));
}
if (RandUtil.nextBoolean())
build.setColor(color);
else
build.setColor(color2);
});
}
});
setDead();
}
Aggregations