Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.lisenochek.ftfiches.NPC;
- import net.minecraft.server.v1_8_R3.NBTTagCompound;
- import org.bukkit.Location;
- import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.Villager;
- import ru.lisenochek.ftfiches.utils.C;
- public class CreatorNPC {
- public static void createNPC(Location loc, String age, String name) {
- Villager ent = (Villager) loc.getWorld().spawn(loc, Villager.class);
- ent.setCustomNameVisible(true);
- ent.setCustomName(C.c(name));
- ent.setMaximumNoDamageTicks(Integer.MAX_VALUE);
- disableAI(ent);
- if (age.equalsIgnoreCase("baby")) return;
- ent.setBaby();
- ent.setAgeLock(true);
- }
- private static void disableAI(Entity ent) {
- net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) ent).getHandle();
- NBTTagCompound tag = nmsEntity.getNBTTag();
- if (tag == null) tag = new NBTTagCompound();
- nmsEntity.c(tag);
- tag.setInt("NoAI", 1);
- nmsEntity.f(tag);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement