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

Change block every second?

Comments in 'Plugin Development' started by Legoboy0215, May 17, 2015.

  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Then what is the error?
    Code:
    [CRITICAL] ClassNotFoundException: "Class blockchanger\Position not found" (EXC EPTION) in "/src/spl/BaseClassLoader" at line 122
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Learn PHP please...
    PHP:
    use pocketmine\level\Position;
    Samueljh1 likes this.
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    OMG.... Sorry. You know, I think you should have told me to learn english....
    I typed:
    PHP:
    use pocketmone\level\Position;
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    @PEMapModder , can you teach me a better way to write this? PS: I know the code looks like cr*p, but don't mind since I am an beginner.
    PHP:
    <?php
    namespace legoboy\blockchanger;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\utils\Config;
    class 
    Main extends PluginBase{
      public function 
    onEnable(){
          
    $this->saveDefaultConfig();
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x1"), $this->getConfig()->get("y1"), $this->getConfig()->get("z1"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x2"), $this->getConfig()->get("y2"), $this->getConfig()->get("z2"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x3"), $this->getConfig()->get("y3"), $this->getConfig()->get("z3"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x4"), $this->getConfig()->get("y4"), $this->getConfig()->get("z4"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x5"), $this->getConfig()->get("y5"), $this->getConfig()->get("z5"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x6"), $this->getConfig()->get("y6"), $this->getConfig()->get("z6"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x7"), $this->getConfig()->get("y7"), $this->getConfig()->get("z7"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x8"), $this->getConfig()->get("y8"), $this->getConfig()->get("z8"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x9"), $this->getConfig()->get("y9"), $this->getConfig()->get("z9"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x10"), $this->getConfig()->get("y10"), $this->getConfig()->get("z10"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x11"), $this->getConfig()->get("y11"), $this->getConfig()->get("z11"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
        
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position($this->getConfig()->get("x12"), $this->getConfig()->get("y12"), $this->getConfig()->get("z12"), $this->getServer()->getDefaultLevel()), [Block::get(Block::GOLD_BLOCK0), Block::get(Block::IRON_BLOCK15)]), $this->getConfig()->get("ticks"), $this->getConfig()->get("ticks"));
      }
    }
    Code:
    ---
    #Add text below.
    ticks: "20"
    x1: ""
    y1: ""
    z1: ""
    x2: ""
    y2: ""
    z2: ""
    x3: ""
    y3: ""
    z3: ""
    x4: ""
    y4: ""
    z4: ""
    x5: ""
    y5: ""
    z5: ""
    x6: ""
    y6: ""
    z6: ""
    x7: ""
    y7: ""
    z7: ""
    x8: ""
    y8: ""
    z8: ""
    x9: ""
    y9: ""
    z9: ""
    x10: ""
    y10: ""
    z10: ""
    x11: ""
    y11: ""
    z11: ""
    x12: ""
    y12: ""
    z12: ""
    ...
  6. matthww
    Offline

    matthww Active Member

    Joined:
    May 13, 2014
    Posts:
    91
    Minecraft User:
    Matthww
    Legoboy just a question if this works can you send it to me to?
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Ok, I may. Ask for @PEMapModder for permission. That is all.
  8. matthww
    Offline

    matthww Active Member

    Joined:
    May 13, 2014
    Posts:
    91
    Minecraft User:
    Matthww
    Ok thnx :)
  9. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    [CRITICAL] ClassNotFoundException: "Class legoboy\blockchanger\ChangeBlockTask not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 131
  10. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    ChangeBlockTask.php
    PHP:
    <?php
    namespace blockchanger;
    use 
    pocketmine\scheduler\PluginTask;
    class 
    ChangeBlockTask extends PluginTask{
      private 
    $pos;
      private 
    $list;
      private 
    $current 0;
      public function 
    __construct(Main $mainPosition $pos, array $list){
        
    parent::__construct($main);
        
    $this->pos $pos;
        
    $this->list $list;
        if(
    count($list) === 0){
          throw new \
    InvalidArgumentException;
        }
      }
      public function 
    onRun($t){
        
    $this->pos->getLevel()->setBlock($this->pos$this->list[$this->next()]);
      }
      private function 
    next(){
        
    $this->current++;
        if(
    $this->current >= count($this->list)) $this->current 0// loop back to the initial item
        
    return $this->current;
      }
    }
  11. matthww
    Offline

    matthww Active Member

    Joined:
    May 13, 2014
    Posts:
    91
    Minecraft User:
    Matthww
    it should be this:

    PHP:
    <?php
    namespace legoboy\blockchanger;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\level\Position;
    class 
    ChangeBlockTask extends PluginTask{
      private 
    $pos;
      private 
    $list;
      private 
    $current 0;
      public function 
    __construct(Main $mainPosition $pos, array $list){
        
    parent::__construct($main);
        
    $this->pos $pos;
        
    $this->list $list;
        if(
    count($list) === 0){
          throw new \
    InvalidArgumentException;
        }
      }
      public function 
    onRun($t){
        
    $this->pos->getLevel()->setBlock($this->pos$this->list[$this->next()]);
      }
      private function 
    next(){
        
    $this->current++;
        if(
    $this->current >= count($this->list)) $this->current 0// loop back to the initial item
        
    return $this->current;
      }
    }
  12. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    WOW OMGGGGGGGGGGG VVGODDDDDDDDDDDDDDDDDDDDDD THX
    GamesLoad likes this.
  13. matthww
    Offline

    matthww Active Member

    Joined:
    May 13, 2014
    Posts:
    91
    Minecraft User:
    Matthww
    Just thank PEmapmodder and legoboy
  14. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Please don't copy the code without understanding it.
    If you understand the code, you wouldn't be asking me how to improve it.
  16. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Oooops. Nothing already. I got a way so sorry...
  17. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Omg so many posts to answer 1 eZ question xD.

    PHP:

    Face
    ::palm();

Share This Page

Advertisement