use of org.joml.Vector3d in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MixinTileEntity method getDistanceSq.
/**
* This is easier to have as an overwrite because there's less laggy hackery to be done then :P
*
* @author DaPorkchop_
*/
@Overwrite
public double getDistanceSq(double x, double y, double z) {
World tileWorld = this.world;
double d0 = (double) this.pos.getX() + 0.5D - x;
double d1 = (double) this.pos.getY() + 0.5D - y;
double d2 = (double) this.pos.getZ() + 0.5D - z;
double toReturn = d0 * d0 + d1 * d1 + d2 * d2;
if (tileWorld != null) {
// Assume on Ship
if (tileWorld.isRemote && toReturn > 9999999D) {
BlockPos pos = this.pos;
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, pos);
if (physicsObject.isPresent()) {
Vector3d tilePos = new Vector3d(pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5);
physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(tilePos, TransformType.SUBSPACE_TO_GLOBAL);
tilePos.x -= x;
tilePos.y -= y;
tilePos.z -= z;
return tilePos.lengthSquared();
}
}
}
return toReturn;
}
use of org.joml.Vector3d in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MixinChunkPos method getDistanceSq.
/**
* This is easier to have as an overwrite because there's less laggy hackery to be done then :P
*
* @author DaPorkchop_
*/
@Overwrite
public double getDistanceSq(Entity entityIn) {
double d0 = this.x * 16 + 8;
double d1 = this.z * 16 + 8;
double d2 = d0 - entityIn.posX;
double d3 = d1 - entityIn.posZ;
double vanilla = d2 * d2 + d3 * d3;
// A big number
if (vanilla < TOO_MUCH_DISTANCE) {
return vanilla;
}
try {
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(entityIn.world, new BlockPos(d0, 127, d1));
if (physicsObject.isPresent()) {
Vector3d entityPosInLocal = new Vector3d(entityIn.posX, entityIn.posY, entityIn.posZ);
// RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform,
// entityPosInLocal);
physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(entityPosInLocal, TransformType.GLOBAL_TO_SUBSPACE);
entityPosInLocal.sub(d0, entityPosInLocal.y, d1);
return entityPosInLocal.lengthSquared();
}
} catch (Exception e) {
e.printStackTrace();
}
return vanilla;
}
use of org.joml.Vector3d in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MixinEntity method getDistanceSq.
/**
* This is easier to have as an overwrite because there's less laggy hackery to be done then :P
*
* @author DaPorkchop_
*/
@Overwrite
public double getDistanceSq(BlockPos pos) {
double vanilla = pos.getDistance((int) posX, (int) posY, (int) posZ);
if (vanilla < 64.0D) {
return vanilla;
} else {
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, pos);
if (physicsObject.isPresent()) {
Vector3d posVec = new Vector3d(pos.getX() + .5D, pos.getY() + .5D, pos.getZ() + .5D);
physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(posVec, TransformType.SUBSPACE_TO_GLOBAL);
posVec.x -= this.posX;
posVec.y -= this.posY;
posVec.z -= this.posZ;
if (vanilla > posVec.lengthSquared()) {
return posVec.lengthSquared();
}
}
}
return vanilla;
}
use of org.joml.Vector3d in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MixinEntity method runningParticlesFirstFloor.
@Redirect(method = "createRunningParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;floor(D)I", ordinal = 0))
private int runningParticlesFirstFloor(double d) {
final ShipData lastTouchedShip = ValkyrienUtils.getLastShipTouchedByEntity(thisAsEntity);
if (lastTouchedShip == null) {
searchVector = null;
return MathHelper.floor(d);
} else {
searchVector = new Vector3d(this.posX, this.posY - 0.20000000298023224D, this.posZ);
lastTouchedShip.getShipTransform().transformPosition(searchVector, TransformType.GLOBAL_TO_SUBSPACE);
return MathHelper.floor(searchVector.x);
}
}
use of org.joml.Vector3d in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MixinEntity method getDistanceSq.
/**
* This is easier to have as an overwrite because there's less laggy hackery to be done then :P
*
* @author DaPorkchop_
*/
@Overwrite
public double getDistanceSq(double x, double y, double z) {
double d0 = this.posX - x;
double d1 = this.posY - y;
double d2 = this.posZ - z;
double vanilla = d0 * d0 + d1 * d1 + d2 * d2;
if (vanilla < 64.0D) {
return vanilla;
} else {
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, new BlockPos(x, y, z));
if (physicsObject.isPresent()) {
Vector3d posVec = new Vector3d(x, y, z);
physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(posVec, TransformType.SUBSPACE_TO_GLOBAL);
posVec.x -= this.posX;
posVec.y -= this.posY;
posVec.z -= this.posZ;
if (vanilla > posVec.lengthSquared()) {
return posVec.lengthSquared();
}
}
}
return vanilla;
}
Aggregations