Resource Remove AI from an entity

Discussion in 'Spigot Plugin Development' started by alexhackers, Jun 6, 2017.

  1. Spigot 1.8+

    Code (Text):
    public static void setAI(LivingEntity entity, boolean hasAi) {
      EntityLiving handle = ((CraftLivingEntity) entity).getHandle();
      handle.getDataWatcher().watch(15, (byte) (hasAi ? 0 : 1));

    // Exemplo:
    Location loc = null;// Localizacao
    Villager villager = loc.getWorld().spawn(loc, Villager.class);
    setAI(villager, false);
    Spigot 1.8+ Other method

    Code (Text):
    void noAI(Entity bukkitEntity) {
        net.minecraft.server.v1_8_R1.Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
        NBTTagCompound tag = nmsEntity.getNBTTag();
        if (tag == null) {
            tag = new NBTTagCompound();
        tag.setInt("NoAI", 1);
    Spigot 1.9+

    • Like Like x 3
    • Useful Useful x 3
  2. What's the point of this?
    • Funny Funny x 2
  3. Change AI of entity, will stay
  4. There are already way too many threads about this, that tell people more about what they're doing than this does. Also you even link out to the javadocs for 1.9 and above. We're at 1.11.2, the code that you provide is obsolete
    • Funny Funny x 1
  5. It's not obsolete because of the version, because people such as myself use 1.8, however this is repeated multiple times on this forum. No need for it. You keep posting resources, why? Youve posted like 4 or so (that Ive seen) small resources that serve almost no purpose, or are developed using poor conventions.