mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-09 21:24:53 +00:00
Chests and furnaces drop their items on break
This commit is contained in:
parent
45ee7ea7ae
commit
fdb7af5df2
@ -277,9 +277,7 @@ class BlockAPI{
|
||||
|
||||
if(($player->gamemode & 0x01) === 0x00 and count($drops) > 0){
|
||||
foreach($drops as $drop){
|
||||
for($c = 0; $c < $drop[2]; ++$c){
|
||||
$this->server->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, 1));
|
||||
}
|
||||
$this->server->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2]));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -32,21 +32,21 @@ class BurningFurnaceBlock extends SolidBlock{
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
0 => 4,
|
||||
1 => 2,
|
||||
2 => 5,
|
||||
3 => 3,
|
||||
);
|
||||
$this->meta = $faces[$player->entity->getDirection()];
|
||||
$this->level->setBlock($block, $this);
|
||||
return true;
|
||||
$faces = array(
|
||||
0 => 4,
|
||||
1 => 2,
|
||||
2 => 5,
|
||||
3 => 3,
|
||||
);
|
||||
$this->meta = $faces[$player->entity->getDirection()];
|
||||
$this->level->setBlock($block, $this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
$server = ServerAPI::request();
|
||||
$this->level->setBlock($this, new AirBlock(), true, true);
|
||||
return true;
|
||||
$server = ServerAPI::request();
|
||||
$this->level->setBlock($this, new AirBlock(), true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
@ -116,12 +116,19 @@ class BurningFurnaceBlock extends SolidBlock{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
$drops = array();
|
||||
if($item->isPickaxe() >= 1){
|
||||
return array(
|
||||
array(FURNACE, 0, 1),
|
||||
);
|
||||
}else{
|
||||
return array();
|
||||
$drops[] = array(FURNACE, 0, 1);
|
||||
}
|
||||
$t = ServerAPI::request()->api->tile->get($this);
|
||||
if($t !== false and $t->class === TILE_FURNACE){
|
||||
for($s = 0; $s < FURNACE_SLOTS; ++$s){
|
||||
$slot = $t->getSlot($s);
|
||||
if($slot->getID() > AIR and $slot->count > 0){
|
||||
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $drops;
|
||||
}
|
||||
}
|
@ -99,7 +99,7 @@ class ChestBlock extends TransparentBlock{
|
||||
$slots = array();
|
||||
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
||||
$slot = $chest->getSlot($s);
|
||||
if($slot->getID() > 0 and $slot->count > 0){
|
||||
if($slot->getID() > AIR and $slot->count > 0){
|
||||
$slots[] = $slot;
|
||||
}else{
|
||||
$slots[] = BlockAPI::getItem(AIR, 0, 0);
|
||||
@ -115,8 +115,18 @@ class ChestBlock extends TransparentBlock{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
$drops = array(
|
||||
array($this->id, 0, 1),
|
||||
);
|
||||
$t = ServerAPI::request()->api->tile->get($this);
|
||||
if($t !== false and $t->class === TILE_CHEST){
|
||||
for($s = 0; $s < CHEST_SLOTS; ++$s){
|
||||
$slot = $t->getSlot($s);
|
||||
if($slot->getID() > AIR and $slot->count > 0){
|
||||
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->count);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $drops;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user