Working item frames

This commit is contained in:
Dylan K. Taylor
2016-12-14 18:30:40 +00:00
parent c4d4277a6c
commit 8c772fe671
6 changed files with 211 additions and 13 deletions

View File

@ -133,6 +133,7 @@ use pocketmine\network\SourceInterface;
use pocketmine\permission\PermissibleBase;
use pocketmine\permission\PermissionAttachment;
use pocketmine\plugin\Plugin;
use pocketmine\tile\ItemFrame;
use pocketmine\tile\Sign;
use pocketmine\tile\Spawnable;
use pocketmine\tile\Tile;
@ -2930,6 +2931,25 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->dataPacket($pk);
$this->sendSettings();
}
break;
case ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET:
if($this->spawned === false or $this->blocked === true or !$this->isAlive()){
break;
}
if(($tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z))) instanceof ItemFrame){
if(!$tile->getItem()->equals($packet->item) and !$this->isCreative(true)){
$tile->spawnTo($this);
break;
}
if(lcg_value() <= $tile->getItemDropChance() and $packet->item->getId() !== Item::AIR){
$this->level->dropItem($tile->getBlock(), $packet->item); //Use the packet item to handle creative drops correctly
}
$tile->setItem(null);
$tile->setItemRotation(0);
}
break;
default:
break;
@ -3025,7 +3045,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$pk->message = $message;
$this->dataPacket($pk);
}
/**
* @param string $sender
* @param string $message