Fixed Chests and Furnaces not droping their contents when broken

This commit is contained in:
Shoghi Cervantes 2014-05-28 15:34:34 +02:00
parent c778e0467e
commit 130b2c4910
3 changed files with 5 additions and 4 deletions

View File

@ -136,8 +136,8 @@ class Chest extends Transparent{
);
$t = $this->getLevel()->getTile($this);
if($t instanceof TileChest){
for($s = 0; $s < $t->getInventory()->getSize(); ++$s){
$slot = $t->getInventory()->getItem($s);
for($s = 0; $s < $t->getRealInventory()->getSize(); ++$s){
$slot = $t->getRealInventory()->getItem($s);
if($slot->getID() > Item::AIR and $slot->getCount() > 0){
$drops[] = array($slot->getID(), $slot->getDamage(), $slot->getCount());
}

View File

@ -34,7 +34,7 @@ use pocketmine\Server;
class PlayerInventory extends BaseInventory{
protected $itemInHandIndex = -1;
protected $itemInHandIndex = 0;
/** @var int[] */
protected $hotbar;

View File

@ -756,6 +756,7 @@ class Level{
return false;
}
$drops = $target->getDrops($item); //Fixes tile entities being deleted before getting drops
$target->onBreak($item);
if($item instanceof Item){
$item->useOn($target);
@ -765,7 +766,7 @@ class Level{
}
if(!($player instanceof Player) or ($player->getGamemode() & 0x01) === 0){
foreach($target->getDrops($item) as $drop){
foreach($drops as $drop){
if($drop[2] > 0){
$this->dropItem($vector->add(0.5, 0.5, 0.5), Item::get($drop[0], $drop[1], $drop[2]), 1);
}