mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-16 16:34:05 +00:00
Sync crafting data changes
this seems to fix #2881, at least the reproducing case that was given.
This commit is contained in:
parent
793f93afdb
commit
898009a91b
@ -24,7 +24,6 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\inventory;
|
namespace pocketmine\inventory;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\item\ItemFactory;
|
|
||||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||||
use pocketmine\network\mcpe\protocol\CraftingDataPacket;
|
use pocketmine\network\mcpe\protocol\CraftingDataPacket;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
@ -56,7 +55,7 @@ class CraftingManager{
|
|||||||
|
|
||||||
foreach($recipes as $recipe){
|
foreach($recipes as $recipe){
|
||||||
switch($recipe["type"]){
|
switch($recipe["type"]){
|
||||||
case 0:
|
case "shapeless":
|
||||||
if($recipe["block"] !== "crafting_table"){ //TODO: filter others out for now to avoid breaking economics
|
if($recipe["block"] !== "crafting_table"){ //TODO: filter others out for now to avoid breaking economics
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -65,7 +64,7 @@ class CraftingManager{
|
|||||||
array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["output"])
|
array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["output"])
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case "shaped":
|
||||||
if($recipe["block"] !== "crafting_table"){ //TODO: filter others out for now to avoid breaking economics
|
if($recipe["block"] !== "crafting_table"){ //TODO: filter others out for now to avoid breaking economics
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -75,14 +74,14 @@ class CraftingManager{
|
|||||||
array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["output"])
|
array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["output"])
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case "smelting":
|
||||||
case 3:
|
|
||||||
if($recipe["block"] !== "furnace"){ //TODO: filter others out for now to avoid breaking economics
|
if($recipe["block"] !== "furnace"){ //TODO: filter others out for now to avoid breaking economics
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$result = $recipe["output"];
|
$this->registerRecipe(new FurnaceRecipe(
|
||||||
$resultItem = Item::jsonDeserialize($result);
|
Item::jsonDeserialize($recipe["output"]),
|
||||||
$this->registerRecipe(new FurnaceRecipe($resultItem, ItemFactory::get($recipe["inputId"], $recipe["inputDamage"] ?? -1, 1)));
|
Item::jsonDeserialize($recipe["input"]))
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -30,6 +30,7 @@ use pocketmine\inventory\FurnaceRecipe;
|
|||||||
use pocketmine\inventory\ShapedRecipe;
|
use pocketmine\inventory\ShapedRecipe;
|
||||||
use pocketmine\inventory\ShapelessRecipe;
|
use pocketmine\inventory\ShapelessRecipe;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\ItemFactory;
|
||||||
use pocketmine\network\mcpe\NetworkBinaryStream;
|
use pocketmine\network\mcpe\NetworkBinaryStream;
|
||||||
use pocketmine\network\mcpe\NetworkSession;
|
use pocketmine\network\mcpe\NetworkSession;
|
||||||
use function count;
|
use function count;
|
||||||
@ -106,10 +107,15 @@ class CraftingDataPacket extends DataPacket{
|
|||||||
break;
|
break;
|
||||||
case self::ENTRY_FURNACE:
|
case self::ENTRY_FURNACE:
|
||||||
case self::ENTRY_FURNACE_DATA:
|
case self::ENTRY_FURNACE_DATA:
|
||||||
$entry["inputId"] = $this->getVarInt();
|
$inputId = $this->getVarInt();
|
||||||
|
$inputData = -1;
|
||||||
if($recipeType === self::ENTRY_FURNACE_DATA){
|
if($recipeType === self::ENTRY_FURNACE_DATA){
|
||||||
$entry["inputDamage"] = $this->getVarInt();
|
$inputData = $this->getVarInt();
|
||||||
|
if($inputData === 0x7fff){
|
||||||
|
$inputData = -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$entry["input"] = ItemFactory::get($inputId, $inputData);
|
||||||
$entry["output"] = $this->getSlot();
|
$entry["output"] = $this->getSlot();
|
||||||
$entry["block"] = $this->getString();
|
$entry["block"] = $this->getString();
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 268bfa763de208366c3d9712ecf697172f95bb55
|
Subproject commit 8696a27a5d05cdae032bf2503973dedff7d21aa9
|
Loading…
x
Reference in New Issue
Block a user