NoAI Method

Discussion in 'Spigot Plugin Development' started by Just_Jitse, May 17, 2016.

  1. Hello everyone :)

    Is there already someone who has made a NoAI Method for v1_9_R2?
    Because the old NTB Tag "NoAI" from 1.8 doesn't really work anymore :/

    I already had a look in the nms entity class but I wasn't able to get anything working.
    I thought I read something about a motion tag and setting that, but I don't know xD

    Any help is welcome!
  2. Could just use the setAI(boolean) method in LivingEntity. Depending on what you're doing this may/may not be helpful to you.

    EDIT: In the past I have also used packets to set AI. This might be an option if you know the entity id
    #2 Kloudy, May 17, 2016
    Last edited: May 17, 2016
    • Agree Agree x 1
  3. It doesn't really work for me ._.
  4. What's that even supposed to mean? What doesn't work?
    • Agree Agree x 1
  5. What are you doing to set the NBT tag on the NMS entity? I know things changed for that in 1.9, but in my case I'll need more information to be able to help you.
  6. You will need to explain more about what it is your are actually trying to accomplish, and what about the LivingEntity#setAI(boolean) method is not working for you?
  7. Okay so what I am trying to do is make CommandNPCs, so spawn a mod which cannot move and cannot be collided. But somehow, when I try to use the #setAI(boolean) the mob won't move by itself but it is still pushable :/
  8. Try the LivingEntity#setCollidable(boolean) method.
  9. tried it, doesn't work
    • Informative Informative x 2
  11. @qlimax5000 So what I have done is set the collidable to false of the player on join and the mob spawned also has got collision disabled, but it's still collidable.

    edit: it was not working because I reloaded the server, dangit! Working now.
  12. Could you post some of you code?
  13. It's easy use this ^^
  14. Code (Text):
    private void disableAI(Entity entity) {
        net.minecraft.server.v1_8_R1.Entity nmsEnt = ((CraftEntity) entity).getHandle();
        NBTTagCompound tag = nmsEnt.getNBTTag();
        if(tag == null) {
            tag = new NBTTagCompound();
        tag.setInt("NoAI", 1);
  15. sorry i have miss the code ^^
  16. I have just tested this in 1.9.2 it's ok ^^
  17. Could you not spam post?
    • Agree Agree x 1
  18. sorry ^^