protocol: fixed missing field of CraftRecipeAuto

This commit is contained in:
Dylan K. Taylor 2021-10-20 19:47:32 +01:00
parent 9c5cec77b1
commit dc07ac33d3
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 47 additions and 49 deletions

View File

@ -23,12 +23,38 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest;
use pocketmine\network\mcpe\NetworkBinaryStream;
/**
* Tells that the current transaction crafted the specified recipe, using the recipe book. This is effectively the same
* as the regular crafting result action.
*/
final class CraftRecipeAutoStackRequestAction extends ItemStackRequestAction{
use CraftRecipeStackRequestActionTrait;
/** @var int */
private $recipeId;
/** @var int */
private $repetitions;
final public function __construct(int $recipeId, int $repetitions){
$this->recipeId = $recipeId;
$this->repetitions = $repetitions;
}
public function getRecipeId() : int{ return $this->recipeId; }
public function getRepetitions() : int{ return $this->repetitions; }
public static function getTypeId() : int{ return ItemStackRequestActionType::CRAFTING_RECIPE_AUTO; }
public static function read(NetworkBinaryStream $in) : self{
$recipeId = $in->readGenericTypeNetworkId();
$repetitions = $in->getByte();
return new self($recipeId, $repetitions);
}
public function write(NetworkBinaryStream $out) : void{
$out->writeGenericTypeNetworkId($this->recipeId);
$out->putByte($this->repetitions);
}
}

View File

@ -23,11 +23,30 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest;
use pocketmine\network\mcpe\NetworkBinaryStream;
/**
* Tells that the current transaction crafted the specified recipe.
*/
final class CraftRecipeStackRequestAction extends ItemStackRequestAction{
use CraftRecipeStackRequestActionTrait;
/** @var int */
private $recipeId;
final public function __construct(int $recipeId){
$this->recipeId = $recipeId;
}
public function getRecipeId() : int{ return $this->recipeId; }
public static function getTypeId() : int{ return ItemStackRequestActionType::CRAFTING_RECIPE; }
public static function read(NetworkBinaryStream $in) : self{
$recipeId = $in->readGenericTypeNetworkId();
return new self($recipeId);
}
public function write(NetworkBinaryStream $out) : void{
$out->writeGenericTypeNetworkId($this->recipeId);
}
}

View File

@ -1,47 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program 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.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest;
use pocketmine\network\mcpe\NetworkBinaryStream;
trait CraftRecipeStackRequestActionTrait{
/** @var int */
private $recipeId;
final public function __construct(int $recipeId){
$this->recipeId = $recipeId;
}
public function getRecipeId() : int{ return $this->recipeId; }
public static function read(NetworkBinaryStream $in) : self{
$recipeId = $in->readGenericTypeNetworkId();
return new self($recipeId);
}
public function write(NetworkBinaryStream $out) : void{
$out->writeGenericTypeNetworkId($this->recipeId);
}
}