Ir para conteúdo
  • 0

[Resolvido] Ajuda?


DaviDEV

Pergunta

Estou fazendo um pl de splegg porém estou com um erro

já fiz o sistema de pá soltar ovo main estou tendo problemas porque a galinha ta nascendo, olha o metodo

package dSplegg.Listener;

import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.util.BlockIterator;

public class ListenerJogo implements Listener {
	@SuppressWarnings("deprecation")
	@EventHandler
	public void eggLand(ProjectileHitEvent e)
	{
		if (((e.getEntity().getShooter() instanceof Player)) && 
				((e.getEntity() instanceof Egg)))
		{
			BlockIterator bi = new BlockIterator(e.getEntity().getWorld(), e.getEntity().getLocation().toVector(), e.getEntity().getVelocity().normalize(), 0.0D, 4);
			Block hit = null;
			while (bi.hasNext())
			{
				hit = bi.next();
				if (hit.getTypeId() != 0) {
					break;
				}
				hit.setTypeId(0);
				if (hit.getType() == Material.TNT)
				{
					e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 3.0F);
				}
			}
		}
	}
}

Link para o comentário
Compartilhar em outros sites

7 respostass a esta questão

Posts Recomendados

 @EventHandler
    public void onCreatureSpawn(CreatureSpawnEvent event)
    {
        if (event.getSpawnReason() == SpawnReason.EGG)
        {
            event.setCancelled(true);
        }
    }

achei no google testa ai.

 

mais como faço para ele quebrar o bloco de onde o ovo chega

Link para o comentário
Compartilhar em outros sites

mais como faço para ele quebrar o bloco de onde o ovo chega

@EventHandler
    public void onEggHit(ProjectileHitEvent e) {
        Entity en = e.getEntity();
        if(en instanceof Egg) {   
            en.getLocation().getBlock().setType(Material.AIR);
    }
}
}

achei no google tbm e-e testa ai.

Link para o comentário
Compartilhar em outros sites

@EventHandler
    public void onEggHit(ProjectileHitEvent e) {
        Entity en = e.getEntity();
        if(en instanceof Egg) {   
            en.getLocation().getBlock().setType(Material.AIR);
    }
}
}

achei no google tbm e-e testa ai.

 

Não foi, eu uso esse cod para lançar o ovo séra que é ele:

 

@EventHandler
public void aoInteragir(PlayerInteractEvent e)
{
Player p  =e.getPlayer();
ItemStack hand = p.getItemInHand();
if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR)
{
if (hand.getType() == Material.WOOD_SPADE)
{
p.launchProjectile(Egg.class);
p.playSound(p.getLocation(), Sound.CHICKEN_EGG_POP, 1.0F, 1.0F);
}
if (hand.getType() == Material.STONE_SPADE)
{
for (int i = 0; i<2; i+=1)
{
p.launchProjectile(Egg.class);
}
p.playSound(p.getLocation(), Sound.CHICKEN_EGG_POP, 1.0F, 1.0F);
}
}
}
Link para o comentário
Compartilhar em outros sites

 

Não foi, eu uso esse cod para lançar o ovo séra que é ele:

 

@EventHandler
public void aoInteragir(PlayerInteractEvent e)
{
Player p  =e.getPlayer();
ItemStack hand = p.getItemInHand();
if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR)
{
if (hand.getType() == Material.WOOD_SPADE)
{
p.launchProjectile(Egg.class);
p.playSound(p.getLocation(), Sound.CHICKEN_EGG_POP, 1.0F, 1.0F);
}
if (hand.getType() == Material.STONE_SPADE)
{
for (int i = 0; i<2; i+=1)
{
p.launchProjectile(Egg.class);
}
p.playSound(p.getLocation(), Sound.CHICKEN_EGG_POP, 1.0F, 1.0F);
}
}
}

 

Sei la eu nao manjo java mais eu tento ajudar e-e agora o negocio e esperar os devs .

Link para o comentário
Compartilhar em outros sites

Consegui galerin
Pra quem quiser o cod:
 

@SuppressWarnings("deprecation")
@EventHandler
public void onEggHit(ProjectileHitEvent e) {
Entity en = e.getEntity();
if(en instanceof Egg) {   
BlockIterator bi = new BlockIterator(e.getEntity().getWorld(), e.getEntity().getLocation().toVector(), e.getEntity().getVelocity().normalize(), 0.0D, 4);
Block hit = null;
while (bi.hasNext())
{
hit = bi.next();
if (hit.getTypeId() != 0) {
break;
}
}
hit.setType(Material.AIR);
en.getLocation().getBlock().setType(Material.AIR);
}
}
}
Link para o comentário
Compartilhar em outros sites

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