Solved Entity teleport between worlds

Discussion in 'Plugin Development' started by NemesisMate, Aug 27, 2013.

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

    NemesisMate

    I woul like to teleport an Entity to other worlds but it doesn't work, my code is like:

    Code:java
    1. Entity entity;
    2.  
    3. Location loc;
    4.  
    5. .......
    6.  
    7. /*if(!loc.getChunk().isLoaded())
    8.  
    9. loc.getChunk().load();*/
    10.  
    11. entity.teleport(loc)


    It works fine if the teleport is on the same world but not on different ones.
     
  2. Offline

    etaxi341

    NemesisMate You could delete the Entity in this World and create in the other world a new Entity. Just save the Entity and spawn the saved one in the new World.
     
  3. Offline

    NemesisMate

    I need to spawn an exact copy of that entity and I don't know how (I would like to teleport player's horses).
     
  4. Offline

    etaxi341

    NemesisMate I think you can just store an "Entity" and then spawn the stored Entity.
    entity.remove();
    entity... (I am not sure what the method for entity spawning is but if you want i can look for it)
     
  5. Offline

    NemesisMate

    etaxi341

    I know about entity.remove(), but not about that one to spawn the exact entity I removed :S, I tried to find it but I can't find so if you could I would be really pleased.
     
  6. Offline

    etaxi341

    NemesisMate Ohh... I looked at it... it isn't as easy as I thought... sry :( You need to do world.spawnEntity(location, EntityType);
    and then set the name of the mob again to the same and the health and ... :)
     
  7. Offline

    NemesisMate

    etaxi341

    Just like I suppose, that is why I was asking for an easier way, whatever thanks for your help.

    etaxi341
    Maybe do you know how to copy all horse stats?, so I can spawn a new one and transform on the other?.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  8. Offline

    etaxi341

    NemesisMate Look into the Horses class and see what datas about horses get saved in this class. Then you just need to get every data about the horse and reaply it to the new Horse.
     
  9. Offline

    NemesisMate

    etaxi341
    Ok, the copy is being done right but the player see as if the horse wasn't domesticated and don't see it saddle, if disconect and reconect then is well seen so It is really doing it well but the player couldn't apreciate it, is there a way to update it so the player see it right?.
     
  10. Offline

    etaxi341

    NemesisMate So if the player relogs he sees the saddle? I haven't seen any entity.update() Method or something like that. Maybe it is a Bukkit-side bug. But I think I can't help you in this issue. Maybe someone knows it and posts it in this Thread :) This would be nice :). But I am sorry. I wasn't really helpfull in this Thread :D
     
  11. Offline

    NemesisMate

    etaxi341

    Yes, the saddle is there and the horse is domesticated but the player couldn't see it till the he relogs, :S, If if find a way to update it I'll post it here.

    etaxi341
    I found a way to see the saddle, setting the saddle to a saddle when copying all data but that bugs the horse and after this there is no way to open it inventory without mattering if restarting the server.

    Getting the same if setting the armor instead the saddle.

    Ok, I missed setting it tamed, once is tamed the bug of seen is fixed with setting saddle or armor.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
Thread Status:
Not open for further replies.

Share This Page