Fixed NBT IntArray off-by-one reading

This commit is contained in:
Shoghi Cervantes 2015-03-15 16:39:43 +01:00
parent 807107e581
commit 220d2b7bee
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89

View File

@ -34,7 +34,10 @@ class IntArray extends NamedTag{
public function read(NBT $nbt){
$this->value = [];
$size = $nbt->getInt();
$this->value = unpack($nbt->endianness === NBT::LITTLE_ENDIAN ? "V*" : "N*", $nbt->get($size * 4));
$value = unpack($nbt->endianness === NBT::LITTLE_ENDIAN ? "V*" : "N*", $nbt->get($size * 4));
foreach($value as $i => $v){
$this->value[$i - 1] = $v;
}
}
public function write(NBT $nbt){