Faster + synced Fog of war

This commit is contained in:
Anuken
2022-02-18 13:17:02 -05:00
parent 027d037233
commit 396afb5144
9 changed files with 380 additions and 124 deletions
@@ -203,8 +203,15 @@ public abstract class SaveFileReader{
public interface CustomChunk{
void write(DataOutput stream) throws IOException;
void read(DataInput stream) throws IOException;
/** @return whether this chunk is enabled at all */
default boolean shouldWrite(){
return true;
}
/** @return whether this chunk should be written to connecting clients (default true) */
default boolean writeNet(){
return true;
}
}
}
+3 -3
View File
@@ -84,11 +84,11 @@ public abstract class SaveVersion extends SaveFileReader{
region("content", stream, this::writeContentHeader);
region("map", stream, this::writeMap);
region("entities", stream, this::writeEntities);
region("custom", stream, this::writeCustomChunks);
region("custom", stream, s -> writeCustomChunks(s, false));
}
public void writeCustomChunks(DataOutput stream) throws IOException{
var chunks = customChunks.orderedKeys().select(s -> customChunks.get(s).shouldWrite());
public void writeCustomChunks(DataOutput stream, boolean net) throws IOException{
var chunks = customChunks.orderedKeys().select(s -> customChunks.get(s).shouldWrite() && (!net || customChunks.get(s).writeNet()));
stream.writeInt(chunks.size);
for(var chunkName : chunks){
var chunk = customChunks.get(chunkName);