1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved How to Specify in the Interaction Event

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

  1. Minetron26

    Minetron26 Witch

    Messages:
    55
    GitHub:
    minetron26
    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 Witch

    Messages:
    53
    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 Witch

    Messages:
    55
    GitHub:
    minetron26
    Thanks you!
     
  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.