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

Climb on walls

Discussion in 'Development' started by iCirgio, Jan 4, 2018.

  1. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    I'm trying to make it so when someone where's a helmet they can climb up walls but my code doesn't seem to work

    PHP:
    public function onClimb(EntityMotionEvent $event){

       
    $player $event->getPlayer();
       
    $helmetid $player->getInventory()->getHelmet()->getId();
         
    $helmetd $player->getInventory()->getHelmet()->getDamage();

        if(
    $helmetid === 397){
        if(
    $helmetd === 1){

       
    $blocks $player->getLevel()->getBlock($player)->getHorizontalSides();
      
    $nonair 0;

       foreach (
    $blocks as $block){

           if(
    $block->getId() !== Block::AIR && $block->isSolid()){

            
    $nonair++;

          }
      }

          if(
    $nonair 0){
              if(!
    $player->getGenericFlag(Entity::DATA_FLAG_WALLCLIMBING)){

           
    $player->setGenericFlag(Entity::DATA_FLAG_WALLCLIMBINGtrue);

            }

       
    $player->resetFallDistance();

               }else{

              if(
    $player->getGenericFlag(Entity::DATA_FLAG_WALLCLIMBING)){
          
    $player->setGenericFlag(Entity::DATA_FLAG_WALLCLIMBINGfalse);

           }
       }
    }

                }else{

             if(
    $player->getGenericFlag(Entity::DATA_FLAG_WALLCLIMBING)){
       
    $player->setGenericFlag(Entity::DATA_FLAG_WALLCLIMBINGfalse);

         }
       }
     
  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.