Serialization that makes more sense
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user