canBeAttacked = true; $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"); //orig: 3 $this->width = 0.98; $this->height = 0.7; $this->yOffset = $this->height / 2; } public function isPickable(){ return !$this->dead; } public function getDrops(){ return [ [MINECART, 0, 1] ]; } public function update($now){ if($this->closed === true){ return false; } } public function close() { parent::close(); if($this->linkedEntity != 0){ $ent = $this->level->entityList[$this->linkedEntity] ?? false; if($ent instanceof Entity){ $ent->stopRiding(); }else{ ConsoleAPI::warn("$this is being ridden by invalid entity {$this->linkedEntity}"); } } } public function isPushable(){ return false; //TODO replace with true } 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); } public function interactWith(Entity $e, $action){ console($action); if($action === InteractPacket::ACTION_HOLD && $e->isPlayer() && $this->canRide($e)){ console("set ride"); $e->setRiding($this); return true; } if($action === InteractPacket::ACTION_ATTACK && $e->eid == $this->linkedEntity){ return false; //TODO more vanilla way? } parent::interactWith($e, $action); } public function canRide($e) { return $this->linkedEntity == 0 && $e->linkedEntity == 0; } }