Added base physics

This commit is contained in:
Shoghi Cervantes
2014-05-25 12:31:00 +02:00
parent ec055fd8d1
commit 4f2856dc09
9 changed files with 360 additions and 25 deletions

View File

@ -27,6 +27,7 @@ use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\Short;
use pocketmine\nbt\tag\String;
use pocketmine\network\protocol\AddItemEntityPacket;
use pocketmine\network\protocol\SetEntityMotionPacket;
use pocketmine\Player;
class DroppedItem extends Entity{
@ -38,6 +39,12 @@ class DroppedItem extends Entity{
/** @var Item */
protected $item;
public $width = 0.25;
public $length = 0.25;
public $height = 0.25;
protected $gravity = 0.04;
protected $drag = 0.02;
protected function initEntity(){
//TODO: upgrade old numeric entity ids
$this->namedtag->id = new String("id", "Item");
@ -156,6 +163,13 @@ class DroppedItem extends Entity{
$pk->metadata = $this->getData();
$player->dataPacket($pk);
$pk = new SetEntityMotionPacket;
$pk->eid = $this->getID();
$pk->speedX = $this->motionX;
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$player->dataPacket($pk);
parent::spawnTo($player);
}
}