1.15.2 1.15 Mob riding?

Discussion in 'Spigot Plugin Development' started by hidden1nin, Feb 15, 2020.

  1. I am trying to make passive mobs ridable and i was following a tutorial https://bukkit.org/threads/tutorial-1-7-5-wasd-entity-riding.163019/ and i believe that since it was made for 1.7 ( a version from over 5 years ago) it isnt accurate for 1.15, could someone help me make passive mobs ridable without making a seperate class for each mob?
     
    • Agree Agree x 1
  2. Well, put the player to ride the mob and store its UUID and the mob somewhere, then have a repeating task that will go throw all the UUIDs and will get the player direction and move the entity in that way
    A Map will work perfectly
     
  3. That's smart, do you know how I would detect if a player wants to stay still or go in reverse?
     
  4. Maybe you can make that when the player hits the mob starts walking and then it hits again it stops
     
  5. I'm still very confused on creating a class, what do I need to extend, as it keeps telling me that the e function needs to return int
     
    • Optimistic Optimistic x 1
  6. Fixed mounting rotating but i cant seem to get it to move forward, i tried multipling velocity but im unusre how to do it.
     
  7. Thank you all for your help I eventually found It out and instead of hitting, I made it work like a carrot on a stick would, where the mobs only move when holding the stick
     
  8. Also, I didn't save any data, I just looked through all players to see if they are a passenger and if so then if they have a certain item, this would be bad for larger servers but my server has never had more than 10 people on it
     
  9. Thanks for everyones support i finished mob riding a few days ago! what i did was if you click a mob hile holding a certain item, you become a passenger of said mob, then the mob matches your yaw and pitch in a runnable, with also makes the mob walk when said item is held.
     
  10. Can you tell me the code? plz...
    There is a problem moving the entity.
     
  11. O of course! here you go

    Code (Java):
    @Override
        public void run() {

            for(Player p:Bukkit.getOnlinePlayers()){
            if(p.isInsideVehicle()&&p.getVehicle() instanceof Horse== false) {
                Entity v = p.getVehicle();
                p.setFallDistance(0);//stops fall damage
                if(v instanceof Player) {return;}
                v.setRotation(p.getLocation().getYaw(),p.getLocation().getPitch());
                if(p.getInventory().getItemInMainHand()==null) {return;}
                if(p.getInventory().getItemInMainHand().getItemMeta()==null) {return;}
                if(p.getInventory().getItemInMainHand().getType==Material.SADDLE){//checks to see if they are holding item
             
                    Vector current_velocity = p.getVelocity();
                    Vector walk_velocity = p.getLocation().getDirection().multiply(1.15);//propels them forward
                    walk_velocity.setY(current_velocity.getY());//stops the mob from flying, remove this line to allow mob flight
                    v.setVelocity(current_velocity.add(walk_velocity));//sets velocity
                   //Code by hidden1nin
                }

        }}
            }
     
  12. please don't just copy paste that though, take some time to try and understand whats happening
    Also feel free to critique that and give me suggestions, im sure it could be alot cleaner!
     
    • Agree Agree x 1
  13. It is a good idea to learn Java before you try to write code in it. You also cannot write a book when you do not know how to write letters.
     
  14. Was that directed towards me? i never specifically learned java, i just scrounge what i can learn and throw it all together
     
  15. Yes.
    I see.
     
  16. Thank you for showing the code. I understand all the code
    But I want to move the entity using w, a, s, d. Therefore, you need to find a way. Thank you
     
    #20 songsehen, Feb 23, 2020
    Last edited: Feb 23, 2020
    • Optimistic Optimistic x 1