added nbt

This commit is contained in:
Keegan 2016-03-06 11:11:14 -05:00
commit b860063e36
3 changed files with 17 additions and 10 deletions

View file

@ -35,7 +35,7 @@
},
{
"name": "nbtData",
"type": "optionalNbt"
"type": "nbt"
}
]
]

View file

@ -17,6 +17,7 @@
],
"license": "MIT",
"dependencies": {
"prismarine-nbt": "^0.2.1",
"protodef": "^1.1.2",
"raknet": "^1.1.0"
},

View file

@ -1,3 +1,5 @@
var nbt = require('prismarine-nbt');
function readUUID(buffer, offset) {
if(offset+16>buffer.length)
throw new PartialReadError();
@ -13,15 +15,19 @@ function writeUUID(value, buffer, offset) {
return offset + 16;
}
function readNbt(buffer, offset) {
return nbt.proto.read(buffer,offset,"nbt");
}
function writeNbt(value, buffer, offset) {
return nbt.proto.write(value,buffer,offset,"nbt");
}
function sizeOfNbt(value) {
return nbt.proto.sizeOf(value,"nbt");
}
module.exports = {
'uuid': [readUUID, writeUUID, 16],
'metadatadictionary': [readLTriad, writeLTriad, 3],
'skin': [readIpAddress, writeIpAddress, 4],
'entitylocations': [readRestBuffer, writeRestBuffer, sizeOfRestBuffer],
'blockrecords':[readEndOfArray,writeEndOfArray,sizeOfEndOfArray],
'records':[readToByte,writeToByte,sizeOfToByte],
'playerattributes': [],
'item': [],
'blockcoordinates': []
'nbt': [readNbt, writeNbt, sizeOfNbt]
};