When I do updateMovement() to Minecart entity, then it looks like this: How can I fix it? I'm doing only updateMovement() and nothing else.
Thanks. Now I'm trying to implement movement for the minecart (in air), but players head is still in the minecart and player is sitting on air, not on minecart, so it all times move minecart 1 block up image: Spoiler Minecart class: Spoiler PHP: $this->moveVector[2] = new Vector3(-1, 0, 0);$this->moveVector[0] = new Vector3(1, 0, 0);$this->moveVector[3] = new Vector3(0, 0, -1);$this->moveVector[1] = new Vector3(0, 0, 1);public function entityBaseTick(int $tickDiff = 1) : bool{ if($this->closed){ return false; } $player = null; if(!is_null($this->sittingEntity)){ $player = $this->sittingEntity; $this->processMovement(); $this->yaw = 0; $this->pitch = 0; $this->updateMovement(); }else{ return false; } } private function processMovement(){ $player = $this->sittingEntity; $nextDirection = null; $nextDirection = $player->getDirection(); $this->direction = $nextDirection; if($nextDirection !== -1){ $this->direction = $nextDirection; $moved = $this->checkForVertical($nextDirection); if(!$moved){ $nextMoveVector = $this->moveVector[$this->direction]; $nextMoveVector = $nextMoveVector->multiply($this->moveSpeed); $newVector = $this->add($nextMoveVector->x, $nextMoveVector->y, $nextMoveVector->z); $this->checkDirection($newVector); }else{ return true; } } } private function moveByVector(Vector3 $desiredPosition){ $dx = $desiredPosition->x - $this->x; $dy = $desiredPosition->y - $this->y; $dz = $desiredPosition->z - $this->z; $this->move($dx, $dy, $dz); } public function checkDirection($direction){ switch($direction){ case Vector3::SIDE_NORTH; $diff = $this->x - $this->getFloorX(); if ($diff !== 0 and $diff <= .5) { $dx = ($this->getFloorX() - .1) - $this->x; $this->move($dx, 0, 0); return true; } break; case Vector3::SIDE_SOUTH; $diff = $this->x - $this->getFloorX(); if ($diff !== 0 and $diff >= .5) { $dx = ($this->getFloorX() + 1) - $this->x; $this->move($dx, 0, 0); return true; } break; case Vector3::SIDE_EAST; $diff = $this->z - $this->getFloorZ(); if ($diff !== 0 and $diff <= .5) { $dz = ($this->getFloorZ() - .1) - $this->z; $this->move(0, 0, $dz); return true; } break; case Vector3::SIDE_WEST; $diff = $this->z - $this->getFloorZ(); if ($diff !== 0 and $diff >= .5) { $dz = ($this->getFloorZ() + 1) - $this->z; $this->move(0, 0, $dz); return true; } break; } return false; }
Use DATA_RIDER_SEAT_POSITION PHP: //new API$this->propertyManager->setVector3f(self::DATA_RIDER_SEAT_POSITION, new Vector3(0, 0.75, 0));//old API$entity->setDataProperty(self::DATA_RIDER_SEAT_POSITION, self::DATA_TYPE_VECTOR3F, [0, 0.75, 0]); You may need to play with the numbers a bit, maybe try -0.75.