diff --git a/assets/Data/fab/test.block b/assets/Data/fab/test.block new file mode 100644 index 00000000..9954869c Binary files /dev/null and b/assets/Data/fab/test.block differ diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index fbd681d8..1198a5cc 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1541,6 +1541,7 @@ Block area selection (04/26/2025) Exporting block prefabs to compressed files +Minor block fab improvements diff --git a/src/main/java/electrosphere/client/block/ClientBlockSelection.java b/src/main/java/electrosphere/client/block/ClientBlockSelection.java index 65ef71ad..8c541749 100644 --- a/src/main/java/electrosphere/client/block/ClientBlockSelection.java +++ b/src/main/java/electrosphere/client/block/ClientBlockSelection.java @@ -114,7 +114,7 @@ public class ClientBlockSelection { ); BlockFab fab = BlockFab.create(dimensions, types, metadata); - File exportLoc = new File("./struct.block"); + File exportLoc = new File("./assets/Data/fab/struct.block"); fab.save(exportLoc); } diff --git a/src/main/java/electrosphere/game/data/block/BlockFab.java b/src/main/java/electrosphere/game/data/block/BlockFab.java index 0eb5c94e..62f8e59d 100644 --- a/src/main/java/electrosphere/game/data/block/BlockFab.java +++ b/src/main/java/electrosphere/game/data/block/BlockFab.java @@ -16,11 +16,20 @@ import electrosphere.util.FileUtils; */ public class BlockFab { + /** + * File version format + */ + public static final int FILE_VER = 1; + /** * Size of the header for a block fab file + * 1 * 4 for integer ID of the version of this fab file * 3 * 4 for the dimensions at the front of the file */ - public static final int HEADER_SIZE = 3 * 4; + public static final int HEADER_SIZE = + 1 * 4 + + 3 * 4 + ; /** * Dimensions of the block fab @@ -63,6 +72,7 @@ public class BlockFab { ByteBuffer buff = ByteBuffer.allocate(HEADER_SIZE + blockCount * BlockChunkData.BYTES_PER_BLOCK); IntBuffer intView = buff.asIntBuffer(); + intView.put(FILE_VER); intView.put(dimensions.x); intView.put(dimensions.y); intView.put(dimensions.z); @@ -74,9 +84,8 @@ public class BlockFab { shortView.put(metadata); shortView.flip(); - File exportLoc = new File("./struct.block"); try { - FileUtils.writeBufferToCompressedFile(exportLoc, buff); + FileUtils.writeBufferToCompressedFile(file, buff); } catch (IOException e) { throw new Error("Failed to export selected blocks to a file!"); }