private void checkResources() {
        int level = 0;
        int needed = 0;
        int[] levels;
        int[] resourcesInLevels;
        Resource resource = null;
        ResourceType resourceType = null;

        for (int i = 0; i < resourceTypes.size(); i++) {
            resourceType = resourceTypes.get(i);
            levels = resourceType.getLevels();
            resourcesInLevels = new int[5];

            try {
                for (String key : resources.keySet()) {
                    resource = (Resource) resources.get(key);
                    if (resource.getResourceType() == resourceType) {
                        level = registry.getBlockManager().getLevelByY(resource.getMapY());
                        if (level >= 0 && level < levels.length) {
                            resourcesInLevels[level]++;
                        }
                    }
                }
            } catch (ConcurrentModificationException concEx) {
                //another thread was trying to modify resources while iterating
                //we'll continue and the new item can be grabbed on the next update
            }

            for (int x = 0; x < 5; x++) {
                needed = levels[x] - resourcesInLevels[x];
                if (needed > 0) {
                    spawnResources(resourceType, needed, x);
                }
            }
        }
    }