mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Fix anvil rotation and variant drops
This commit is contained in:
parent
1d876e30c8
commit
d696049a0a
@ -28,6 +28,10 @@ use pocketmine\Player;
|
|||||||
|
|
||||||
class Anvil extends Fallable{
|
class Anvil extends Fallable{
|
||||||
|
|
||||||
|
const TYPE_NORMAL = 0;
|
||||||
|
const TYPE_SLIGHTLY_DAMAGED = 4;
|
||||||
|
const TYPE_VERY_DAMAGED = 8;
|
||||||
|
|
||||||
protected $id = self::ANVIL;
|
protected $id = self::ANVIL;
|
||||||
|
|
||||||
public function isSolid(){
|
public function isSolid(){
|
||||||
@ -51,7 +55,12 @@ class Anvil extends Fallable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return "Anvil";
|
static $names = [
|
||||||
|
self::TYPE_NORMAL => "Anvil",
|
||||||
|
self::TYPE_SLIGHTLY_DAMAGED => "Slightly Damaged Anvil",
|
||||||
|
self::TYPE_VERY_DAMAGED => "Very Damaged Anvil"
|
||||||
|
];
|
||||||
|
return $names[$this->meta & 0x0c] ?? "Anvil";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getToolType(){
|
public function getToolType(){
|
||||||
@ -66,10 +75,16 @@ class Anvil extends Fallable{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
|
$direction = ($player !== null ? $player->getDirection() : 0) & 0x03;
|
||||||
|
$this->meta = ($this->meta & 0x0c) | $direction;
|
||||||
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item){
|
public function getDrops(Item $item){
|
||||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||||
return [
|
return [
|
||||||
[$this->id, 0, 1], //TODO break level
|
[$this->id, $this->meta & 0x0c, 1],
|
||||||
];
|
];
|
||||||
}else{
|
}else{
|
||||||
return [];
|
return [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user