1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Minecart bug

Discussion in 'Development' started by Kyd, Jan 19, 2018.

  1. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    When I do updateMovement() to Minecart entity, then it looks like this:
    upload_2018-1-19_19-22-20.png
    How can I fix it?
    I'm doing only updateMovement() and nothing else.
     
  2. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    lmaaaaao :eek: just another day for a developer :mad:.. hahahah
     
    Last edited: Jan 19, 2018
  3. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Please don't tell me that no one help me again :eek::eek::eek::eek::eek::eek::eek::oops::(:(:(:(:(
     
    LewBr likes this.
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Set yaw and pitch of the minecart to 0
     
  5. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    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:
    upload_2018-1-19_22-42-26.png
    Minecart class:
    PHP:
    $this->moveVector[2] = new Vector3(-100);
    $this->moveVector[0] = new Vector3(100);
    $this->moveVector[3] = new Vector3(00, -1);
    $this->moveVector[1] = new Vector3(001);

    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->$this->x;
            
    $dy $desiredPosition->$this->y;
            
    $dz $desiredPosition->$this->z;
            
    $this->move($dx$dy$dz);
        }

        public function 
    checkDirection($direction){
            switch(
    $direction){
                case 
    Vector3::SIDE_NORTH;
                
    $diff $this->$this->getFloorX();
                if (
    $diff !== and $diff <= .5) {
                        
    $dx = ($this->getFloorX() - .1) - $this->x;
                        
    $this->move($dx00);
                        return 
    true;
                 }
                 break;
                 case 
    Vector3::SIDE_SOUTH;
                  
    $diff $this->$this->getFloorX();
                        if (
    $diff !== and $diff >= .5) {
                          
    $dx = ($this->getFloorX() + 1) - $this->x;
                         
    $this->move($dx00);
                       return 
    true;
                  }
                  break;
                  case  
    Vector3::SIDE_EAST;
                            
    $diff $this->$this->getFloorZ();
                            if (
    $diff !== and $diff <= .5) {
                                
    $dz = ($this->getFloorZ() - .1) - $this->z;
                                
    $this->move(00$dz);
                                return 
    true;
                            }
                            break;
                  case 
    Vector3::SIDE_WEST;
                        
    $diff $this->$this->getFloorZ();
                        if (
    $diff !== and $diff >= .5) {
                        
    $dz = ($this->getFloorZ() + 1) - $this->z;
                        
    $this->move(00$dz);
                        return 
    true;
                  }
                  break;
            }
            return 
    false;
        }
     
  6. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Use DATA_RIDER_SEAT_POSITION
    PHP:
    //new API
    $this->propertyManager->setVector3f(self::DATA_RIDER_SEAT_POSITION, new Vector3(00.750));

    //old API
    $entity->setDataProperty(self::DATA_RIDER_SEAT_POSITIONself::DATA_TYPE_VECTOR3F, [00.750]);
    You may need to play with the numbers a bit, maybe try -0.75.
     
  7. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Thank you!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.