fix anvil bounding box

This commit is contained in:
Dylan K. Taylor 2017-10-13 11:18:19 +01:00
parent 2893aac3ac
commit 401e33dd85

View File

@ -27,6 +27,7 @@ use pocketmine\inventory\AnvilInventory;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
@ -67,6 +68,30 @@ class Anvil extends Fallable{
return Tool::TYPE_PICKAXE;
}
public function recalculateBoundingBox() : ?AxisAlignedBB{
$inset = 0.125;
if($this->meta & 0x01){ //east/west
return new AxisAlignedBB(
$this->x,
$this->y,
$this->z + $inset,
$this->x + 1,
$this->y + 1,
$this->z + 1 - $inset
);
}else{
return new AxisAlignedBB(
$this->x + $inset,
$this->y,
$this->z,
$this->x + 1 - $inset,
$this->y + 1,
$this->z + 1
);
}
}
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$player->addWindow(new AnvilInventory($this));