Ir para conteúdo
  • 0

DUVIDA NPC


Wanderson Luis

Pergunta

7 respostass a esta questão

Posts Recomendados

Para criar o npc use



Villager npc = (Villager)p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
npc.setAdult();
npc.setProfession(Villager.Profession.PRIEST);
npc.setCustomName("NOME");
npc.setCustomNameVisible(false);
npc.setCanPickupItems(false);
NoAIUtils.noAI((Entity)npc);
p.sendMessage("§aAldeão criado com sucesso!");
return true;

Para setar um comando no villager use



@EventHandler
public void aoInteragir(PlayerInteractEntityEvent e) {
if (e.getRightClicked() instanceof Villager) {
Villager npc = (Villager) e.getRightClicked();
Player p = e.getPlayer();
if (npc.getCustomName() == null) {
return;
}
if (npc.getCustomName().equals("NOME DO VILLAGER")) {
}
}
}

Para fazer ele ficar parado use isso quando for spawnar ele, seta o noAI nele



public static void noAI(final Entity bukkitEntity) {
final net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity)bukkitEntity).getHandle();
NBTTagCompound tag = nmsEntity.getNBTTag();
if (tag == null) {
tag = new NBTTagCompound();
}
nmsEntity.c(tag);
tag.setInt("NoAI", 1);
nmsEntity.f(tag);
}

Para ele não levar dano use



@EventHandler
public void aoDarDano(EntityDamageByEntityEvent e) {
if (!(e.getEntity() instanceof Villager)) {
return;
}
Villager npc = (Villager) e.getEntity();
if (e.getEntity() instanceof Villager) {
if (npc.getCustomName() == null) {
return;
}
if (npc.getCustomName().equals("§r§r§a")) {
if (e.getDamager() instanceof Player) {
Player p = (Player) e.getDamager();
if (p.hasPermission("admin.usar")) {
if (p.getItemInHand().getType() == Material.GOLD_SWORD) {
npc.setHealth(0.0);
} else {
e.setCancelled(true);
}
} else {
e.setCancelled(true);
}
}
}
}
}
Link para o comentário
Compartilhar em outros sites

 

Alguem poderia me encinar como posso spawnar um vilager , colocar um comando nele, ele setar pra ele nao levar dano e mexer etc? Sem usar outro plugin nem api somente em java se alguem souber e puder falar agradaço <3 

 

 

Acho que sem um plugin isso não é possivel.

Link para o comentário
Compartilhar em outros sites

 

Para criar o npc use

				   Villager npc = (Villager)p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
			            npc.setAdult();
			            npc.setProfession(Villager.Profession.PRIEST);
			            npc.setCustomName("NOME");
			            npc.setCustomNameVisible(false);
			            npc.setCanPickupItems(false);
			            NoAIUtils.noAI((Entity)npc);
			            p.sendMessage("§aAldeão criado com sucesso!");
			            return true;

Para setar um comando no villager use

	@EventHandler
	public void aoInteragir(PlayerInteractEntityEvent e) {
		if (e.getRightClicked() instanceof Villager) {
			Villager npc = (Villager) e.getRightClicked();
			Player p = e.getPlayer();
			if (npc.getCustomName() == null) {
				return;
			}
			if (npc.getCustomName().equals("NOME DO VILLAGER")) {
			}
		}
	}

Para fazer ele ficar parado use isso quando for spawnar ele, seta o noAI nele

	public static void noAI(final Entity bukkitEntity) {
        final net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity)bukkitEntity).getHandle();
        NBTTagCompound tag = nmsEntity.getNBTTag();
        if (tag == null) {
            tag = new NBTTagCompound();
        }
        nmsEntity.c(tag);
        tag.setInt("NoAI", 1);
        nmsEntity.f(tag);
    }

Para ele não levar dano use

	@EventHandler
	public void aoDarDano(EntityDamageByEntityEvent e) {
		if (!(e.getEntity() instanceof Villager)) {
			return;
		}
		Villager npc = (Villager) e.getEntity();
		if (e.getEntity() instanceof Villager) {
			if (npc.getCustomName() == null) {
				return;
			}
			if (npc.getCustomName().equals("§r§r§a")) {
				if (e.getDamager() instanceof Player) {
					Player p = (Player) e.getDamager();
					if (p.hasPermission("admin.usar")) {
						if (p.getItemInHand().getType() == Material.GOLD_SWORD) {
							npc.setHealth(0.0);
						} else {
							e.setCancelled(true);
						}
					} else {
						e.setCancelled(true);
					}
				}
			}
		}
	}

Vlw :D 

Link para o comentário
Compartilhar em outros sites

 

Para criar o npc use

				   Villager npc = (Villager)p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
			            npc.setAdult();
			            npc.setProfession(Villager.Profession.PRIEST);
			            npc.setCustomName("NOME");
			            npc.setCustomNameVisible(false);
			            npc.setCanPickupItems(false);
			            NoAIUtils.noAI((Entity)npc);
			            p.sendMessage("§aAldeão criado com sucesso!");
			            return true;

Para setar um comando no villager use

	@EventHandler
	public void aoInteragir(PlayerInteractEntityEvent e) {
		if (e.getRightClicked() instanceof Villager) {
			Villager npc = (Villager) e.getRightClicked();
			Player p = e.getPlayer();
			if (npc.getCustomName() == null) {
				return;
			}
			if (npc.getCustomName().equals("NOME DO VILLAGER")) {
			}
		}
	}

Para fazer ele ficar parado use isso quando for spawnar ele, seta o noAI nele

	public static void noAI(final Entity bukkitEntity) {
        final net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity)bukkitEntity).getHandle();
        NBTTagCompound tag = nmsEntity.getNBTTag();
        if (tag == null) {
            tag = new NBTTagCompound();
        }
        nmsEntity.c(tag);
        tag.setInt("NoAI", 1);
        nmsEntity.f(tag);
    }

Para ele não levar dano use

	@EventHandler
	public void aoDarDano(EntityDamageByEntityEvent e) {
		if (!(e.getEntity() instanceof Villager)) {
			return;
		}
		Villager npc = (Villager) e.getEntity();
		if (e.getEntity() instanceof Villager) {
			if (npc.getCustomName() == null) {
				return;
			}
			if (npc.getCustomName().equals("§r§r§a")) {
				if (e.getDamager() instanceof Player) {
					Player p = (Player) e.getDamager();
					if (p.hasPermission("admin.usar")) {
						if (p.getItemInHand().getType() == Material.GOLD_SWORD) {
							npc.setHealth(0.0);
						} else {
							e.setCancelled(true);
						}
					} else {
						e.setCancelled(true);
					}
				}
			}
		}
	}

full THG ahusahusa

 

mas boa

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...