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

Solved How to place blocks in a plugin

Discussion in 'Plugin Help' started by neb16, Apr 15, 2019.

  1. neb16

    neb16 Witch

    Messages:
    71
    GitHub:
    developerneb101
    So I am currently expirimenting with making plugins. Right now i just made a simple death event:

    PHP:
      public function onDeath(PlayerDeathEvent $event) : void{
                  
    $event->setDeathMessage("§l§3" $event->getPlayer()->getName() . " §8just died");
                  
    $level->setBlock(new Vector3($p->getX(), $p->getY()-1$p->getZ()), Block::get(1));
    }
    In order for that block to be placed would'nt i need to do something like:
    PHP:
    use pocketmine\Blocks;
    Any help would be great!
     
  2. Swourire

    Swourire Spider Jockey

    Messages:
    49
    GitHub:
    swourire
    The class you're looking for is this https://github.com/pmmp/PocketMine-MP/blob/stable/src/pocketmine/block/Block.php
    call will be :
    use pocketmine\block\Block;

    also you can just call the block class, if we want Anvil to be spawned :
    new Anvil();
    $level->setBlock($position, new Anvil(), false); the false at the end is to not update the blocks around it (causes less lags)
    with higher a call of the class :
    use pocketmine\block\Anvil;
     
  3. kazuya

    kazuya Slime

    Messages:
    79
    GitHub:
    xdqrknez
    Yeah, you would. Same for Vector3. I recommend that you use an IDE to help you regarding imports
     
  4. neb16

    neb16 Witch

    Messages:
    71
    GitHub:
    developerneb101
    K thanks guys
     
  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.