mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Updated some packets for 0.12, UUIDs, other stuff!
This commit is contained in:
@ -26,6 +26,7 @@ use pocketmine\block\Stone;
|
||||
use pocketmine\block\Wood;
|
||||
use pocketmine\block\Wood2;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class CraftingManager{
|
||||
|
||||
@ -38,6 +39,8 @@ class CraftingManager{
|
||||
/** @var FurnaceRecipe[] */
|
||||
public $furnaceRecipes = [];
|
||||
|
||||
private static $RECIPE_COUNT = 0;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
$this->registerStonecutter();
|
||||
@ -519,6 +522,8 @@ class CraftingManager{
|
||||
}elseif($recipe instanceof FurnaceRecipe){
|
||||
$this->registerFurnaceRecipe($recipe);
|
||||
}
|
||||
|
||||
$recipe->setId(UUID::fromData(++self::$RECIPE_COUNT, $recipe->getResult()->getId(), $recipe->getResult()->getDamage(), $recipe->getResult()->getCount(), $recipe->getResult()->getCompoundTag()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,8 +23,12 @@ namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class FurnaceRecipe implements Recipe{
|
||||
|
||||
private $id = null;
|
||||
|
||||
/** @var Item */
|
||||
private $output;
|
||||
|
||||
@ -40,6 +44,18 @@ class FurnaceRecipe implements Recipe{
|
||||
$this->ingredient = clone $ingredient;
|
||||
}
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(UUID $id){
|
||||
if($this->id !== null){
|
||||
throw new \InvalidStateException("Id is already set");
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
*/
|
||||
|
@ -29,8 +29,8 @@ use pocketmine\item\Item;
|
||||
use pocketmine\network\Network;
|
||||
use pocketmine\network\protocol\ContainerSetContentPacket;
|
||||
use pocketmine\network\protocol\ContainerSetSlotPacket;
|
||||
use pocketmine\network\protocol\PlayerArmorEquipmentPacket;
|
||||
use pocketmine\network\protocol\PlayerEquipmentPacket;
|
||||
use pocketmine\network\protocol\MobArmorEquipmentPacket;
|
||||
use pocketmine\network\protocol\MobEquipmentPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
@ -126,7 +126,7 @@ class PlayerInventory extends BaseInventory{
|
||||
public function sendHeldItem($target){
|
||||
$item = $this->getItemInHand();
|
||||
|
||||
$pk = new PlayerEquipmentPacket();
|
||||
$pk = new MobEquipmentPacket();
|
||||
$pk->eid = ($target === $this->getHolder() ? 0 : $this->getHolder()->getId());
|
||||
$pk->item = $item->getId();
|
||||
$pk->meta = $item->getDamage();
|
||||
@ -315,7 +315,7 @@ class PlayerInventory extends BaseInventory{
|
||||
}
|
||||
}
|
||||
|
||||
$pk = new PlayerArmorEquipmentPacket();
|
||||
$pk = new MobArmorEquipmentPacket();
|
||||
$pk->eid = $this->getHolder()->getId();
|
||||
$pk->slots = $slots;
|
||||
$pk->encode();
|
||||
@ -372,7 +372,7 @@ class PlayerInventory extends BaseInventory{
|
||||
}
|
||||
}
|
||||
|
||||
$pk = new PlayerArmorEquipmentPacket();
|
||||
$pk = new MobArmorEquipmentPacket();
|
||||
$pk->eid = $this->getHolder()->getId();
|
||||
$pk->slots = $slots;
|
||||
$pk->encode();
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
interface Recipe{
|
||||
|
||||
/**
|
||||
@ -29,4 +31,9 @@ interface Recipe{
|
||||
public function getResult();
|
||||
|
||||
public function registerToCraftingManager();
|
||||
|
||||
/**
|
||||
* @return UUID
|
||||
*/
|
||||
public function getId();
|
||||
}
|
@ -23,11 +23,14 @@ namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class ShapedRecipe implements Recipe{
|
||||
/** @var Item */
|
||||
private $output;
|
||||
|
||||
private $id = null;
|
||||
|
||||
/** @var string[] */
|
||||
private $rows = [];
|
||||
|
||||
@ -61,6 +64,22 @@ class ShapedRecipe implements Recipe{
|
||||
$this->output = clone $result;
|
||||
}
|
||||
|
||||
public function getResult(){
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(UUID $id){
|
||||
if($this->id !== null){
|
||||
throw new \InvalidStateException("Id is already set");
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param Item $item
|
||||
|
@ -23,11 +23,14 @@ namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class ShapelessRecipe implements Recipe{
|
||||
/** @var Item */
|
||||
private $output;
|
||||
|
||||
private $id = null;
|
||||
|
||||
/** @var Item[] */
|
||||
private $ingredients = [];
|
||||
|
||||
@ -35,6 +38,18 @@ class ShapelessRecipe implements Recipe{
|
||||
$this->output = clone $result;
|
||||
}
|
||||
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(UUID $id){
|
||||
if($this->id !== null){
|
||||
throw new \InvalidStateException("Id is already set");
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getResult(){
|
||||
return clone $this->output;
|
||||
}
|
||||
|
Reference in New Issue
Block a user