private ArrayList<CrystalReceiver> getAllColorConnectedTo( CrystalTransmitter te, CrystalElement color, boolean recursive, HashSet<WorldLocation> locs) { ArrayList<CrystalReceiver> li = this.getNearbyReceivers(te, color); if (recursive) { for (CrystalReceiver r : li) { WorldLocation loc = new WorldLocation(r.getWorld(), r.getX(), r.getY(), r.getZ()); if (!locs.contains(loc)) { locs.add(loc); if (r instanceof CrystalTransmitter) { ArrayList<CrystalReceiver> li2 = this.getAllColorConnectedTo((CrystalTransmitter) r, color, recursive, locs); for (CrystalReceiver r2 : li2) { WorldLocation loc2 = new WorldLocation(r.getWorld(), r.getX(), r.getY(), r.getZ()); if (!locs.contains(loc2)) { locs.add(loc2); li.add(r2); } } } } } } return li; }
ArrayList<CrystalTransmitter> getTransmittersTo(CrystalReceiver r, CrystalElement e) { ArrayList<CrystalTransmitter> li = new ArrayList(); for (WorldLocation c : tiles.keySet()) { if (c.dimensionID == r.getWorld().provider.dimensionId) { CrystalNetworkTile tile = tiles.get(c); if (tile instanceof CrystalTransmitter && r != tile) { CrystalTransmitter te = (CrystalTransmitter) tile; if (te.canConduct() && te.canTransmitTo(r)) { if (e == null || te.isConductingElement(e)) { double d = te.getDistanceSqTo(r.getX(), r.getY(), r.getZ()); // ReikaJavaLibrary.pConsole(e+": "+d+": "+te); double send = te.getSendRange(); double dist = r.getReceiveRange(); if (d <= Math.min(dist * dist, send * send)) { li.add(te); } } } } } } return li; }