Egg Glitching

Discussion in 'Plugin Development' started by PieMan456, Dec 11, 2013.

Thread Status:
Not open for further replies.
  1. Offline


    Hello Everyone,

    I am getting a strange glitch. I am making a grenade plugin that when you throw an egg with the name Grenade it shoots an egg and makes an explosion where it lands. Except if I right click a block with nothing in my hand after I shoot it it shoots another egg. Why is this happening? Here is how I shoot the egg: (This is inside PlayerInteractEvent)
    1. Vector v1 = e.getPlayer().getEyeLocation().getDirection().multiply(2.0);
    2. if (e.getPlayer().getItemInHand().getType() != Material.EGG)
    3. return;
    4. if (e.getAction() == Action.RIGHT_CLICK_AIR) {
    5. if (e.getPlayer().getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GREEN + "Grenade")) {
    6. e.setCancelled(true);
    7. Egg egg =e.getPlayer().getWorld().spawn(e.getPlayer().getEyeLocation().add(v1.getX(), v1.getY(), v1.getZ()), Egg.class);
    8. egg.setMetadata("grenade", new FixedMetadataValue(this, true));
    9. egg.setVelocity(v1);
    10. bob.add(e.getPlayer().getName());
    11. return;
    12. }
    13. }

Thread Status:
Not open for further replies.

Share This Page