node id mapping
This commit is contained in:
parent
dbba9b638f
commit
3cafddf24f
@ -67,11 +67,11 @@ module.exports.parse = data => new Promise(function(resolve, reject) {
|
||||
offset++;
|
||||
|
||||
const numMappings = buffer.readUInt16BE(offset);
|
||||
const node_names = [];
|
||||
const node_id_mapping = {};
|
||||
|
||||
offset += 2;
|
||||
for (let i=0; i < numMappings; i++) {
|
||||
//const nodeId = buffer.readUInt16BE(offset);
|
||||
const nodeId = buffer.readUInt16BE(offset);
|
||||
offset += 2;
|
||||
|
||||
const nameLen = buffer.readUInt16BE(offset);
|
||||
@ -80,14 +80,14 @@ module.exports.parse = data => new Promise(function(resolve, reject) {
|
||||
const blockName = buffer.subarray(offset, offset+nameLen).toString();
|
||||
offset += nameLen;
|
||||
|
||||
node_names.push(blockName);
|
||||
node_id_mapping[blockName] = nodeId;
|
||||
}
|
||||
|
||||
resolve({
|
||||
version: version,
|
||||
static_objects_count: static_objects_count,
|
||||
static_objects_version: static_objects_version,
|
||||
node_names: node_names
|
||||
node_id_mapping: node_id_mapping
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -10,7 +10,9 @@ describe('mapblockparser', function() {
|
||||
assert.equal(mapblock.version, 28);
|
||||
assert.equal(mapblock.static_objects_count, 1);
|
||||
assert.equal(mapblock.static_objects_version, 0);
|
||||
assert.equal(mapblock.node_names.some(name => name == "air"), true);
|
||||
assert.equal(mapblock.node_id_mapping.air >= 0, true);
|
||||
assert.equal(mapblock.node_id_mapping["default:stone"] >= 0, true);
|
||||
assert.equal(mapblock.node_id_mapping["some:stuff"] >= 0, false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user