mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
CraftingTransaction: Don't hardcode crafting grid sizes
This commit is contained in:
parent
98ac6fc7be
commit
878f1bffb9
@ -25,7 +25,7 @@ namespace pocketmine\inventory;
|
||||
|
||||
class BigCraftingGrid extends CraftingGrid{
|
||||
|
||||
public function getDefaultSize() : int{
|
||||
return 9;
|
||||
public function getGridWidth() : int{
|
||||
return 3;
|
||||
}
|
||||
}
|
@ -31,8 +31,12 @@ class CraftingGrid extends BaseInventory{
|
||||
parent::__construct($holder);
|
||||
}
|
||||
|
||||
public function getGridWidth() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getDefaultSize() : int{
|
||||
return 4;
|
||||
return $this->getGridWidth() ** 2;
|
||||
}
|
||||
|
||||
public function setSize(int $size){
|
||||
|
@ -46,7 +46,7 @@ class CraftingTransaction extends InventoryTransaction{
|
||||
protected $recipe = null;
|
||||
|
||||
public function __construct(Player $source, $actions = []){
|
||||
$this->gridSize = ($source->getCraftingGrid() instanceof BigCraftingGrid) ? 3 : 2;
|
||||
$this->gridSize = $source->getCraftingGrid()->getGridWidth();
|
||||
|
||||
$air = ItemFactory::get(Item::AIR, 0, 0);
|
||||
$this->inputs = array_fill(0, $this->gridSize, array_fill(0, $this->gridSize, $air));
|
||||
|
Loading…
x
Reference in New Issue
Block a user