Skip to content

Commit

Permalink
Fixed more list issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Bradley Watton committed Oct 23, 2020
1 parent b96692b commit c974ae3
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/BinaryData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class BinaryData extends BData {
case TagType.Long:
return this.readLong()
case TagType.String:
return this.readString(this.readShort())
return this.readStringShort()
case TagType.List:
const list = tag as ListTag
list.valueType = this.readByte()
Expand All @@ -32,6 +32,14 @@ export class BinaryData extends BData {
return this.readTagArray('readInt', 'readInt')
case TagType.Compound:
return this.readCompoundList()
case TagType.String:
return this.readTagArray('readStringShort', 'readInt')
case TagType.Double:
return this.readTagArray('readDouble', 'readInt')
case TagType.Float:
return this.readTagArray('readFloat', 'readInt')
case TagType.End:
return null
default:
throw new Error(`Don't know how to read ListTag.valueType of ${list.valueType}`)
}
Expand All @@ -46,17 +54,21 @@ export class BinaryData extends BData {
return super.readTagValue(tag)
}

public readStringShort(): string {
return this.readString(this.readShort())
}

public readCompoundList(): CompoundTag[] {
const count = this.readInt()

let gotEnd = false

const compounds: CompoundTag[] = []
while(!gotEnd) {
for(let i = 0; i < count; i++) {
const tag = new CompoundTag()

const tags: Record<string, Tag> = {}
for(let i = 0; i < count; i++) {

let gotEnd = false
while(!gotEnd) {
const tag = this.readTag()

if(tag instanceof EndTag) {
Expand Down

0 comments on commit c974ae3

Please sign in to comment.