mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
fixed Anvils item/block different logic handling, close #1910
This commit is contained in:
parent
88a05845c2
commit
ffe89f5e1b
@ -112,7 +112,7 @@ class Anvil extends Fallable{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get($this->getItemId(), $this->getDamage() & 0x0c)
|
||||
ItemFactory::get($this->getItemId(), $this->getDamage() >> 2)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
38
src/pocketmine/item/Anvil.php
Normal file
38
src/pocketmine/item/Anvil.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockFactory;
|
||||
|
||||
class Anvil extends ItemBlock{
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
parent::__construct(Item::ANVIL, $meta);
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
return BlockFactory::get(Block::ANVIL, $this->meta << 2);
|
||||
}
|
||||
}
|
@ -47,6 +47,10 @@ class ItemBlock extends Item{
|
||||
return BlockFactory::get($this->blockId, $this->meta === -1 ? 0 : $this->meta & 0xf);
|
||||
}
|
||||
|
||||
public function getVanillaName() : string{
|
||||
return $this->getBlock()->getName();
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return $this->getBlock()->getFuelTime();
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ class ItemFactory{
|
||||
public static function init(){
|
||||
self::$list = new \SplFixedArray(65536);
|
||||
|
||||
self::registerItem(new Anvil(), true);
|
||||
|
||||
self::registerItem(new Shovel(Item::IRON_SHOVEL, 0, "Iron Shovel", TieredTool::TIER_IRON));
|
||||
self::registerItem(new Pickaxe(Item::IRON_PICKAXE, 0, "Iron Pickaxe", TieredTool::TIER_IRON));
|
||||
self::registerItem(new Axe(Item::IRON_AXE, 0, "Iron Axe", TieredTool::TIER_IRON));
|
||||
|
Loading…
x
Reference in New Issue
Block a user