Hello everyone,

For the past while, I've been working on a class for reading in, modifying and writing out NBT-format files. This particular format is used for the game Minecraft, as some of you may know.

Attached is my work so far on this, which is coming close to being a working solution to reading the files in. As well, attached is an example NBT for testing the script.

The specification for the NBT format can be found at http://www.minecraft.net/docs/NBT.txt.

The issue which I'm having is that PHP's pack and unpack function for binary data does not seem to be complete. Or, at least, it's missing certain functionality which is necessary for what I'm trying to do.

It may be a matter of misunderstanding on my part, but I would have expected the pack and unpack function to be able to handle every combination of endianness, signing and machine-specific sizing of each type.

Currently, I'm stuck in reading in the TAG_INT type of the NBT format, which is a 32-bit signed short, big-endian, as per the specification. There does not seem to be a packing format code for this data type.

How might I go about this? Am I simply missing something about binary data, or is PHP's pack/unpack functionality indeed lacking? And, if the pack and unpack functions are indeed lacking, is it possible to handle binary data without those functions?

Justin Martin

<<attachment: nbt.class.php>>

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to