use of net.minecraft.world.level.saveddata.maps.MapIndex in project SpongeCommon by SpongePowered.
the class SpongeMapStorage method allMapInfos.
@Override
public Collection<MapInfo> allMapInfos() {
final Set<MapInfo> mapInfos = new HashSet<>();
final ServerLevel defaultWorld = (ServerLevel) Sponge.server().worldManager().defaultWorld();
final int highestId = ((MapIdTrackerBridge) defaultWorld.getDataStorage().computeIfAbsent(MapIndex::new, Constants.Map.MAP_INDEX_DATA_NAME)).bridge$getHighestMapId().orElse(-1);
for (int i = 0; i <= highestId; i++) {
@Nullable final MapInfo mapInfo = (MapInfo) defaultWorld.getMapData(Constants.Map.MAP_PREFIX + i);
if (mapInfo == null) {
SpongeCommon.logger().warn("Missing map with id: " + i);
continue;
}
this.addMapInfo(mapInfo);
mapInfos.add(mapInfo);
}
return mapInfos;
}
Aggregations