From f7ee78233b7b64323ebfba26ac5a4623f4082952 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 3 Oct 2017 12:28:50 +0100 Subject: [PATCH] Item IDs should always be unsigned, treat them with appropriate measures (fixes #1376) --- src/pocketmine/item/Item.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 7759a2860..e4e46de7f 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -982,7 +982,7 @@ class Item implements ItemIds, \JsonSerializable{ */ public function nbtSerialize(int $slot = -1, string $tagName = "") : CompoundTag{ $tag = new CompoundTag($tagName, [ - new ShortTag("id", $this->id), + new ShortTag("id", Binary::signShort($this->id)), new ByteTag("Count", Binary::signByte($this->count)), new ShortTag("Damage", $this->meta), ]); @@ -1015,7 +1015,7 @@ class Item implements ItemIds, \JsonSerializable{ $meta = isset($tag->Damage) ? $tag->Damage->getValue() : 0; if($tag->id instanceof ShortTag){ - $item = ItemFactory::get($tag->id->getValue(), $meta, $count); + $item = ItemFactory::get(Binary::unsignShort($tag->id->getValue()), $meta, $count); }elseif($tag->id instanceof StringTag){ //PC item save format $item = ItemFactory::fromString($tag->id->getValue()); $item->setDamage($meta);