MCPcopy Index your code
hub / github.com/GregTech6/gregtech6 / line

Method line

src/main/java/gregapi/util/WD.java:801–909  ·  view source on GitHub ↗
(final Vec3 aStart, final Vec3 aEnd)

Source from the content-addressed store, hash-verified

799 }
800
801 public static List<ChunkCoordinates> line(final Vec3 aStart, final Vec3 aEnd) {
802 List<ChunkCoordinates> rList = new ArrayListNoNulls<>();
803 if (Double.isNaN(aStart.xCoord) || Double.isNaN(aStart.yCoord) || Double.isNaN(aStart.zCoord) || Double.isNaN(aEnd.xCoord) || Double.isNaN(aEnd.yCoord) || Double.isNaN(aEnd.zCoord)) return rList;
804 Vec3 tPoint = Vec3.createVectorHelper(aStart.xCoord, aStart.yCoord, aStart.zCoord);
805
806 int sx = UT.Code.roundDown(tPoint.xCoord);
807 int sy = UT.Code.roundDown(tPoint.yCoord);
808 int sz = UT.Code.roundDown(tPoint.zCoord);
809 int ex = UT.Code.roundDown(aEnd.xCoord);
810 int ey = UT.Code.roundDown(aEnd.yCoord);
811 int ez = UT.Code.roundDown(aEnd.zCoord);
812
813 rList.add(new ChunkCoordinates(sx, sy, sz));
814
815 int maxAttempts = 2000; // Just to prevent accidental infinite loops
816
817 while (maxAttempts-- >= 0) {
818 if (Double.isNaN(tPoint.xCoord) || Double.isNaN(tPoint.yCoord) || Double.isNaN(tPoint.zCoord)) return rList;
819 if (sx == ex && sy == ey && sz == ez) return rList;
820
821 boolean performx = true;
822 boolean performy = true;
823 boolean performz = true;
824
825 double nx = 999.0D;
826 double ny = 999.0D;
827 double nz = 999.0D;
828
829 double ndx = 999.0D;
830 double ndy = 999.0D;
831 double ndz = 999.0D;
832
833 double distx = aEnd.xCoord - tPoint.xCoord;
834 double disty = aEnd.yCoord - tPoint.yCoord;
835 double distz = aEnd.zCoord - tPoint.zCoord;
836
837 if (ex > sx) {
838 nx = (double) sx + 1.0D;
839 } else if (ex < sx) {
840 nx = (double) sx + 0.0D;
841 } else {
842 performx = false;
843 }
844
845 if (ey > sy) {
846 ny = (double) sy + 1.0D;
847 } else if (ey < sy) {
848 ny = (double) sy + 0.0D;
849 } else {
850 performy = false;
851 }
852
853 if (ez > sz) {
854 nz = (double) sz + 1.0D;
855 } else if (ez < sz) {
856 nz = (double) sz + 0.0D;
857 } else {
858 performz = false;

Callers 1

shootMethod · 0.95

Calls 2

addMethod · 0.95
roundDownMethod · 0.80

Tested by

no test coverage detected