minor block fab improvements
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-04-26 11:18:35 -04:00
parent 69a5e07818
commit 42e6e1aae8
4 changed files with 14 additions and 4 deletions

BIN
assets/Data/fab/test.block Normal file

Binary file not shown.

View File

@ -1541,6 +1541,7 @@ Block area selection
(04/26/2025) (04/26/2025)
Exporting block prefabs to compressed files Exporting block prefabs to compressed files
Minor block fab improvements

View File

@ -114,7 +114,7 @@ public class ClientBlockSelection {
); );
BlockFab fab = BlockFab.create(dimensions, types, metadata); 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); fab.save(exportLoc);
} }

View File

@ -16,11 +16,20 @@ import electrosphere.util.FileUtils;
*/ */
public class BlockFab { public class BlockFab {
/**
* File version format
*/
public static final int FILE_VER = 1;
/** /**
* Size of the header for a block fab file * 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 * 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 * Dimensions of the block fab
@ -63,6 +72,7 @@ public class BlockFab {
ByteBuffer buff = ByteBuffer.allocate(HEADER_SIZE + blockCount * BlockChunkData.BYTES_PER_BLOCK); ByteBuffer buff = ByteBuffer.allocate(HEADER_SIZE + blockCount * BlockChunkData.BYTES_PER_BLOCK);
IntBuffer intView = buff.asIntBuffer(); IntBuffer intView = buff.asIntBuffer();
intView.put(FILE_VER);
intView.put(dimensions.x); intView.put(dimensions.x);
intView.put(dimensions.y); intView.put(dimensions.y);
intView.put(dimensions.z); intView.put(dimensions.z);
@ -74,9 +84,8 @@ public class BlockFab {
shortView.put(metadata); shortView.put(metadata);
shortView.flip(); shortView.flip();
File exportLoc = new File("./struct.block");
try { try {
FileUtils.writeBufferToCompressedFile(exportLoc, buff); FileUtils.writeBufferToCompressedFile(file, buff);
} catch (IOException e) { } catch (IOException e) {
throw new Error("Failed to export selected blocks to a file!"); throw new Error("Failed to export selected blocks to a file!");
} }