fixed server not checking crafting results if crafting was done in inventory

This commit is contained in:
GameHerobrine 2025-05-10 20:37:03 +03:00
parent 236e98be23
commit 9e9dd532a3

View file

@ -2195,7 +2195,6 @@ class Player{
$this->craftingItems = []; $this->craftingItems = [];
$this->toCraft = []; $this->toCraft = [];
$this->craftingType = CraftingRecipes::TYPE_INVENTORY; $this->craftingType = CraftingRecipes::TYPE_INVENTORY;
$packet->eid = $this->eid; $packet->eid = $this->eid;
for($i = 0; $i < 4; ++$i){ for($i = 0; $i < 4; ++$i){
$s = $packet->slots[$i]; $s = $packet->slots[$i];
@ -2205,21 +2204,21 @@ class Player{
$s = BlockAPI::getItem($s + 256, 0, 1); $s = BlockAPI::getItem($s + 256, 0, 1);
} }
$slot = $this->armor[$i]; $slot = $this->armor[$i];
if($slot->getID() !== AIR and $s->getID() === AIR){
if($slot->getID() !== AIR && $s->getID() === AIR){
$this->addItem($slot->getID(), $slot->getMetadata(), 1, false); $this->addItem($slot->getID(), $slot->getMetadata(), 1, false);
$this->armor[$i] = BlockAPI::getItem(AIR, 0, 0); $this->armor[$i] = BlockAPI::getItem(AIR, 0, 0);
$packet->slots[$i] = 255; $packet->slots[$i] = 255;
}elseif($s->getID() !== AIR and $slot->getID() === AIR and ($sl = $this->hasItem($s->getID())) !== false){ }elseif($s->getID() !== AIR and $slot->getID() === AIR and ($sl = $this->hasItem($s->getID())) !== false){
$this->armor[$i] = $this->getSlot($sl); $this->armor[$i] = $this->getSlot($sl);
$this->setSlot($sl, BlockAPI::getItem(AIR, 0, 0), false); $this->setSlot($sl, BlockAPI::getItem(AIR, 0, 0), false);
}elseif($s->getID() !== AIR and $slot->getID() !== AIR and ($slot->getID() !== $s->getID() or $slot->getMetadata() !== $s->getMetadata()) and ($sl = $this->hasItem($s->getID())) !== false){ }elseif($s->getID() !== AIR && $slot->getID() !== AIR and ($slot->getID() !== $s->getID() or $slot->getMetadata() !== $s->getMetadata()) and ($sl = $this->hasItem($s->getID())) !== false){
$item = $this->armor[$i]; $item = $this->armor[$i];
$this->armor[$i] = $this->getSlot($sl); $this->armor[$i] = $this->getSlot($sl);
$this->setSlot($sl, $item, false); $this->setSlot($sl, $item, false);
}else{ }else{
$packet->slots[$i] = 255; $packet->slots[$i] = 255;
} }
} }
$this->sendArmor(); $this->sendArmor();
if($this->entity->inAction === true){ if($this->entity->inAction === true){
@ -2497,6 +2496,7 @@ class Player{
$this->craftingItems = []; $this->craftingItems = [];
$this->craftingType = CraftingRecipes::TYPE_INVENTORY; $this->craftingType = CraftingRecipes::TYPE_INVENTORY;
} }
if(!isset($this->windows[$packet->windowid])){ if(!isset($this->windows[$packet->windowid])){
break; break;
} }
@ -2731,10 +2731,14 @@ class Player{
$cc = CraftingRecipes::canCraft($results, $ingridients, $this->craftingType); $cc = CraftingRecipes::canCraft($results, $ingridients, $this->craftingType);
if(!is_array($cc) && $this->craftingType == CraftingRecipes::TYPE_CRAFTIGTABLE){ if(!is_array($cc)){
$cc = CraftingRecipes::canCraft($results, $ingridients, CraftingRecipes::TYPE_INVENTORY); if($this->craftingType == CraftingRecipes::TYPE_CRAFTIGTABLE){
if(!is_array($cc)){ $cc = CraftingRecipes::canCraft($results, $ingridients, CraftingRecipes::TYPE_INVENTORY);
return; //recipe not found if(!is_array($cc)){
return; //recipe not found
}
}else{
return;
} }
} }