private void processNetwork() {
        if (!network.isValid())
            parent.fail("Network lost");

        while (network.hasInboundPackets()) {
            Packet packet = network.nextInboundPacket();
            if (packet instanceof WindowPacket) {
                WindowPacket spp = (WindowPacket) packet;
                temp.setLocation(spp.x, spp.y);
                World.worldCoordToScreenCoord(temp, temp);
                System.err.println("Force viewport " + spp.x + ":" + spp.y + " " + temp);
                parent.setViewportLocation(temp);
            } else if (packet instanceof WorldRegionPacket) {
                WorldRegionPacket wrp = (WorldRegionPacket) packet;
                int entries = wrp.entries();
                if (entries > 0) {
                    int[] locations = new int[entries];
                    byte[] tiles = new byte[entries];
                    wrp.readUpdates(locations, tiles);
                    world.writeTiles(locations, tiles);
                }
            } else if (packet instanceof WorldUpdatesPacket) {
                WorldUpdatesPacket wup = (WorldUpdatesPacket) packet;
                world.writeTiles(wup.locations, wup.tiles);
            } else if (packet instanceof EntitiesPacket) {
                EntitiesPacket ep = (EntitiesPacket) packet;
                world.updateEntities(ep.data, ep.checkpoint);
            } else if (packet instanceof PlayerUpdatePacket) {
                PlayerUpdatePacket pup = (PlayerUpdatePacket) packet;
                values.read(pup.data);

                stone = values.get(Constants.V_PLAYER_STONES);
                iron = values.get(Constants.V_PLAYER_IRON);
                gold = values.get(Constants.V_PLAYER_GOLD);
                playerId = values.get(Constants.V_PLAYER_ID);
            } else
                throw new RuntimeException("Unknown packet: " + packet.packetId());
        }

        World.screenCoordToWorldCoord(parent.getViewportLocation(), temp);
        WindowPacket wp = new WindowPacket((int) temp.getX(), (int) temp.getY());
        network.send(wp);
    }