Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Get Killers Weapon

Comments in 'Plugin Development' started by Pman1220, Aug 4, 2015.

  1. Pman1220
    Offline

    Pman1220 Active Member Plugin Developer

    Joined:
    Nov 21, 2013
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Pman1220
    How may I go about finding a persons weapon? For example: a player kills another player. I want to know what weapon the killer is using or what item is in that persons hand. Thanks for your help :)
  2. tschrock
    Offline

    tschrock New Member Plugin Developer

    Joined:
    May 3, 2014
    Posts:
    22
    Plugins:
    3
    Minecraft User:
    tschrock
    You can get whatever's currently in a player's hand with $player->getInventory()->getItemInHand();
  3. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    502
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    Use EntityDamageByEntityEvent
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Note that if a projectile hit the player, you should check the getChild entity in EntityDamageByChildEntityEvent, because by the time the projectile hits the player maybe the player is no longer holding the bow/snowball/egg.

Share This Page

Advertisement