ArrayList<CrystalReceiver> getNearbyReceivers(CrystalTransmitter r, CrystalElement e) { ArrayList<CrystalReceiver> li = new ArrayList(); try { for (WorldLocation c : tiles.keySet()) { if (c.dimensionID == r.getWorld().provider.dimensionId) { CrystalNetworkTile tile = tiles.get(c); if (tile instanceof CrystalReceiver && r != tile) { CrystalReceiver te = (CrystalReceiver) tile; if (te.canConduct() && r.canTransmitTo(te)) { if (e == null || te.isConductingElement(e)) { double d = te.getDistanceSqTo(r.getX(), r.getY(), r.getZ()); // ReikaJavaLibrary.pConsole(e+": "+d+": "+te); double send = r.getSendRange(); double dist = te.getReceiveRange(); if (d <= Math.min(dist * dist, send * send)) { li.add(te); } } } } } } } catch (ConcurrentModificationException ex) { ex.printStackTrace(); ChromatiCraft.logger.logError( "CME when trying to pathfind on the crystal network. This indicates a deeper issue."); } return li; }
public boolean findSourceWithX( CrystalReceiver r, CrystalElement e, int amount, int range, boolean consume) { EntityPlayer ep = r.getPlacerUUID() != null ? r.getWorld().func_152378_a(r.getPlacerUUID()) : null; CrystalPath p = new PylonFinder(e, r, ep).findPylonWith(amount); if (p != null) { if (consume) p.transmitter.drain(e, amount); return true; } return false; }
public CrystalSource getConnectivity(CrystalElement e, CrystalReceiver r) { EntityPlayer ep = r.getPlacerUUID() != null ? r.getWorld().func_152378_a(r.getPlacerUUID()) : null; try { CrystalPath p = new PylonFinder(e, r, ep).findPylon(); return p != null && p.canTransmit() ? p.transmitter : null; } catch (ConcurrentModificationException ex) { ex.printStackTrace(); ChromatiCraft.logger.logError("CME during pathfinding!"); return null; } }
public boolean makeRequest( CrystalReceiver r, CrystalElement e, int amount, World world, int range, int maxthru) { if (amount <= 0) return false; if (this.hasFlowTo(r, e, world)) return false; EntityPlayer ep = r.getPlacerUUID() != null ? world.func_152378_a(r.getPlacerUUID()) : null; CrystalFlow p = new PylonFinder(e, r, ep).findPylon(amount, maxthru); // ReikaJavaLibrary.pConsole(p, Side.SERVER); CrystalNetworkLogger.logRequest(r, e, amount, p); if (p != null) { flows.addValue(world.provider.dimensionId, p); p.transmitter.onUsedBy(ep, e); return true; } return false; }
@Override public boolean canTransmitTo(CrystalReceiver r) { if (r instanceof TileEntityCrystalBroadcaster) { return r.getDistanceSqTo(xCoord, yCoord, zCoord) >= MIN_RANGE * MIN_RANGE; } else { return true; } }
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; }
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; }
public boolean makeRequest( CrystalReceiver r, CrystalElement e, int amount, int range, int maxthru) { return this.makeRequest(r, e, amount, r.getWorld(), range, maxthru); }
public boolean makeRequest(CrystalReceiver r, CrystalElement e, int amount, int range) { return this.makeRequest(r, e, amount, r.getWorld(), range, Integer.MAX_VALUE); }