Spawning a new horse with predefined attributes

Discussion in 'Plugin Development' started by Fl1pzta, Jul 15, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Fl1pzta

    Title says it all, but my reason for doing so is to teleport a player and put him back on his horse or other entities. So I suppose the real question is how do take an entity and spawn a new enitity with the old entities data.

    Code so far:
    Code:
        if(update == true){
            Player player = (Player)event.getVehicle().getPassenger();
            event.getVehicle().eject();
            Entity vehicle = event.getVehicle();
            event.getVehicle().remove();
            if(vehicle instanceof Horse){
                Entity newEntity = player.getWorld().spawnEntity(new Location(player.getWorld(),toLocX,player.getLocation().getY(),toLocZ), ((Horse)vehicle).getType());
                Horse horse = (Horse)newEntity;
                Horse oldHorse = (Horse)vehicle;
                horse.setAge(oldHorse.getAge());
                horse.setAgeLock(oldHorse.getAgeLock());
                //...
            }
            }
     
  2. Offline

    NoLiver92

    are you just trying to teleport a horse and a player to the same location? Or is there something wlse you are trying to do?
     
  3. Offline

    Fl1pzta

    Well yeah I'd like to do that, but isn't there an issue with teleporting vehicles? NoLiver92

    Herpderp: I'll cast horse to the vehicle and teleport the horse after I eject the player, Isn't there an issue with teleporting multiple entities at a time?
     
  4. Offline

    NoLiver92


    Ive created a horse teleport plugin for one of my servers i work on and the way i do it is:
    • get the player
    • get the horse the player is on as an entity
    • eject the player
    • teleport both the horse and player as entity's to a location
    this has been running for a few days (since 1.6.2 came out) and i have not had a problem with this even with 50 people using it.

    I believe there might be an error if the player is in the vehicle hence the ejection of the player then teleport them one by one
     
  5. Offline

    Fl1pzta

    Alright, I'm going to give that a try. Thanks! NoLiver92
     
Thread Status:
Not open for further replies.

Share This Page