Door drop fixed

This commit is contained in:
ArkQuark 2022-05-04 21:49:18 +03:00
parent 230357a82c
commit d3a627c977
3 changed files with 4 additions and 23 deletions

View file

@ -35,10 +35,12 @@ class DoorBlock extends TransparentBlock{
*
* @return bool|int
*/
public function onUpdate($type){
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false);
if($this->getID() == 64) ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(324, 0, 1));
elseif($this->getID() == 71) ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(330, 0, 1));
if($this->getSide(1) instanceof DoorBlock){
$this->level->setBlock($this->getSide(1), new AirBlock(), false);
}
@ -48,6 +50,7 @@ class DoorBlock extends TransparentBlock{
return false;
}
/**
* @param Item $item
* @param Player $player

View file

@ -46,17 +46,6 @@ class IronDoorBlock extends DoorBlock{
}
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, $this->meta, 1));
$this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL;
}
}
return false;
}
public function getDrops(Item $item, Player $player){
if($item->isPickaxe() >= 1){
return array(

View file

@ -26,17 +26,6 @@ class WoodDoorBlock extends DoorBlock{
$this->hardness = 15;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL and $meta == 0x8){
if($this->getSide(0)->getID() === AIR){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, $this->meta, 1));
$this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL;
}
}
return false;
}
public function getDrops(Item $item, Player $player){
return array(
array(WOODEN_DOOR, 0, 1),