void turnOnBulletReceiver() throws IOException { Global.log("Turning on bullet receiver..."); while (true) { if (isDisposed()) throw new IOException("Client game disposed"); Global.log("Connecting to port " + (Global.bulletPort()) + "..."); try { bulletStream = new ClientByteStream(ip, Global.bulletPort(), Bullet.bufferSize()); break; } catch (IOException ex) { } } Global.log("Connected!"); timers.add( new FixedTimer( new FixedTask() { public boolean fixedRate() { return true; } public float FPS() { return Global.ReceiveFPS * 20; } public void run() { byte[] data = null; try { data = bulletStream.read(); } catch (IOException ex) { System.err.println("Bullet receiver error: " + ex); Global.onException(); stop(); return; } if (data == null) return; Bullet toSpawn = Bullet.fromBytes(data); Ship find = cShip.get(toSpawn.getFill()); if (find == null) { for (Ship s : turrets) { if (s.fill.equals(toSpawn.getFill())) { find = s; break; } } } if (find == null) return; find.getBulletSet().add(toSpawn); } })); }