use of net.katsstuff.mirror.data.MutableVector3 in project Solar by ArekkuusuJerii.
the class EntityEyeOfSchrodinger method onLivingUpdate.
@Override
public void onLivingUpdate() {
super.onLivingUpdate();
this.onGround = false;
this.isJumping = false;
this.onGroundSpeedFactor = 0;
this.prevOnGroundSpeedFactor = 0;
// Spawn Particles
if (world.isRemote) {
int rgb = hasTargetedEntity() ? RED : BLUE;
FXUtil.spawnTunneling(world, Vector3.apply(posX, posY + 0.25D, posZ), Vector3.Zero(), 10, 1.5F, rgb, GlowTexture.GLOW);
Entity entity = getTargetedEntity();
if (entity != null) {
MutableVector3 speed = Vector3.apply(posX, posY + 0.25D, posZ).asMutable().subtract(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ).multiply(-0.1D);
if (speed.x() > 0.15D || speed.x() < -0.15D)
speed.setX(0.15);
if (speed.y() > 0.15D || speed.y() < -0.15D)
speed.setY(0.15);
if (speed.z() > 0.15D || speed.z() < -0.15D)
speed.setZ(0.15);
FXUtil.spawnSquared(world, Vector3.apply(posX, posY + 0.25D, posZ), speed.asImmutable(), 10, 4F, RED);
}
}
}
use of net.katsstuff.mirror.data.MutableVector3 in project Solar by ArekkuusuJerii.
the class ParticleVolt method calculateBolts.
private void calculateBolts() {
// TODO: Maybe use textures instead of raw gl lines?
ProfilerHelper.begin("[Particle Bolt] Calculating Bolts");
List<VoltSegment> branched = Lists.newArrayList();
for (int i = 0; i < generations; i++) {
List<VoltSegment> temp = Lists.newArrayList();
for (VoltSegment segment : segments) {
Vector3 from = segment.from;
Vector3 to = segment.to;
MutableVector3 mid = average(from, to).asMutable();
Vector3 midOffset = to.subtract(from);
mid = mid.add(midOffset.normalize().cross(Vector3.One()).multiply(Vector3.rotateRandom().multiply(offset)));
if (branch && rand.nextDouble() > 0.6D) {
MutableVector3 direction = mid.subtract(from);
float xAngle = (25.0F + 12.5F * rand.nextFloat()) * (rand.nextBoolean() ? 1 : -1);
float zAngle = (25.0F + 12.5F * rand.nextFloat()) * (rand.nextBoolean() ? 1 : -1);
Quat x = Quat.fromAxisAngle(Vector3.Forward(), xAngle);
Quat z = Quat.fromAxisAngle(Vector3.Right(), zAngle);
Vector3 splitEnd = direction.rotate(x.multiply(z)).multiply(0.7D).add(mid).asImmutable();
VoltSegment sub = new VoltSegment(mid.asImmutable(), splitEnd);
sub.alpha = segment.alpha;
temp.add(sub);
}
VoltSegment one = new VoltSegment(from, mid.asImmutable());
VoltSegment two = new VoltSegment(mid.asImmutable(), to);
if (fade) {
one.alpha = segment.alpha * 0.5F;
two.alpha = segment.alpha;
}
temp.add(one);
temp.add(two);
if (branched.isEmpty() || branched.contains(segment)) {
branched.add(two);
}
}
segments = temp;
offset /= 2;
}
ProfilerHelper.end();
}
Aggregations