mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Added base physics
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user