From b568ca2972262710425eb1b019ef6d9fff285247 Mon Sep 17 00:00:00 2001 From: JadlionHD <48410066+JadlionHD@users.noreply.github.com> Date: Wed, 27 Dec 2023 16:46:09 +0700 Subject: [PATCH] fix invalid buffer size when writing items --- src/structures/ItemsDat.ts | 2 +- test/items-builder-v16/index.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/structures/ItemsDat.ts b/src/structures/ItemsDat.ts index 0a73006..24d0bf1 100644 --- a/src/structures/ItemsDat.ts +++ b/src/structures/ItemsDat.ts @@ -35,7 +35,7 @@ class ItemsDat { * @param items An array of items */ private getWriteSize(items: ItemDefinition[]) { - let size = 194 * items.length; + let size = 196 * items.length; // get sizes for the string for (const item of items) { const keys = Object.keys(item); diff --git a/test/items-builder-v16/index.js b/test/items-builder-v16/index.js index f9ddda6..b2737d2 100644 --- a/test/items-builder-v16/index.js +++ b/test/items-builder-v16/index.js @@ -11,4 +11,7 @@ const item = new ItemsDat(file); decoded.items.forEach((i) => { i.itemRenderer.length ? console.log(i) : undefined; }); + + const encoded = await item.encode(decoded); + console.log({ encoded }); })();