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

Help Place block with tag

Comments in 'Plugin Development' started by BSHRMG, Jul 9, 2016.

  1. BSHRMG
    Offline

    BSHRMG New Member

    Joined:
    Mar 15, 2016
    Posts:
    21
    I want to know if this is right and if its why it doesn't works?
    Or someone can tell me how to do it?
    Thanks :D
    PHP:
    <?php
    namespace Lucky;

    use 
    pocketmine\Block;
    use 
    pocketmine\event\BlockPlaceEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\Level;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\BlockBreakEvent;

    class 
    Main extends PluginBase implements Listener{
          public function 
    onEnable(){
    $this->getLogger()->info("LuckyBlock Enabled");
    }

    public function 
    onPlace(BlockPlaceEvent $event){
            
    $player $event->getPlayer();
    $level $event->getLevel();
    $lucky = new FloatingTextParticle(new Vector3(010," ","Mushrom"));
    if(
    $event->getBlock()->getID == 100){
    $level->addParticle($lucky);
    }
    }
    }
  2. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    Not sure what the hell you were trying to do with Vector3
    PHP:
    if($event->getBlock()->getID == 100){
    $b $event->getBlock();
    $lucky = new FloatingTextParticle(new Vector3($b->getX(), $b->getY() +1$b->getZ())," ","Mushrom"));
    $level->addParticle($lucky);
    }
    applqpak, SOFe and BSHRMG like this.
  3. BSHRMG
    Offline

    BSHRMG New Member

    Joined:
    Mar 15, 2016
    Posts:
    21
    Thanks for reply but it didn't work yet
    I'm trying that every time i place block show like this example but I don't know how to do it of all right :)

    Attached Files:

  4. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    You didn't registered events
  5. EschieEsh
    Offline

    EschieEsh Active Member

    Joined:
    Jun 28, 2014
    Posts:
    69
    Minecraft User:
    Escherion
    It is $event->getBlock()->getId(), not $event->getBlock()->getID
  6. BSHRMG
    Offline

    BSHRMG New Member

    Joined:
    Mar 15, 2016
    Posts:
    21
    Look how is but doesn't work yet xD

    PHP:
    namespace Lucky;

    use 
    pocketmine\Block;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    use 
    pocketmine\Level;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\block\BlockBreakEvent;

    class 
    Main extends PluginBase implements Listener{
          public function 
    onEnable(){
        
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    $this->getLogger()->info("LuckyTag Enabled");
    }

    public function 
    onPlace(BlockPlaceEvent $event){
    if(
    $event->getBlock()->getId == 100){
        
    $b $event->getBlock();
        
    $level getLevel();
        
    $lucky = new FloatingTextParticle(new Vector3($b->getX(), $b->getY()+1$b->getZ()),"","Mushrom");
    $level->addParticle($lucky);
    }
    }
    }
  7. BalAnce
    Offline

    BalAnce Active Member

    Joined:
    Mar 10, 2015
    Posts:
    125
    Minecraft User:
    BalAnce
    PHP:
    $event->getBlock()->getId()
  8. Mat
    Offline

    Mat Active Member Plugin Developer

    Joined:
    Jun 15, 2014
    Posts:
    179
    Plugins:
    1
    Minecraft User:
    matcracker
    Yes, and
    PHP:
    $level $b->getLevel();
    BalAnce likes this.
  9. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Note that getId() and getID() have no difference in PHP. At least, not now, and most likely, never.
  10. BSHRMG
    Offline

    BSHRMG New Member

    Joined:
    Mar 15, 2016
    Posts:
    21
    I did this new and it works but now how to do disappear the particle when player get break the block again? xD



    PHP:
    <?php

    namespace vere;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\event\player\PlayerChatEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\block\Chest;
    use 
    pocketmine\Server;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\event\inventory\InventoryOpenEvent;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerItemHeldEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\level\Level;

    class 
    Main extends PluginBase implements Listener{

    public function 
    onEnable(){
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    $this->getLogger("Plugin Enabled");
    }

    public function 
    onPlace(BlockPlaceEvent $event){
    $player $event->getPlayer();
    $block $event->getBlock();
    $name $player->getName();
    if(
    $player instanceof Player){
    $text "§eLucky §fBlock";
    $title "§bBreak Me!";
    $x $block->getX()+0.5;
    $y $block->getY()+1.5;
    $z $block->getZ()+0.5;
    $particle = new FloatingTextParticle(new Vector3($x,$y,$z),$text,$title);
    if(
    $block->getId() == 100){
    $player->getLevel()->addParticle($particle,array($player));
    }
    }
    }
    }
  11. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Store the $particle at the appropriate place, then call setVisible(false) on it and addParticle() it again when you need to despawn it.
    BSHRMG likes this.

Share This Page

Advertisement