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

NEED HELP

Comments in 'Plugin Development' started by Flabe, Jan 17, 2016.

Thread Status:
Not open for further replies.
  1. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Hello guys tell me please whats wrong with my code?(i am trying to create snowball entity but it not works)
    PHP:
    <?php
    namespace Oleg;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\Player;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\level\particle\EnchantmentTableParticle;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\inventory\PlayerInventory;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\entity\Snowball;


    class 
    PixelTestPlugin extends Pluginbase implements Listener{
        public function 
    onEnable(){
            
    $this->getLogger()->info("Плагин Pixelinfo запуск........");
            
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
        }
       
        public function 
    onDisable(){
            
    $this->getLogger()->info("Плагин Pixelinfo отключение........");
        }
        public function 
    onEvent(PlayerInteractEvent $event)
        {
            
    $player $event->getPlayer();
            if(
    $event->getAction() == PlayerInteractEvent::RIGHT_CLICK_AIR){
                if(
    $player->getInventory()->getItemInHand()->getId() == 287) {
            
    $speed 3;
            
    $pos $player->getPosition();
            
    $dir $player->getDirectionVector();
            
    $frontPos $player->add($player->getDirectionVector()->multiply(1.5));
            
    $dir->$dir->$speed;
            
    $dir->$dir->$speed;
            
    $dir->$dir->$speed;
            
    $nbt =
                new 
    Compound("",
                             [
    "Pos" => new Enum("Pos",
                                [new 
    Double(""$frontPos->x),
                                    new 
    Double(""$frontPos->y+1),
                                    new 
    Double(""$frontPos->z)]),
                                
    "Motion" => new Enum("Motion",
                                [new 
    Double("",$dir->x),
                                    new 
    Double("",$dir->y),
                                    new 
    Double("",$dir->z)]),
                              
    "Rotation" => new Enum("Rotation",
                                [new 
    Float(""0),
                                    new 
    Float(""0)])]);
            
    Entity::createEntity("Snowball"$pos->getLevel()->getChunk($pos->>> 4$pos->>> 4),$nbt)->spawnTo($player);
           
        }
            }
        }
    }
       
    ?>
  2. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    errors?
  3. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    No , there is no errors it's just not work when I try to shoot snowball with item(Id = 287)...
  4. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    There will be errors as you didn't use
    pocketmine\nbt\tag\Compound
    pocketmine\nbt\tag\Enum
    pocketmine\nbt\tag\Double
    pocketmine\nbt\tag\Float
    Btw errors will only be displayed on the server console, not to players.
    applqpak likes this.
  5. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    thx)
  6. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    is it import? use pocketmine?
  7. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Still not working.....
    PHP:
    <?php
    namespace Oleg;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\Player;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\level\particle\EnchantmentTableParticle;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\inventory\PlayerInventory;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\entity\Snowball;
    use 
    pocketmine\nbt\tag\Compound;
    use 
    pocketmine\nbt\tag\Enum;
    use 
    pocketmine\nbt\tag\Double;
    use 
    pocketmine\nbt\tag\Float;


    class 
    PixelTestPlugin extends Pluginbase implements Listener{
        public function 
    onEnable(){
            
    $this->getLogger()->info("Плагин Pixelinfo запуск........");
            
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
        }
       
        public function 
    onDisable(){
            
    $this->getLogger()->info("Плагин Pixelinfo отключение........");
        }
        public function 
    onEvent(PlayerInteractEvent $event)
        {
            
    $player $event->getPlayer();
            if(
    $event->getAction() == PlayerInteractEvent::RIGHT_CLICK_AIR){
                if(
    $player->getInventory()->getItemInHand()->getId() == 287) {
            
    $speed 3;
            
    $pos $player->getPosition();
            
    $dir $player->getDirectionVector();
            
    $frontPos $player->add($player->getDirectionVector()->multiply(1.5));
            
    $dir->$dir->$speed;
            
    $dir->$dir->$speed;
            
    $dir->$dir->$speed;
            
    $nbt =
                new 
    Compound("",
                             [
    "Pos" => new Enum("Pos",
                                [new 
    Double(""$frontPos->x),
                                    new 
    Double(""$frontPos->y+1),
                                    new 
    Double(""$frontPos->z)]),
                                
    "Motion" => new Enum("Motion",
                                [new 
    Double("",$dir->x),
                                    new 
    Double("",$dir->y),
                                    new 
    Double("",$dir->z)]),
                              
    "Rotation" => new Enum("Rotation",
                                [new 
    Float(""0),
                                    new 
    Float(""0)])]);
            
    Entity::createEntity("Snowball"$pos->getLevel()->getChunk($pos->>> 4$pos->>> 4),$nbt)->spawnTo($player);
           
        }
            }
        }
    }
       
    ?>
  8. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    There is nothing wrong in this code, is your plugin.yml correct?
    applqpak likes this.
Thread Status:
Not open for further replies.

Share This Page

Advertisement