maxogden/minecraft-nbt — pull request #2 by deathcap (2014-03-15 23:44:44+00:00)
Title: Fix parsing longs and strings

Includes several fixes:

* Updates jdataview to lowercase dependency name to fix missing dependency error (see https://www.npmjs.org/package/jDataView vs https://www.npmjs.org/package/jdataview)
* Uses `getInt64` instead of `getFloat64` to fix parsing `TAG_Long` – previously, would interpret the data as a float, leading to very small numbers:

"firstPlayed": 6.75790774786e-312,

with jdataview 64-bit integers, split into two 32-bits:

"firstPlayed": {
"lo": 2016155682,
"hi": 318
},

which matches the value compared with [NBTExplorer](http://www.minecraftforum.net/topic/840677-nbtexplorer-nbt-editor-for-windows-and-mac/) (318*Math.pow(2,32) + 2016155682 = 1367815755810):

![screen shot 2014-03-15 at 3 30 33 pm](https://f.cloud.github.com/assets/5897956/2429794/aec7151c-ac99-11e3-8d7d-94233f7000f5.png)

* Parses strings as UTF-8 instead of 'binary':

![screen shot 2014-03-15 at 4 30 52 pm](https://f.cloud.github.com/assets/5897956/2429796/e7f694e8-ac99-11e3-90b2-b80ee6eed588.png)

parsed correctly as '§eElectric' (raw bytes: \xc2\xa7 utf8, decode as U+00A7). Before this would decode as 'Â§eElectric'

---

P.S. @maxogden: any interest in merging this module with @sjmulder's https://github.com/sjmulder/nbt-js ('nbt' in npm)? It has been inactive (3 years) not sure if @sjmulder is still up for maintaining it but I think it has a cleaner implementation than this module ('minecraft-nbt'), written directly in JavaScript instead of updated translated from CoffeeScript; though it is using a bundled binary decoding library instead of jdataview. Would be cool to have one ultimate NBT library =) considering preserving the interface of minecraft-nbt (so minecraft-mca/region or any other users wouldn't have to change) but replacing the guts with 'nbt'. Maybe https://github.com/andrewrk/node-minecraft-protocol could even use it too? (cc @andrewrk @roblabla)