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

Action on itemuse

Comments in 'Plugin Development' started by JackboyPlay, Feb 15, 2016.

  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    How can I do when a Player uses a item like a slimeball that he gets a message [He should use the slimeball with right klick]
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Handle PlayerInteractEvent. If action is PlayerInteractEvent::RIGHT_CLICK_BLOCK. If item ID matches Item::SLIMEBALL. Send message.
    JackboyPlay and Vaivez66 like this.
  3. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
  4. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    if(PlayerInteractEvent::RIGHT_CLICK_BLOCK){
    $event->getPlayer()->sendMessage("You are cool");
    }
    @PEMapModder like this?
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No. How will PHP know what you are doing with PlayerInteractEvent::RIGHT_CLICK_BLOCK? Compare it with $PlayerInteractEvent->getAction(), to see if they are identical, using the === operator.
  6. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    if(PlayerInteractEvent->getAction() == RIGHT_CLICK_BLOCK){
    $event->getPlayer()->sendMessage("You are cool");
    }
    @@PEMapModder like this?
  7. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    Do You Want A Cick in the air 1 sec look my plugin TNT
    Do you want a click a block and do things
    use PlayerInteractEvent
  8. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    I know it... Since 2 h
    PEMapModder likes this.

Share This Page

Advertisement