set Yaw of a Villager

Discussion in 'Spigot Plugin Development' started by TomDev, Apr 17, 2017.

  1. Hi , I want to create a Daily rewads Villager , but I have a problem

    Code :

    Code (Text):
            Entity ent = Bukkit.getWorlds().get(0).spawnEntity(new Location(Bukkit.getWorlds().get(0),1168.5,39,84.5), EntityType.VILLAGER);
            Location loc = ent.getLocation();
            loc.setYaw(140);
            loc.setPitch(2);
            ent.teleport(loc);

            EntityVillager nmsEnt = ((CraftVillager) ent).getHandle();
            if(nmsEnt.getNBTTag() == null){
                NBTTagCompound nbt = new NBTTagCompound();
                nbt.setBoolean("NoAI", true);
                nmsEnt.a(nbt);
            }
            ent.setCustomName("§cRécompense journalière");
            ent.setCustomNameVisible(true);
    Error : No error but the yaw and pitch of the pnj wasn't set