mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Base inventory fixes
This commit is contained in:
@ -191,18 +191,16 @@ class BinaryStream extends \stdClass{
|
||||
}
|
||||
|
||||
public function getSlot(){
|
||||
$id = $this->getSignedShort();
|
||||
$id = $this->getVarInt();
|
||||
|
||||
if($id <= 0){
|
||||
return Item::get(0, 0, 0);
|
||||
}
|
||||
|
||||
$cnt = $this->getByte();
|
||||
|
||||
$data = $this->getShort();
|
||||
$auxValue = $this->getVarInt();
|
||||
$data = $auxValue >> 8;
|
||||
$cnt = $auxValue & 0xff;
|
||||
|
||||
$nbtLen = $this->getLShort();
|
||||
|
||||
$nbt = "";
|
||||
|
||||
if($nbtLen > 0){
|
||||
@ -217,19 +215,19 @@ class BinaryStream extends \stdClass{
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function putSlot(Item $item){
|
||||
if($item->getId() === 0){
|
||||
$this->putShort(0);
|
||||
$this->putVarInt(0);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->putShort($item->getId());
|
||||
$this->putByte($item->getCount());
|
||||
$this->putShort($item->getDamage() === null ? -1 : $item->getDamage());
|
||||
$this->putVarInt($item->getId());
|
||||
$auxValue = ($item->getDamage() << 8) | $item->getCount();
|
||||
$this->putVarInt($auxValue);
|
||||
$nbt = $item->getCompoundTag();
|
||||
$this->putLShort(strlen($nbt));
|
||||
$this->put($nbt);
|
||||
|
||||
}
|
||||
|
||||
public function getString(){
|
||||
|
Reference in New Issue
Block a user