move CubeIterator

This commit is contained in:
__felix__ authored and GitHub committed 2026-03-13 23:57:37 -04:00
1 parent 4d668add2a
commit 995377cac9
1 file changed
+1 -77
@@ -22,6 +22,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeHooks;
import com.brandon3055.draconicevolution.common.utils.ItemNBTHelper;
import com.gtnewhorizon.gtnhlib.geometry.CubeIterator;
import crazypants.enderio.machine.obelisk.xp.TileExperienceObelisk;
import crazypants.enderio.xp.ExperienceContainer;
@@ -350,81 +351,4 @@ public class TileDissEnchanter extends TileEntity implements ISidedInventory {
super.readFromNBT(compound);
}
public static final class CubeIterator {
public int range = 0;
// wow, it's just like electron orbitals. and the spin is the sign. how beautiful
public int n = 0;
public int l = 0;
public int m = 0;
CubeIterator(int range) {
this.range = range;
}
// maybe i could put this in next() and make it an Iterator<Boolean>?
public boolean hasNext() {
return -n < range || -l < range || -m < range;
}
public void next() {
// this shit looks like the decompile of an obfuscated assembly but i assure you it is hand written
m = -m;
if (m < 0) return;
l = -l;
if (l < 0) return;
n = -n;
if (n < 0) return;
if (l >= n || m > n) {
if (m >= l) {
if (n <= l) {
if (m > n) {
n ^= m;
m ^= n;
n ^= m;
if (l > m) {
++m;
return;
}
m = 0;
++l;
return;
}
l = 0;
m = 0;
++n;
return;
}
n ^= l;
l ^= n;
n ^= l;
return;
}
if (n < m) {
n ^= m;
m ^= n;
n ^= m;
return;
}
m ^= l;
l ^= m;
m ^= l;
return;
}
if (l > m) {
m ^= l;
l ^= m;
m ^= l;
return;
}
n ^= l;
l ^= n;
n ^= l;
return;
} // i have just found out that Java has a `when` statement, but primitive pattern matching is preview
// and the syntax sucks (case boolean b when a>6)
// i genuinely would rather have written this bytecode by bytecode but here we are
}
}