1.15.2 Teleporting or removing far entities not working

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

  1. Hi,
    I'm trying to find a way to teleport an entity. I tried also using the functions on the NMS classes but it doesn't work. I tried to find some posts but no one of them works for me. The other alternative that I found is about remove the entity that I want to teleport, before that, create a new one and put everything from the old one to the new one. This worked, but not completely. I can create the new entity and get the data from the old one to modify, but I can't remove the old one, so when I teleport back to the other entity location, it's still there. Is there a way to make it work?
  2. What exactly are you trying to accomplish? Teleporting to an entity that is very far away?
  3. Yes. The entity can stay where you are but you can call it when you are far away, the thing is, if the distance is really high, you can't teleport it to you. The only thing I found is that the Entity gives false when you use isValid(), but after this I don't know how to delete this invalid entity.
  4. Likely a result of the chunk the entity is in not being loaded. You can't do much with an entity in an unloaded chunk, but you can add a plugin chunk ticket that will keep it loaded until removed.
  5. At the end I could find it, anyway thank you. The chunk is always enabled, I already check it in the old entity instance, but the problem is the entity. When nobody is close, I think Spigot disables or unloads the entity, making it invalid. I used this post, that gets all the chunk's entities and checks which one is the correct entity. If that's true, I think that also enabling the chunk or preventing it's unload, is not gonna work.
  6. Actually just discovered this method in the Entity interface, which sounds much more relevant to what you're experiencing.