Blocking Entity Movement

Discussion in 'Plugin Development' started by TheDiamond06, Dec 24, 2018.

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

    TheDiamond06

    I have been trying to create villagers that are going to be used for player interaction via some sort of quest system. However how would you be able to completely turn off the AI of villagers so they don't walk around. Sure you can give them slowness 1000 or something like that but they can still be pushed and I don't think that is what servers who actually use this type of thing use. Is to trick them into being "trapped" so they don't move and can't be pushed by other players. You can use barrier blocks but that wouldn't work so well because the players would need to actually interact with them and move by them. Is there some sort of invisible block that you can use where the villager AI would be "turned off" and not be able to be pushed through while players still can.

    Or is there some other way to do this?

    So far I've tried just teleporting the villager to the location I want it to be at (static location) every second and every tick but that poses problems even with every tick as the villager still moves with it's AI pretty far and is not that optimized of a method. I could combine that with the slowness but then players could still push the villager (not that far) but not something I want and it would still be unoptimized because it would be teleporting all the static villagers every tick (there will be quite a lot)

    Thanks
     
    Last edited: Dec 24, 2018
  2. Changing the behaviour of a creature would require the use of NMS (NetMinecraftServer). The 'issue' with this, is that you would be required to update your plugin every single time you want to update your plugin to a newer version of Spigot, as the fields declared in the NMS Classes have randomly generated names, so they will be different with every update.

    But other than that, it gets the job done just fine. It's just a case of if you want to be that dedicated to your plugin.
     
Thread Status:
Not open for further replies.

Share This Page