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

Add stop

Discussion in 'Plugin Help' started by dragonflex, Feb 18, 2017.

  1. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
    How add stopping creating obsidian to block bedrock?
    PHP:
    <?php

    namespace dragonflex;

    use 
    pocketmine\plugin\PluginBase as P;
    use 
    pocketmine\event\Listener as L;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\utils\MainLogger;
    use 
    pocketmine\block\Air;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\block\BlockPlaceEvent as BPL;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\item\Item;

    class 
    Main extends implements L{

        public function 
    onEnable(){

            
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
            
    $this->saveDefaultConfig();
            
    $this->getServer()->getLogger()->info(TextFormat::GREEN."[Boyfarner] wlaczony!");
        }

        public function 
    onPlace(BPL $e){

            
    $player $e->getPlayer();
            
    $blok $e->getBlock();
            
    $gracz $e->getPlayer()->getName();

                    if(
    $e->getBlock()->getId() == 121){
                    
    $this->getServer()->$gracz->getLevel()->setBlock(new Vector3($blok->getFloorX(), $blok->getFloorY()-80$blok->getFloorZ()), new Obsidian());
                    
    $e->setCancelled();
            }
        }
    }
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
  3. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
    how to adjust to the generation of obsidian ended on bedrock
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    do you meant you want the world to generate with obsidian instated of bedrock?
     
  5. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
  6. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    BPE is only called when a player places the block. So your code will not replace all bedrock in the world. Only the bedrock placed by a player. I am going to assume you know that, and continue with what I see wrong with your code.

    Instead of checking if the block ID == the ID number, use Item::ITEM_NAME to get the ID. This provides use in the event item and block IDs are changed.


    You used:
    PHP:
     $gracz $e->getPlayer()->getName();
    //later in your code, you used:
      
    $this->getServer()->$gracz->getLevel(); //...
    There are so many things wrong with this. In your case, you do not need the player's name at all, and you certainly can't call any events with that name. You don't need to get the server either, because it provides no use in this case. You could instead use:
    PHP:
     $e->getPlayer->getLevel()->setBlock(new Vector3($blok->getFloorX(), $blok->getFloorY()-80 /*Why - 80? */$blok->getFloorZ()), new Obsidian());
    /*add use statement for Obsidian Block, because otherwise you will get an error.*/
    /*You may not even need to getFloorX(), getFloorY(), etc. I am not sure though, so I won't go into that. */
     
  7. dragonflex

    dragonflex Spider Jockey

    Messages:
    44
    I need boyfarmer
     
  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.