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

Help needed with entity sizes, player effects and setBoots

Discussion in 'Development' started by MalakasPlayzMCPE, Mar 23, 2018.

  1. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    For older PocketMine versions I used this code for changing the player sizes:
    PHP:
    $player->setDataProperty(Entity::DATA_SCALEEntity::DATA_TYPE_FLOAT1.5);
    this code for adding effects:
    PHP:
    $effect Effect::getEffect(13);
    $effect->setDuration(999);
    $effect->setAmplifier(1);
    $effect->setVisible(false);
    $player->addEffect($effect);
    and this code for setting boots:
    PHP:
    $player->getInventory()->setBoots(Item::get(31301));
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Now, this code does not work. Can you help me?
     
    Last edited: Mar 23, 2018
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    1. Use Entity:: getDataPropertyManager().
    2. Living::addEffect() require EffectInstance to be passed as the first parameter. Enclose your Effect into an EffectInstance class.
    PHP:
    $effect Effect::getEffect(13);
    $player->addEffect(new EffectInstance($effect9991));
    3. https://forums.pmmp.io/threads/undefined-method-but-i-was-using-it-before.5461/
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    The 3rd and the 2nd are solved now. About the first one, what do you mean?
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Since you're setting the scale, why not use Entity::setScale(1.5) instead of setting it's data property. Entity::setScale() method will also change the bounding box of the Entity which is a plus.
     
  6. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    I tried Entity::setScale(1.5) but it did not work
     
  7. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    It's working, but if you didn't read source and used it as static method then it will not work
     
  8. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    How to make it work? I use this code:
    PHP:
    $player->setDataProperty(Entity::setScale(1.5));
     
  9. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    I said it will not work if you use it as static method
    PHP:
    $player->setScale(1.5);
    Really hard... :D
     
    Teamblocket and OnTheVerge like this.
  10. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Ok, thanks!
     
  11. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    I get this error now:
    Code:
    24.03 05:19:27 [Server] Server thread/CRITICAL Could not execute task MalakasPlayzMC\rainbowArmor: Return value of pocketmine\entity\Living::getArmorInventory() must be an instance of pocketmine\inventory\ArmorInventory, null returned 24.03 05:19:27 [Server] Server thread/CRITICAL TypeError: "Return value of pocketmine\entity\Living::getArmorInventory() must be an instance of pocketmine\inventory\ArmorInventory, null returned" (EXCEPTION) in "src/pocketmine/entity/Living" at line 427 24.03 05:19:27 [Server] Server thread/DEBUG #0 Plugin.phar/src/MalakasPlayzMC/Plugin(2503): pocketmine\entity\Living->getArmorInventory() 24.03 05:19:27 [Server] Server thread/DEBUG #1 src/pocketmine/scheduler/TaskHandler(160): MalakasPlayzMC\rainbowArmor->onRun(integer 15541) 24.03 05:19:27 [Server] Server thread/DEBUG #2 src/pocketmine/scheduler/ServerScheduler(327): pocketmine\scheduler\TaskHandler->run(integer 15541) 24.03 05:19:27 [Server] Server thread/DEBUG #3 src/pocketmine/Server(2499): pocketmine\scheduler\ServerScheduler->mainThreadHeartbeat(integer 15541) 24.03 05:19:27 [Server] Server thread/DEBUG #4 src/pocketmine/Server(2239): pocketmine\Server->tick() 24.03 05:19:27 [Server] Server thread/DEBUG #5 src/pocketmine/Server(2115): pocketmine\Server->tickProcessor() 24.03 05:19:27 [Server] Server thread/DEBUG #6 src/pocketmine/Server(1701): pocketmine\Server->start() 24.03 05:19:27 [Server] Server thread/DEBUG #7 src/pocketmine/PocketMine(305): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /, string /plugins/) 24.03 05:19:27 [Server] Server thread/DEBUG #8 /custom.phar(1): require(string phar:///custom.phar/src/pocketmine/PocketMine.php)
    Here is my code:
    PHP:
    class rainbowArmor extends PluginTask{

            public function 
    __construct(LobbyCore $plugin) {
           
    parent::__construct($plugin);
           
    $this->plugin $plugin;
       }

       public function 
    onRun($tick) {
           foreach(
    $this->plugin->rarmor as $p){
               
    $helmeta = array(298302306310314);
               
    $chestplatea = array(299303307311315);
               
    $leggingsa = array(300304308312316);
               
    $bootsa = array(301305309313317);

               
    $helmet Item::get($helmeta[array_rand($helmeta)]);
               
    $chestplate Item::get($chestplatea[array_rand($chestplatea)]);
               
    $leggings Item::get($leggingsa[array_rand($leggingsa)]);
               
    $boots Item::get($bootsa[array_rand($bootsa)]);
               if(!
    $helmet == null || !$chestplate == null || !$leggings == null || !$boots == null){
                   
    $p->getArmorInventory()->setHelmet($helmet);
                   
    $p->getArmorInventory()->setChestplate($chestplate);
                   
    $p->getArmorInventory()->setLeggings($leggings);
                   
    $p->getArmorInventory()->setBoots($boots);
               }
           }  
       }
    }
     
  12. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    When are you adding the player to $this->plugin->rarmor array?
     
  13. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    PHP:
           $in $event->getPlayer()->getInventory()->getItemInHand()->getCustomName();

            if(
    $in == TextFormat::RESET TextFormat::GOLD "Colorful" TextFormat::RESET TextFormat::GOLD " Armor"); {
                if(
    in_array($player$this->rarmor)){
                    unset(
    $this->rarmor[array_search($player$this->rarmor)]);
                    
    $player->getArmorInventory()->setHelmet(Item::get(0));
                    
    $player->getArmorInventory()->setChestplate(Item::get(0));
                    
    $player->getArmorInventory()->setLeggings(Item::get(0));
                    
    $player->getArmorInventory()->setBoots(Item::get(0));
                    
    $player->sendMessage($prefix TextFormat::RESET TextFormat::RED "You have disabled your " TextFormat::GOLD "Colorful Armor");
                }else{
                    
    array_push($this->rarmor$player);
                    
    $player->sendMessage($prefix TextFormat::RESET TextFormat::GREEN "You have enabled your " TextFormat::GOLD "Colorful Armor");
                }
            }
     
  14. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    On PlayerInteractEvent
     
  15. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Bump!
     
  16. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Well, fixed that issue. I have an issue with the interact event. When the player taps somewhere (even without the item with the name I have set), this is getting enabled and disabled. Is this a pocketmine bug?
     
  17. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Try to use getName() instead of getCustomName()
     
  18. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Yes, happens in Windows 10 edition. There's a bug where PlayerInteractEvent gets called twice.
     
  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.