GunZ

Discussion in 'Plugin Development' started by Deckerz, Feb 21, 2013.

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

    Deckerz

    Hey i am wondering i have some gun code..
    Code:java
    1.  
    2. else if(e.getPlayer().getItemInHand().getType() == Material.STONE_HOE){
    3. if(!recentlyFired.contains(player.getName())){
    4. ItemStack item = new ItemStack(Material.GLOWSTONE_DUST, 1);
    5. ItemMeta reName = item.getItemMeta();
    6. reName.setDisplayName(ChatColor.RESET + "Ammo");
    7. List<String> lore = new ArrayList<String>();
    8. lore.add(ChatColor.RESET + "For use on:");
    9. lore.add(ChatColor.RESET + "- MP5");
    10. reName.setLore(lore);
    11. item.setItemMeta(reName);
    12.  
    13. Arrow arrow = (Arrow)player.launchProjectile(Arrow.class);
    14. arrow.setVelocity(arrow.getVelocity().multiply(5));
    15. arrow.setShooter(player);
    16. arrow.setMetadata("shotfrom", new FixedMetadataValue(this, "mp5"));
    17. recentlyFired.add(player.getName());
    18. inventory.removeItem(item);
    19. }
    20. }
    21.  


    but what's happens is the arrow goes straight for a while the suddenly swings left or right

    Thanks,
    Deckerz
     
  2. Offline

    Nitnelave

    A few problems that might be responsible for this : try to define the arrow's velocity yourself, as spawning an arrow will give it a velocity of 0, if I'm not mistaken.
    Try to reduce the velocity, I'm not sure bukkit likes it if you have a velocity too big.
     
  3. Offline

    gamerzap

    No, I think an arrow spawns with a velocity. Because I have some code I used a while ago for spread arrows and they work.
     
  4. Offline

    Nitnelave

    Oh, right, he used player.launchProjectile, not world.spawn().
     
Thread Status:
Not open for further replies.

Share This Page