minor block fab improvements
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
69a5e07818
commit
42e6e1aae8
BIN
assets/Data/fab/test.block
Normal file
BIN
assets/Data/fab/test.block
Normal file
Binary file not shown.
@ -1541,6 +1541,7 @@ Block area selection
|
||||
|
||||
(04/26/2025)
|
||||
Exporting block prefabs to compressed files
|
||||
Minor block fab improvements
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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!");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user