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

code tread block

Discussion in 'Development' started by MadeUpadanaYT, Feb 17, 2017.

  1. MadeUpadanaYT

    MadeUpadanaYT Spider

    Messages:
    12
    Can you tell the code at the time stepped on the block?
    Example:
    if we step on the object and will get a sword or effect

    Please
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    I was going to type up an example, but there is one here that is much better than what I could do.
     
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    PHP:
    const BLOCKID Block::STONE;
    public function 
    onMove(PlayerMoveEvent $event){
        if(!
    $event->getFrom()->equals(($to $event->getTo())))
            if(
    $event->getPlayer()->getLevel()->getBlockIdAt($to->x$to->y$to->z) === self::BLOCKID){
                
    $player->getInventory()->addItem(Item::get(Item::DIAMOND_SWORD));
                
    //$player->addEffect(...)
            
    }
        }
    }
     
    corytortoise likes this.
  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.