Solved How to remove an entity from a world but keep it alive?

Discussion in 'Plugin Development' started by critikull, Sep 13, 2017.

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

    critikull

    I'm trying to remove an entity from a world temporarily and add it back at a later time.

    The issue is that world.removeEntity(entity) will kill the entity on the next tick so when I call world.addEntity(entity) the entity does not appear.

    I notice that the Entity class uses a similar technique to move an entity across worlds/dimensions:

    Code:
    this.world.removeEntity(this);
    this.isDead = false;
    But isDead is private to the Entity class so I am unable to do this.

    Is there any other way (other than moving it to 20000,200000,200000)?
     
  2. @critikull
    Well, why do you need to?

    You can teleport entities just as you please like to move them around.
     
  3. Offline

    critikull

    I have a custom entity that transforms into different forms (zombie, sheep, etc.), instead of creating new entities each time it transforms I'd like to save the entity to be used when it transforms at a later time. This allows me to keep the state of that entity and its UUID.
     
  4. @critikull
    Right. Is this entity managed using NMS? If it is, it may be feasible to do it this way, but if it is not managed via NMS, I think you're just better off spawning entirely new entities.

    Also, what 'isDead' field are you talking about? The only field I see regarding the entitys removed state in the Entity class is 'dead', and that is public.
     
  5. Offline

    critikull

    @AlvinB
    Yes, the entities are managed using NMS. Arg, I was referencing the wrong minecraft source.. this.dead = false exists and is working. Doh..... Thank you for the help!
     
Thread Status:
Not open for further replies.

Share This Page