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

Help.. T^T

Comments in 'Plugin Development' started by iDirtPlayzMC, Jul 1, 2015.

Thread Status:
Not open for further replies.
  1. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    PHP:
    <?php

    namespace iDirtniverse\BlockEffect;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\entity\Effect;

    class 
    Main extends PluginBase implements Listener{

        public function 
    onEnable(){
            
    $this->getLogger()->info("Activated");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->saveDefaultConfig();
        }
        public function 
    onDisable(){
            
    $this->getLogger()->info("Deactivated");
        }
        public function 
    onMove(PlayerMoveEvent $event){
            
    $effect Effect::getEffect(1); //Effect ID
            
    $effect->setAmplifier(5);
            
    $effect->setDuration(100); //Ticks
            
    $x $event->getPlayer()->getFloorX();
            
    $y $event->getPlayer()->getFloorY() - 1;
            
    $z $event->getPlayer()->getFloorZ();
            
    $player $event->getPlayer();
            
    $blockPos = new Vector3($x$y$z);
            
    $block $player->getLevel()->getBlock($blockPos);
            if(
    $block->getId() === Block::OBSIDIAN){
                
    $player->addEffect($effect);
            }
        }
    }
    is that code right? it doesnt work when i step on redstoneblock..

    Im trying to set player effect when player step on redstone block
    Legoboy0215 likes this.
  2. Intyre
    Offline

    Intyre Staff Member PocketMine Team

    Joined:
    Aug 24, 2013
    Posts:
    118
    Minecraft User:
    Intyre
    Code:
    if($block->getId() === Block::OBSIDIAN){
        $player->addEffect($effect);
    }
    
Thread Status:
Not open for further replies.

Share This Page

Advertisement