How to spawn a entity that doesnt move?

Discussion in 'Spigot Plugin Development' started by ShishKaBobz, Apr 26, 2017.

  1. Hello! I would to know how i can spawn a entity that doesn't move... Kinda like NPC's if someone can help that be great! Thanks
     
    • Like Like x 1
  2. This doesnt show how to Freeze a mob though :/
     
  3. WAS

    WAS

    You'll need to override the NMS methods.
     
  4. If you don't wanna change NMS pathfinding goals, you can always put the potioneffect slowness and put the amplifier to something like 10. That should freeze the mob (I used to do this).

    The best way is to use the pathfinding goals to remove the goals of following a player, etc, and make it stand still. Don't forget collision is a factor to freezing a mob, and the potioneffect won't do anything.
     
  5. setAI method in LivingEntity

    Sent from my Nexus 5 using Tapatalk
     
    • Agree Agree x 4
  6. Or save yourself some time and give it slowness with an everlasting duration
     
    • Agree Agree x 1
    • Optimistic Optimistic x 1
  7. noAI=true
     
    • Creative Creative x 1
  8. Well, to offer a complete solution, call this on your entity (not nms entity):

    entityObj.setAI(false);
     
  9. use a command block and NoAI: 1 XD
     
    • Funny Funny x 2
  10. This is for plugin dev, not in game code :p
     
    • Funny Funny x 1
  11. Simplest way is to give the entity a slowness potion effect with max duration and max amplifier. It will take _forever_ for it to move even one pixel. If you don't want players to be able to push it, teleport it back to where you want it on a repeating task.
     
  12. @1010bobIzCOOL What MC version are you coding this for? We're gonna need more info to provide an actual working solution, depending on your version.
     
  13. 3 ways:
    Remove all Pathfinders
    Use NMS to set No AI to 1 (I am unsure if there is a non NMS method for this in 1.9 and above as i use 1.8)
    Slowness and teleporting
     
  14. org.bukkit.entity.LivingEntity#setAI(false);
    no nms required.
     
  15. ooh! when was this added?
     
  16. a long time ago
     
  17. Round 1.9

    Sent from my Nexus 5 using Tapatalk
     
  18. BananaPuncher714

    Supporter

    You can still push the mob around even with their slowness and no AI. Teleporting them constantly may be a bit resource intensive, particularly if you have a lot of them. What you can do is make a mob ride on an invisible armor stand. Not sure if they look like they're sitting though.