diff --git a/src/types/command/CommandParameterTypes.php b/src/types/command/CommandParameterTypes.php deleted file mode 100644 index fbb96041..00000000 --- a/src/types/command/CommandParameterTypes.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * BedrockProtocol is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - */ - -declare(strict_types=1); - -namespace pocketmine\network\mcpe\protocol\types\command; - -/** - * This file is automatically generated; do NOT edit it by hand. - * Regenerate it by running tools/generate-command-parameter-types.php - */ -final class CommandParameterTypes{ - - private function __construct(){ - //NOOP - } - - public const INT = 1; // int - public const VAL = 3; // float - public const RVAL = 4; // value - public const WILDCARDINT = 5; // wildcard int - public const OPERATOR = 6; // operator - public const COMPAREOPERATOR = 7; // compare operator - public const SELECTION = 8; // target - public const WILDCARDSELECTION = 10; // target - public const PATHCOMMAND = 17; // filepath - public const FULLINTEGERRANGE = 23; // integer range - public const EQUIPMENTSLOTENUM = 47; // equipment slots - public const ID = 56; // string - public const POSITION = 64; // x y z - public const POSITION_FLOAT = 65; // x y z - public const MESSAGE_ROOT = 68; // message - public const RAWTEXT = 70; // text - public const JSON_OBJECT = 74; // json - public const BLOCK_STATE_ARRAY = 84; // block states - public const SLASHCOMMAND = 87; // command -} diff --git a/src/types/inventory/ItemStackExtraData.php b/src/types/inventory/ItemStackExtraData.php deleted file mode 100644 index 6def31b5..00000000 --- a/src/types/inventory/ItemStackExtraData.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * BedrockProtocol is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - */ - -declare(strict_types=1); - -namespace pocketmine\network\mcpe\protocol\types\inventory; - -use pocketmine\nbt\LittleEndianNbtSerializer; -use pocketmine\nbt\NbtDataException; -use pocketmine\nbt\tag\CompoundTag; -use pocketmine\nbt\TreeRoot; -use pocketmine\network\mcpe\protocol\PacketDecodeException; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; -use function count; -use function strlen; - -/** - * Wrapper class for extra data on ItemStacks. - * The data is normally provided as a raw string (not automatically decoded). - * This class is just a DTO for PacketSerializer to use when encoding/decoding ItemStacks. - */ -class ItemStackExtraData{ - /** - * @param string[] $canPlaceOn - * @param string[] $canDestroy - */ - public function __construct( - private ?CompoundTag $nbt, - private array $canPlaceOn, - private array $canDestroy - ){} - - /** - * @return string[] - */ - public function getCanPlaceOn() : array{ - return $this->canPlaceOn; - } - - /** - * @return string[] - */ - public function getCanDestroy() : array{ - return $this->canDestroy; - } - - public function getNbt() : ?CompoundTag{ - return $this->nbt; - } - - public static function read(PacketSerializer $in) : self{ - $nbtLen = $in->getLShort(); - - /** @var CompoundTag|null $compound */ - $compound = null; - if($nbtLen === 0xffff){ - $nbtDataVersion = $in->getByte(); - if($nbtDataVersion !== 1){ - throw new PacketDecodeException("Unexpected NBT data version $nbtDataVersion"); - } - $offset = $in->getOffset(); - try{ - $compound = (new LittleEndianNbtSerializer())->read($in->getBuffer(), $offset, 512)->mustGetCompoundTag(); - }catch(NbtDataException $e){ - throw PacketDecodeException::wrap($e, "Failed decoding NBT root"); - }finally{ - $in->setOffset($offset); - } - }elseif($nbtLen !== 0){ - throw new PacketDecodeException("Unexpected fake NBT length $nbtLen"); - } - - $canPlaceOn = []; - for($i = 0, $canPlaceOnCount = $in->getLInt(); $i < $canPlaceOnCount; ++$i){ - $canPlaceOn[] = $in->get($in->getLShort()); - } - - $canDestroy = []; - for($i = 0, $canDestroyCount = $in->getLInt(); $i < $canDestroyCount; ++$i){ - $canDestroy[] = $in->get($in->getLShort()); - } - - return new self($compound, $canPlaceOn, $canDestroy); - } - - public function write(PacketSerializer $out) : void{ - if($this->nbt !== null){ - $out->putLShort(0xffff); - $out->putByte(1); //TODO: NBT data version (?) - $out->put((new LittleEndianNbtSerializer())->write(new TreeRoot($this->nbt))); - }else{ - $out->putLShort(0); - } - - $out->putLInt(count($this->canPlaceOn)); - foreach($this->canPlaceOn as $entry){ - $out->putLShort(strlen($entry)); - $out->put($entry); - } - $out->putLInt(count($this->canDestroy)); - foreach($this->canDestroy as $entry){ - $out->putLShort(strlen($entry)); - $out->put($entry); - } - } -} diff --git a/src/types/inventory/ItemStackExtraDataShield.php b/src/types/inventory/ItemStackExtraDataShield.php deleted file mode 100644 index 3c7519cd..00000000 --- a/src/types/inventory/ItemStackExtraDataShield.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * BedrockProtocol is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - */ - -declare(strict_types=1); - -namespace pocketmine\network\mcpe\protocol\types\inventory; - -use pocketmine\nbt\tag\CompoundTag; -use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; - -/** - * Extension of ItemStackExtraData for shield items, which have an additional field for the blocking tick. - */ -final class ItemStackExtraDataShield extends ItemStackExtraData{ - - /** - * @param string[] $canPlaceOn - * @param string[] $canDestroy - */ - public function __construct( - ?CompoundTag $nbt, - array $canPlaceOn, - array $canDestroy, - private int $blockingTick - ){ - parent::__construct($nbt, $canPlaceOn, $canDestroy); - } - - public function getBlockingTick() : int{ return $this->blockingTick; } - - public static function read(PacketSerializer $in) : self{ - $base = parent::read($in); - $blockingTick = $in->getLLong(); - - return new self($base->getNbt(), $base->getCanPlaceOn(), $base->getCanDestroy(), $blockingTick); - } - - public function write(PacketSerializer $out) : void{ - parent::write($out); - $out->putLLong($this->blockingTick); - } -}