mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Updated protocol details, anvil menu creation
This commit is contained in:
@ -21,28 +21,27 @@
|
||||
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\Network;
|
||||
use pocketmine\network\protocol\TileEventPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\tile\Chest;
|
||||
|
||||
class AnvilInventory extends ContainerInventory implements InventoryHolder{
|
||||
class AnvilInventory extends ContainerInventory{
|
||||
public function __construct(Position $pos){
|
||||
parent::__construct($this, InventoryType::get(InventoryType::ANVIL));
|
||||
}
|
||||
|
||||
public function getInventory(){
|
||||
return $this;
|
||||
parent::__construct(new FakeBlockMenu($this, $pos), InventoryType::get(InventoryType::ANVIL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AnvilInventory
|
||||
* @return FakeBlockMenu
|
||||
*/
|
||||
public function getHolder(){
|
||||
return $this->holder;
|
||||
}
|
||||
|
||||
public function onClose(Player $who){
|
||||
parent::onClose($who);
|
||||
|
||||
for($i = 0; $i < 2; ++$i){
|
||||
$this->getHolder()->getLevel()->dropItem($this->getHolder()->add(0.5, 0.5, 0.5), $this->getItem($i));
|
||||
$this->clear($i);
|
||||
}
|
||||
}
|
||||
}
|
45
src/pocketmine/inventory/FakeBlockMenu.php
Normal file
45
src/pocketmine/inventory/FakeBlockMenu.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\Network;
|
||||
use pocketmine\network\protocol\TileEventPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\tile\Chest;
|
||||
|
||||
class FakeBlockMenu extends Position implements InventoryHolder{
|
||||
|
||||
private $inventory;
|
||||
|
||||
public function __construct(Inventory $inventory, Position $pos){
|
||||
$this->inventory = $inventory;
|
||||
parent::__construct($pos->x, $pos->y, $pos->z, $pos->level);
|
||||
}
|
||||
|
||||
public function getInventory(){
|
||||
return $this->inventory;
|
||||
}
|
||||
}
|
@ -65,7 +65,7 @@ class InventoryType{
|
||||
static::$default[static::STONECUTTER] = new InventoryType(10, "Crafting", 1); //9 CRAFTING slots, 1 RESULT
|
||||
static::$default[static::ENCHANT_TABLE] = new InventoryType(1, "Enchant", 4); //1 INPUT/OUTPUT
|
||||
static::$default[static::BREWING_STAND] = new InventoryType(4, "Brewing", 5); //1 INPUT, 3 POTION
|
||||
static::$default[static::ANVIL] = new InventoryType(3, "Brewing", 6); //2 INPUT, 1 OUTPUT
|
||||
static::$default[static::ANVIL] = new InventoryType(3, "Anvil", 6); //2 INPUT, 1 OUTPUT
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user