use of micdoodle8.mods.galacticraft.core.tile.TileEntityTelemetry in project Galacticraft by micdoodle8.
the class TileEntityTelemetry method getNearest.
public static TileEntityTelemetry getNearest(TileEntity te) {
if (te == null) {
return null;
}
BlockVec3 target = new BlockVec3(te);
int distSq = 1025;
BlockVec3Dim nearest = null;
int dim = GCCoreUtil.getDimensionID(te.getWorld());
for (BlockVec3Dim telemeter : loadedList) {
if (telemeter.dim != dim) {
continue;
}
int dist = telemeter.distanceSquared(target);
if (dist < distSq) {
distSq = dist;
nearest = telemeter;
}
}
if (nearest == null) {
return null;
}
TileEntity result = te.getWorld().getTileEntity(new BlockPos(nearest.x, nearest.y, nearest.z));
if (result instanceof TileEntityTelemetry) {
return (TileEntityTelemetry) result;
}
return null;
}
Aggregations