Solved [1.7-1.8]Need help using NoAI tag

Discussion in 'Spigot Plugin Development' started by LelouBil, Jun 27, 2018.

  1. Hey, I'm making a plugin for a 1.8 server using ViaVersion + ViaRewind so that 1.7+ players can join.

    I need to make villagers unpushable and with no AI.
    I used the NoAI nbt tag like this :
    Code (Text):

    private void disableAI(Entity entity) {
        net.minecraft.server.v1_8_R3.Entity nmsEnt = ((CraftEntity) entity).getHandle();
        NBTTagCompound tag = nmsEnt.getNBTTag();

        if(tag == null) {
            tag = new NBTTagCompound();

        tag.setInt("NoAI", 1);
    And it works for 1.8+ players, but 1.7 push the entities really far on their screens and it's really annoying.
  2. Maybe the NoAI tag is not supported by 1.7 clients and it's causing them to do strange things? You might need to stop that NBT tag being added to entities for 1.7 connections (assuming it's sent in the first place).

    I have to say using 1.8 is bad enough but allowing 1.7 clients?! Why!
  3. Yeah, but I need to allow them.
    But then, do you have a method to simulate the tag with nms that would work for 1.8 and 1.7 ?
  4. Try giving the entity slowness with a very high potency and then cancelling their target event? I think this is the closest thing you will get from such an old version :)
    • Agree Agree x 1
  5. No. If a feature does not exist in a client there is nothing the sever can do about it*.

    *Unless it can mimic the feature using the existing capabilities of the client, which is not the case here for the "NoAI tag".
  6. I have found this:
    It's a class that uses NMS and extends the Villager. It clears their pathfinding goals and sets new one, just keep track of the villagers and handle them properly.
  7. You could try to remove the pathfinder goals and the collision AI, instead of changing the no AI tag
  8. Which is not the same thing as the OP is asking about with using the "NoAI" tag. It might be that there are alternatives solutions which allow the OP to achieve what they want, I can't comment on that as I've not looked into it myself (especially as 1.7 and 1.8 are so old).
  9. The OP is using the NoAI tag correctly and isn't getting the results they want, I was simply suggesting something which could help them.
  10. I think that NoAI affect only the entity on the server, not on the client. Try to set the NoAI tag with /entitydata command and see if the bug is in your code or in the NoAI tag
  11. Also you realise that "net.minecraft.server.v1_8_R3" is 1.8 dependent right?
  12. @LelouBil 1.8_R3 is 1.8.3+ I would recommend looking into reflection or NMS conversion classes.
    • Winner Winner x 1
  13. The NoAI Tag did not exist in 1.7.10 and earlier. ViaRewind currently removes/ignores this tag for 1.7.x clients. Try updating the position and setting the velocity to 0 every tick, this should stop the entity from flying away on 1.7.x.
    You will need to send the packets yourself to do so.
    You can use the ViaVersion API to send the packets only to 1.7.x clients.
    • Useful Useful x 1