Skip to content

Commit

Permalink
feat: items.dat v19
Browse files Browse the repository at this point in the history
  • Loading branch information
JadlionHD committed Nov 14, 2024
1 parent fd59234 commit f87643d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/structures/ItemsDat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export class ItemsDat {
constructor(public data: Buffer) {}

private getWriteSize(items: ItemDefinition[]) {
// magic num came from counting numeric size
let size = 83 * items.length;
// get sizes for the string

for (const item of items) {
const keys = Object.keys(item);

Expand Down Expand Up @@ -136,6 +137,8 @@ export class ItemsDat {
if (this.meta.version >= 16) item.itemRenderer = await this.readString({ id: item.id });
if (this.meta.version >= 17) item.extraFlags1 = this.readI32();
if (this.meta.version >= 18) item.extraHash1 = this.readI32();
if (this.meta.version >= 19)
item.unknownBytes2 = this.data.subarray(this.mempos, (this.mempos += 9));
}
this.meta.items.push(item);
}
Expand Down Expand Up @@ -239,6 +242,10 @@ export class ItemsDat {
}
if (this.meta.version! >= 17) this.writeI32(item.extraFlags1!);
if (this.meta.version! >= 18) this.writeI32(item.extraHash1!);
if (this.meta.version! >= 19) {
if (Buffer.isBuffer(item.unknownBytes2))
for (const byte of item.unknownBytes2) this.writeU8(byte);
}
}
}
this.mempos = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/types/items.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ export interface ItemDefinition {
extraTexture?: ExtendString;
itemRenderer?: ExtendString;
unknownInt1?: number; // NOTE: not sure what this does
unknownBytes1?: Buffer;
unknownBytes1?: Buffer; // NOTE: not sure what this does
extraFlags1?: number; // NOTE: not sure what this does
extraHash1?: number; // NOTE: not sure what this does
unknownBytes2?: Buffer; // NOTE: not sure what this does
}

export interface ExtendString {
Expand Down

0 comments on commit f87643d

Please sign in to comment.