Pathfinders for fake enderdragon?

Discussion in 'Spigot Plugin Development' started by Bolt, Jul 1, 2015.

  1. I'm trying to use pathfinders for a fake enderdragon class in order to make it stay put. How do I do this? I read that the enderdragon AI is significantly different from other mob AIs and so the usual method can't be applied. I also can't seem to find any goalfinders in the source.
     
  2. Serializator

    Supporter

    You can use the "NoAI" tag for this.
     
  3. How do I apply the NoAI tag codewise? All I've found were answers to doing it with minecraft commands.
     
  4. Why not override the 'g' method (in a custom class extending EntityDragon) and do nothing in the method?

    Code (Text):

    public void g(double d0, double d1, double d2) {
    }
     
    May or may not work.
     
  5. Because EnderDragons do not use the default entity ai. So it won't work.
     
    • Informative Informative x 1
  6. I found this bit of code. Will it work?
    Code (Text):
    public void freezeEntity(Entity en){
          net.minecraft.server.v1_8_R2.Entity nmsEn = ((CraftEntity) en).getHandle();
          NBTTagCompound compound = new NBTTagCompound();
          nmsEn.c(compound);
          compound.setByte("NoAI", (byte) 1);
          nmsEn.f(compound);
      }
     
  7. Why don't you try it?
     
    • Agree Agree x 2
  8. It works. Thanks! :D Might I ask another question though, how do I stop it from roaring? I've disabled its AI so it stops moving around but it still keeps roaring incessantly.
     
  9. Underneath the
    Code (Text):
    compound.setByte("NoAI", (byte) 1);
    add this line -
    Code (Text):
    compound.setByte("Silent", (byte) 1);
     
    • Winner Winner x 1
  10. I made this function to set entities compounds, use it!
    Code (Text):
      public static Entity setCompound(org.bukkit.entitiy.Entity entity, String name, boolean value) {
            Entity nms_ent = ((CraftEntity) entity).getHandle();
            NBTTagCompound compound = new NBTTagCompound();
            nms_ent.c(compound);
            compound.setByte(name, value ? (byte) 1 : 0);
            nms_ent.f(compound);
            return entity;
        }
     
    And here's a simple usage:
    Code (Text):
    public static Entity freeze(Entity entity) {
            setCompound(entity, "NoAI", true);
            setCompound(entity, "Silent", true);
            setCompound(entity, "Invulnerable", true);
            return entity;
        }