From 9a8c74071a3434be86b10e5e9acc3cb055ab32bf Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Sun, 5 Jan 2025 21:56:20 +0000 Subject: [PATCH] feat: block properties for .schem files warning: .schem files are extremely buggy --- src/components/dialogs/SaveSchem.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/dialogs/SaveSchem.tsx b/src/components/dialogs/SaveSchem.tsx index e5ed6b3..4125a02 100644 --- a/src/components/dialogs/SaveSchem.tsx +++ b/src/components/dialogs/SaveSchem.tsx @@ -53,8 +53,12 @@ function SaveLitematic({ close }: DialogProps) { new Set( filledBlocks.map((block) => { const blockInfo = blockData[block.name.replace("minecraft:", "")]; - // todo: add block properties - return `minecraft:${blockInfo.id[0]}`; + const properties = blockInfo.properties + ? `[${Object.entries(blockInfo.properties) + .map(([key, value]) => `${key}=${value}`) + .join(",")}]` + : ""; + return `minecraft:${blockInfo.id[0]}${properties}`; }) ) ).reduce>>((acc, blockName, index) => { @@ -69,7 +73,12 @@ function SaveLitematic({ close }: DialogProps) { filledBlocks.forEach((block, index) => { const blockInfo = blockData[block.name.replace("minecraft:", "")]; const blockName = blockInfo ? blockInfo.id[0].toString() : block.name; - const blockId = blockPallete[`minecraft:${blockName}`]; + const properties = blockInfo.properties + ? `[${Object.entries(blockInfo.properties) + .map(([key, value]) => `${key}=${value}`) + .join(",")}]` + : ""; + const blockId = blockPallete[`minecraft:${blockName}${properties}`]; blockPlaceData[index] = parseInt(blockId.toString()); });