Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/nbt/src/types/byte-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class ByteListTag extends Array<number> implements BaseTag {
* @param name The name of the tag, defaults to null.
*/
public constructor(elements: Array<number>, name?: string | null) {
super(...elements);
// Push the elements, so a single element is not treated as a length.
super();
this.push(...elements);
this.name = name ?? null;
}

Expand Down Expand Up @@ -46,10 +48,10 @@ class ByteListTag extends Array<number> implements BaseTag {
const type: TagType = stream.readInt8();

// Verify that the tag type matches the expected type.
if (type !== TagType.Byte) {
if (type !== TagType.ByteList) {
// Throw an error if the type does not match.
throw new Error(
`Expected tag type to be ${TagType[TagType.Byte]}, received ${TagType[type] ?? type}.`
`Expected tag type to be ${TagType[TagType.ByteList]}, received ${TagType[type] ?? type}.`
);
}
}
Expand Down
Loading