use of gnu.trove.map.hash.TObjectByteHashMap in project BuildCraft by BuildCraft.
the class RetroGenData method writeToNBT.
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
Set<String> allNames = new HashSet<>();
for (Set<String> used : gennedChunks.values()) {
allNames.addAll(used);
}
TObjectByteHashMap<String> map = new TObjectByteHashMap<>();
List<String> list = new ArrayList<>(allNames);
NBTTagList registry = new NBTTagList();
for (int i = 0; i < list.size(); i++) {
String name = list.get(i);
map.put(name, (byte) i);
registry.appendTag(new NBTTagString(name));
}
nbt.setTag("registry", registry);
NBTTagCompound data = new NBTTagCompound();
for (Entry<ChunkPos, Set<String>> entry : gennedChunks.entrySet()) {
String key = serializeChunkPos(entry.getKey());
Set<String> names = entry.getValue();
TByteArrayList ids = new TByteArrayList();
for (String s : names) {
byte b = map.get(s);
ids.add(b);
}
data.setByteArray(key, ids.toArray());
}
nbt.setTag("data", data);
return nbt;
}
Aggregations