NostalgiaCore/src/entity/object/Minecart.php
ArkQuark f5222be9d2 Big update about mobs
Removes some array() and some another minor changes.
Cow now drop 0-3 meat.
Pigs can be saddled, and if pig saddled it will drop them.
Creeper can be blown up with flint and steel ("power" => 3).
You can ride on pig (some buggy).
Now Saddle maxStackSize = 1.
Using shears and flint&steel on sheep and creeper they will break.
Saddled will save with closing the server.
2022-10-30 18:13:37 +03:00

49 lines
No EOL
1.4 KiB
PHP

<?php
class Minecart extends Vehicle{
const TYPE = OBJECT_MINECART;
private $moveVector = [];
const STATE_INITIAL = 0;
const STATE_ON_RAIL = 1;
const STATE_OFF_RAIL = 2;
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
parent::__construct($level, $eid, $class, $type, $data);
$this->x = isset($this->data["TileX"]) ? $this->data["TileX"]:$this->x;
$this->y = isset($this->data["TileY"]) ? $this->data["TileY"]:$this->y;
$this->z = isset($this->data["TileZ"]) ? $this->data["TileZ"]:$this->z;
$this->setHealth(1, "generic");
//$this->setName((isset($objects[$this->type]) ? $objects[$this->type]:$this->type));
$this->width = 1;
/*$this->moveVector[Entity::NORTH] = new Vector3(-1, 0, 0);
$this->moveVector[Entity::SOUTH] = new Vector3(1, 0, 0);
$this->moveVector[Entity::EAST] = new Vector3(0, 0, -1);
$this->moveVector[Entity::WEST] = new Vector3(0, 0, 1);*/
$this->update();
}
public function getDrops(){
return [
[MINECART, 0, 1]
];
}
public function spawn($player){
$pk = new AddEntityPacket;
$pk->eid = $this->eid;
$pk->type = $this->type;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$player->dataPacket($pk);
$pk = new SetEntityMotionPacket;
$pk->eid = $this->eid;
$pk->speedX = $this->speedX;
$pk->speedY = $this->speedY;
$pk->speedZ = $this->speedZ;
$player->dataPacket($pk);
}
}