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

what wrong my code ?

Comments in 'Plugin Development' started by DevWars, Nov 27, 2015.

  1. DevWars
    Offline

    DevWars Banned

    Joined:
    Nov 7, 2015
    Posts:
    28
    Minecraft User:
    PmServer
    PHP:
    <?php

    namespace DropBlockPm;

    use 
    pocketmine\Server;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandExecutor;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\PluginCommand;
    use 
    pocketmine\Player;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\event\player\PlayerChatEvent;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\level\particle\Particle;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\level\particle\DestroyBlockParticle;
    use 
    pocketmine\level\particle\ExplodeParticle;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\entity\EntityLevelChangeEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\EventExecutor;
    use 
    pocketmine\event\EventPriority;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\plugin\Plugin;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\scheduler\TaskHandler;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\level\sound\HugeExplodeSound;
    use 
    pocketmine\level\particle\HugeExplodeParticle;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\level\particle\AngryVillagerParticle;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\level\sound\PopSound;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\Player\getName;
    use 
    pocketmine\command\ConsoleCommandSender;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\level\sound\GhastShootSound;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\pocketmine\Level;
    use 
    pocketmine\entity\Effect;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    use 
    pocketmine\event\player\PlayerPreLoginEvent;



    class 
    Main extends PluginBase implements Listener{




                 
        public function 
    onLoad(){
            
    $this->getLogger()->info(TextFormat::YELLOW."Loaded.");
        }

        public function 
    onEnable(){
        
    $this->getServer()->getPluginManager()->registerEvents($this$this);

        
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new AutoTask($this), 10);

    }
    public function 
    getBlock() {
        foreach (
    $this->getServer()->getLevelByName("world")->getBlock() as $block) {
           
    $level $block->getLevel();
           if(
    $block->getId() == 133) {
               
    $level->addParticle(new DestroyBlockParticleBlock::get(57));
           }
        }
    }
        }
        class 
    AutoTask extends PluginTask
    {
        public function 
    __construct(Plugin $owner) {
            
    parent::__construct($owner);
        }
        public function 
    onRun($currentTick){
            
    $this->getOwner()->getBlock();
        }}
    what wrong ??
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    pocketmine\level\Level::getBlock ( Vector3 $pos,
    $cached = true
    )
  3. DevWars
    Offline

    DevWars Banned

    Joined:
    Nov 7, 2015
    Posts:
    28
    Minecraft User:
    PmServer
    Please give me full code correctly
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    public function getBlock() {
        foreach (
    $this->getServer()->getLevelByName("world")->getBlock() as $block) {//How should the Server know where the block is?
           
    $level $block->getLevel();
           if(
    $block->getId() == 133) {
               
    $level->addParticle(new DestroyBlockParticleBlock::get(57));
           }
        }
    }
  5. DevWars
    Offline

    DevWars Banned

    Joined:
    Nov 7, 2015
    Posts:
    28
    Minecraft User:
    PmServer
    I want to DestroyBlockParticle shows me every seconds and so on ...
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    As @Primus said, it's
    PHP:
    Level::getBlock(Vector3 $pos$cached true){}
    and not
    PHP:
    Level::getBlock(){}
  7. DevWars
    Offline

    DevWars Banned

    Joined:
    Nov 7, 2015
    Posts:
    28
    Minecraft User:
    PmServer
    Well I hope that you give me the full code once :)
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Just change your line..?
  9. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Are you trying to foreach every block in the world "world"?
  10. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    First of all, do you even understand your own code? Second of all, do you actally know the API? There is no Level->getBlocks(). That would overload the server, you know how big worlds are and you know how many blocks it'll return. You would use a for-loop. Hint: This plugin doesn't require that many imports.
    Giving you the correct code is useless if you don't understand how it works.
    Well I hope you can look at the docs once :)
    TheDeibo likes this.
  11. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    WHat are you planning to do with this plugin anyways?
  12. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Add particle to each block in world in each second? That definetely will be lag and even more server won't response.
  13. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    $level->addParticle(new DestroyBlockParticle(new Vector3($pos),Block::get(1));
    XWITHERHEROX likes this.

Share This Page

Advertisement