Serialization that makes more sense

This commit is contained in:
Anuken
2020-05-08 20:22:11 -04:00
parent aab97fefc8
commit 8d5cd7b814
10 changed files with 36 additions and 22 deletions
+5 -5
View File
@@ -252,8 +252,8 @@ public abstract class SaveVersion extends SaveFileReader{
}
}
stream.writeInt(Groups.sync.count(Entityc::serialize));
for(Syncc entity : Groups.sync){
stream.writeInt(Groups.all.count(Entityc::serialize));
for(Entityc entity : Groups.all){
if(!entity.serialize()) continue;
writeChunk(stream, true, out -> {
@@ -278,9 +278,9 @@ public abstract class SaveVersion extends SaveFileReader{
for(int j = 0; j < amount; j++){
readChunk(stream, true, in -> {
byte typeid = in.readByte();
Syncc sync = (Syncc)EntityMapping.map(typeid).get();
sync.read(Reads.get(in));
sync.add();
Entityc entity = (Entityc)EntityMapping.map(typeid).get();
entity.read(Reads.get(in));
entity.add();
});
}
}
+9
View File
@@ -259,6 +259,15 @@ public class TypeIO{
return id == -1 ? null : content.item(id);
}
public static void writeWeather(Writes write, Weather item){
write.s(item == null ? -1 : item.id);
}
public static Weather readWeather(Reads read){
short id = read.s();
return id == -1 ? null : content.getByID(ContentType.weather, id);
}
public static void writeString(Writes write, String string){
if(string != null){
byte[] bytes = string.getBytes(charset);