mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Updated protocol details, anvil menu creation
This commit is contained in:
parent
2e0ef645fa
commit
d0bfc826ea
@ -80,7 +80,7 @@ class Anvil extends Fallable{
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
[$this->id, 0, 1], //TODO break level
|
||||
];
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ interface Info{
|
||||
/**
|
||||
* Actual Minecraft: PE protocol version
|
||||
*/
|
||||
const CURRENT_PROTOCOL = 31;
|
||||
const CURRENT_PROTOCOL = 32;
|
||||
|
||||
const LOGIN_PACKET = 0x87;
|
||||
const PLAY_STATUS_PACKET = 0x88;
|
||||
|
@ -56,6 +56,7 @@ class StartGamePacket extends DataPacket{
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putByte(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user