Ir para conteúdo
  • 0

[Resolvido] CÓDIGO PARA A ENTITY NAO SE MOVER PLS!


Hemptt

Pergunta

6 respostass a esta questão

Posts Recomendados

Tire a Ai dela.

boolean ai = false;
nmsEntityHandle.getDataWatcher().watch(15, (byte) (ai ? 1 : 0));

// Exemplo:

Location loc = ...;
Villager e = loc.getWorld().spawn(loc, Villager.class);
CraftVillager v = (CraftVillager) e;
EntityVillager handle = ((CraftVillager) e).getHandle();

handle.getDataWatcher().watch(15, (byte) 1);

/* By

leonardosc

*/
Link para o comentário
Compartilhar em outros sites

 

Tire a Ai dela.

boolean ai = false;
nmsEntityHandle.getDataWatcher().watch(15, (byte) (ai ? 1 : 0));

// Exemplo:

Location loc = ...;
Villager e = loc.getWorld().spawn(loc, Villager.class);
CraftVillager v = (CraftVillager) e;
EntityVillager handle = ((CraftVillager) e).getHandle();

handle.getDataWatcher().watch(15, (byte) 1);

/* By

leonardosc

*/

Onde coloco isso?

 

package Menu;
 
 
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
 
 
public class Entity implements CommandExecutor, Listener{
 
String under = "§7Under§bMC §7» ";
 
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage(under + "§cVoce so pode executar o comando no servidor!");
return true;
}
Player p = (Player)sender;
if (cmd.getName().equalsIgnoreCase("geraldo")){
if(p.hasPermission("use.geraldo")){
Villager v = (Villager) p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
String nome = "§7Under§bMC §a» §7Geraldo§a!";
v.setCustomName(nome);
v.setCustomNameVisible(true);
p.sendMessage("§a» §7Você spawnou o geraldo!");
p.playSound(p.getLocation(), Sound.EXPLODE, 150F, 150F);
v.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100000, 7));
}else {
p.sendMessage("§c» §7Você nao tem permissao para usar esse comando!");
p.playSound(p.getLocation(), Sound.EXPLODE, 150F, 150F);
}
}
return false;
 
}
 
@EventHandler
public void Geraldao(PlayerInteractEntityEvent e){
Player p = e.getPlayer();
if(e.getRightClicked() instanceof Villager){
Villager villager = (Villager) e.getRightClicked();
if(villager.getCustomName().equalsIgnoreCase("§7Under§bMC §a» §7Geraldo§a!")){
p.chat("/menugeral");
p.playSound(p.getLocation(), Sound.EXPLODE, 150F, 150F);
e.setCancelled(true);
}
}
}
 
@EventHandler
public void Bot1_Dano(EntityDamageEvent e) {
if (e.getEntity() instanceof Villager) {
Villager villager = (Villager) e.getEntity();
if (villager.getCustomName().equalsIgnoreCase("§7Under§bMC §a» §7Geraldo§a!")) {
e.setCancelled(true);
}
}
}
}
 
Link para o comentário
Compartilhar em outros sites

 

Onde coloco isso?

package Menu;
 
 
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
 
 
public class Entity implements CommandExecutor, Listener{
 
String under = "§7Under§bMC §7» ";
 
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage(under + "§cVoce so pode executar o comando no servidor!");
return true;
}
Player p = (Player)sender;
if (cmd.getName().equalsIgnoreCase("geraldo")){
if(p.hasPermission("use.geraldo")){
Villager v = (Villager) p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
String nome = "§7Under§bMC §a» §7Geraldo§a!";
v.setCustomName(nome);
v.setCustomNameVisible(true);
p.sendMessage("§a» §7Você spawnou o geraldo!");
p.playSound(p.getLocation(), Sound.EXPLODE, 150F, 150F);
v.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100000, 7));
}else {
p.sendMessage("§c» §7Você nao tem permissao para usar esse comando!");
p.playSound(p.getLocation(), Sound.EXPLODE, 150F, 150F);
}
}
return false;
 
}
 
@EventHandler
public void Geraldao(PlayerInteractEntityEvent e){
Player p = e.getPlayer();
if(e.getRightClicked() instanceof Villager){
Villager villager = (Villager) e.getRightClicked();
if(villager.getCustomName().equalsIgnoreCase("§7Under§bMC §a» §7Geraldo§a!")){
p.chat("/menugeral");
p.playSound(p.getLocation(), Sound.EXPLODE, 150F, 150F);
e.setCancelled(true);
}
}
}
 
@EventHandler
public void Bot1_Dano(EntityDamageEvent e) {
if (e.getEntity() instanceof Villager) {
Villager villager = (Villager) e.getEntity();
if (villager.getCustomName().equalsIgnoreCase("§7Under§bMC §a» §7Geraldo§a!")) {
e.setCancelled(true);
}
}
}
}
 

E eu vou saber ?

 

Leia o código direito, rapaiz.

Editado por Cuthmf
Link para o comentário
Compartilhar em outros sites

<p style="text-align:center;"><img alt="logo-forum.png" src="http://www.gamersboard.com.br/logo-forum.png"/></p><br /></br><br /></br><br />Sua dúvida foi marcada como [Resolvido] e movido à área de dúvidas resolvidas.</br><br /></br><br /></br><br />Atenciosamente,</br><br />Gamer's Board</br>

Link para o comentário
Compartilhar em outros sites

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