Advertisement
Lisenochek

Untitled

Dec 15th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. package ru.lisenochek.ftfiches.NPC;
  2.  
  3. import net.minecraft.server.v1_8_R3.NBTTagCompound;
  4. import org.bukkit.Location;
  5. import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
  6. import org.bukkit.entity.Entity;
  7. import org.bukkit.entity.Villager;
  8. import ru.lisenochek.ftfiches.utils.C;
  9.  
  10. public class CreatorNPC {
  11.  
  12. public static void createNPC(Location loc, String age, String name) {
  13.  
  14. Villager ent = (Villager) loc.getWorld().spawn(loc, Villager.class);
  15.  
  16. ent.setCustomNameVisible(true);
  17. ent.setCustomName(C.c(name));
  18.  
  19. ent.setMaximumNoDamageTicks(Integer.MAX_VALUE);
  20.  
  21. disableAI(ent);
  22.  
  23. if (age.equalsIgnoreCase("baby")) return;
  24. ent.setBaby();
  25. ent.setAgeLock(true);
  26. }
  27.  
  28. private static void disableAI(Entity ent) {
  29.  
  30. net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) ent).getHandle();
  31. NBTTagCompound tag = nmsEntity.getNBTTag();
  32.  
  33. if (tag == null) tag = new NBTTagCompound();
  34.  
  35. nmsEntity.c(tag);
  36. tag.setInt("NoAI", 1);
  37. nmsEntity.f(tag);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement