fix: convert id array to single string in block data

This commit is contained in:
trafficlunar 2025-01-10 21:22:55 +00:00
parent 2500a00e21
commit e5ee9c81a9
7 changed files with 447 additions and 452 deletions

View file

@ -3,7 +3,7 @@ on: [deployment_status]
jobs: jobs:
notify: notify:
if: github.event.deployment_status.state == 'failure' | github.event.deployment_status.state == 'success' if: always()
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Notify on Success - name: Notify on Success

View file

@ -28,10 +28,6 @@ const data = {};
const pattern = new RegExp(nameRegex.join("|"), "g"); const pattern = new RegExp(nameRegex.join("|"), "g");
const blockName = fileName.replace(pattern, ""); const blockName = fileName.replace(pattern, "");
function getDataBlockProperty(property) {
return VERSION_DATA.blocksByName[blockName] ? VERSION_DATA.blocksByName[blockName][property] : "REPLACE_ME_REPLACE_ME_REPLACE_ME_REPLACE_ME";
}
function getVersion() { function getVersion() {
for (const key of Object.keys(versionRegex)) { for (const key of Object.keys(versionRegex)) {
if (blockName.includes(key)) { if (blockName.includes(key)) {
@ -44,7 +40,7 @@ const data = {};
data[fileName] = { data[fileName] = {
name: VERSION_DATA.blocksByName[fileName] ? VERSION_DATA.blocksByName[fileName].displayName : "REPLACE_ME_REPLACE_ME_REPLACE_ME_REPLACE_ME", name: VERSION_DATA.blocksByName[fileName] ? VERSION_DATA.blocksByName[fileName].displayName : "REPLACE_ME_REPLACE_ME_REPLACE_ME_REPLACE_ME",
version: getVersion(), version: getVersion(),
id: [getDataBlockProperty("name"), getDataBlockProperty("id")], id: VERSION_DATA.blocksByName[blockName] ? VERSION_DATA.blocksByName[blockName][property] : "REPLACE_ME_REPLACE_ME_REPLACE_ME_REPLACE_ME",
color: [color.value[0], color.value[1], color.value[2], color.value[3]], color: [color.value[0], color.value[1], color.value[2], color.value[3]],
}; };
} }

View file

@ -96,8 +96,7 @@ function OpenSchematic({ close }: DialogProps) {
if (blockId == "air") continue; if (blockId == "air") continue;
for (const name in blockData) { for (const name in blockData) {
const dataId = blockData[name].id[0]; if (blockData[name].id !== blockId) continue;
if (dataId !== blockId) continue;
const paletteProperties = paletteBlock.Properties; const paletteProperties = paletteBlock.Properties;
const dataProperties = blockData[name].properties; const dataProperties = blockData[name].properties;

View file

@ -48,7 +48,7 @@ function SaveLitematic({ close }: DialogProps) {
blocks.map((block) => { blocks.map((block) => {
const blockInfo = blockData[block.name.replace("minecraft:", "")]; const blockInfo = blockData[block.name.replace("minecraft:", "")];
const returnData: { Name: string; Properties?: Record<string, string> } = { const returnData: { Name: string; Properties?: Record<string, string> } = {
Name: `minecraft:${blockInfo.id[0]}`, Name: `minecraft:${blockInfo.id}`,
...(blockInfo.properties ? { Properties: blockInfo.properties } : {}), ...(blockInfo.properties ? { Properties: blockInfo.properties } : {}),
}; };
@ -65,7 +65,7 @@ function SaveLitematic({ close }: DialogProps) {
filledBlocks.forEach((block) => { filledBlocks.forEach((block) => {
const blockInfo = blockData[block.name.replace("minecraft:", "")]; const blockInfo = blockData[block.name.replace("minecraft:", "")];
const blockName = blockInfo ? blockInfo.id[0].toString() : block.name; const blockName = blockInfo ? blockInfo.id : block.name;
const blockId = blockStatePalette.findIndex((entry) => entry.Name === `minecraft:${blockName}`); const blockId = blockStatePalette.findIndex((entry) => entry.Name === `minecraft:${blockName}`);

View file

@ -58,7 +58,7 @@ function SaveLitematic({ close }: DialogProps) {
.map(([key, value]) => `${key}=${value}`) .map(([key, value]) => `${key}=${value}`)
.join(",")}]` .join(",")}]`
: ""; : "";
return `minecraft:${blockInfo.id[0]}${properties}`; return `minecraft:${blockInfo}${properties}`;
}) })
) )
).reduce<Record<string, nbt.Int32<number>>>((acc, blockName, index) => { ).reduce<Record<string, nbt.Int32<number>>>((acc, blockName, index) => {
@ -72,7 +72,7 @@ function SaveLitematic({ close }: DialogProps) {
filledBlocks.forEach((block, index) => { filledBlocks.forEach((block, index) => {
const blockInfo = blockData[block.name.replace("minecraft:", "")]; const blockInfo = blockData[block.name.replace("minecraft:", "")];
const blockName = blockInfo ? blockInfo.id[0].toString() : block.name; const blockName = blockInfo ? blockInfo.id : block.name;
const properties = blockInfo.properties const properties = blockInfo.properties
? `[${Object.entries(blockInfo.properties) ? `[${Object.entries(blockInfo.properties)
.map(([key, value]) => `${key}=${value}`) .map(([key, value]) => `${key}=${value}`)

File diff suppressed because it is too large Load diff

2
src/types.d.ts vendored
View file

@ -41,7 +41,7 @@ type BlockData = Record<
{ {
name: string; name: string;
version: number; version: number;
id: (string | number)[]; id: string;
color: number[]; color: number[];
fallable?: boolean; fallable?: boolean;
creative?: boolean; creative?: boolean;