Save version chunks changed to 4-byte lengths

This commit is contained in:
Anuken
2025-09-12 14:42:22 -04:00
parent 5f58adb764
commit 729f18726f
19 changed files with 311 additions and 150 deletions

View File

@@ -593,11 +593,13 @@ public class Schematics implements Loadable{
if(total > 128 * 128) throw new IOException("Invalid schematic: Too many blocks.");
Reads read = new Reads(stream);
Seq<Stile> tiles = new Seq<>(total);
for(int i = 0; i < total; i++){
Block block = blocks.get(stream.readByte());
int position = stream.readInt();
Object config = ver == 0 ? mapConfig(block, stream.readInt(), position) : TypeIO.readObject(Reads.get(stream), false, mapper);
Object config = ver == 0 ? mapConfig(block, stream.readInt(), position) : TypeIO.readObject(read, false, mapper);
byte rotation = stream.readByte();
if(block != Blocks.air){
tiles.add(new Stile(block, Point2.x(position), Point2.y(position), config, rotation));
@@ -619,6 +621,7 @@ public class Schematics implements Loadable{
output.write(version);
try(DataOutputStream stream = new DataOutputStream(new DeflaterOutputStream(output))){
Writes write = new Writes(stream);
stream.writeShort(schematic.width);
stream.writeShort(schematic.height);
@@ -655,7 +658,7 @@ public class Schematics implements Loadable{
for(Stile tile : schematic.tiles){
stream.writeByte(blocks.orderedItems().indexOf(tile.block));
stream.writeInt(Point2.pack(tile.x, tile.y));
TypeIO.writeObject(Writes.get(stream), tile.config);
TypeIO.writeObject(write, tile.config);
stream.writeByte(tile.rotation);
}
}