Solved How to Specify in the Interaction Event

Discussion in 'Development' started by Minetron26, Dec 1, 2018.

  1. Minetron26

    Minetron26 Spider Jockey

    Messages:
    43
    GitHub:
    minetron-26
    Hello!, I would like to know how and if there is a way to specify with which block the player must interact so that a sentence was executed, for example, in the Interaction Event a Message was sent to the Player only if the Block with which interacts is Grass and also if I can specify which Item to interact with so that the sentence is executed.
     
  2. Jules

    Jules Spider Jockey

    Messages:
    39
    GitHub:
    Julooooos
    PHP:
    public function onInteract(PlayerInteractEvent $event){
        
    $player $event->getPlayer();
        
    $item $event->getItem();
        
    $block $event->getBlock();

        if(
    $item->getId() == yourid){

            if(
    $block->getId() == yourblock){

                
    $player->sendMessage("Hello world");
            }
        }
    }
    @Minetron26
     
    Minetron26 likes this.
  3. Minetron26

    Minetron26 Spider Jockey

    Messages:
    43
    GitHub:
    minetron-26
    Thanks you!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.