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

Create wings with particles

Comments in 'Plugin Development' started by MCPEPIG, Mar 23, 2016.

  1. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    What's the simplest & best way to make the shape of wings with particles. Example: photo_2016-03-23_16-16-27.jpg
  2. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Plotting points behind the player that looks like wings. Computer does not know what wing you are thinking.
    applqpak likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes, and the question is, what is the simplest way to plot them other than hardcoding everything directly with code.

    I am thinking about this:
    1. In the resources folder of your plugin, create a text file like this:
      Code:
      X       X
       XX   XX
        XXXXX
          X
    2. Parse the contents of the file into coordinates:
      PHP:
      $map = [];
      $handle $plugin->getResource("wings.map");
      $lines explode("\n"rtrim(stream_get_contents($handle)));
      fclose($handle);

      $height count($lines);
      foreach(
      $lines as $lineNumber => $line){
        
      $len strlen($line);
        for(
      $i 0$i $len; ++$i){
          if(
      $line{$i} === "X"){
            
      $map[] = new Vector2($i$height $lineNumber 1);
          }
        }
      }
    3. Convert the mapped coordinates into runtime physical coordinates
      PHP:
      $scale 0.2;
      $particle = new FlameParticle(new Vector3);
      $yaw $player->yaw 180 M_PI;
      $xFactor = -sin($yaw) * $scale;
      $zFactor cos($yaw) * $scale;
      foreach(
      $map as $vector){
        
      $particle->$vector->y;
        
      $particle->$xFactor $vector->x;
        
      $particle->$zFactor $vector->x;
        
      $player->getLevel()->addParticle($particle);
      }
    Of course, cache the value of $map. Don't open-read-close a file every time. Even though the file is inside a phar, it will still create notable lag if you do it every time.
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Yep, @thebigsmileXD has coded it very likely like that (but with more particles, the picture shows the plugin of him) BUT IT's N O T OPEN SOURCE!
  5. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    You don't even know my code. Its a PRIVATE plugin
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Wait... Would that work with everything I draw in the file?
  7. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    If you adjust scale enough it should work
    Particle handling isn't all that hard. FTP handling is f****** hard
    Here is some FTP MADNESS:
    PHP:
        public function updateAllFloatingTexts($playerLevelArray NULL){
            
    $this->hideAllFTPs();
            if(
    $playerLevelArray == NULL){
                
    $this->showAllFTPs();
            }else{
                foreach(
    $this->floatingTextConfig->getAll() as $configFT){
                    
    $configFT $configFT[0];
                    
    $this->FloatingTexts[$this->IndexFTC] = new FloatingText($this$this->getServer()->getLevelByName($configFT[0]), new Vector3($configFT[1], $configFT[2], $configFT[3]), $configFT[4]);
                    if(isset(
    $this->FloatingTexts)){
                        foreach(
    $this->getServer()->getOnlinePlayers() as $player){
                            foreach(
    $this->FloatingTexts as $FloatingTextObject){
                                if(!isset(
    $playerLevelArray[$player->getName()])){
                                    
    $playerLevel $player->getLevel()->getName();
                                }else{
                                    
    $playerLevel $playerLevelArray[$player->getName()];
                                }
                                
    $FloatingTextLevel $FloatingTextObject->getLevel()->getName();
                                
    //echo("Checking "."PlayerLevel: ".$playerLevel." FTPLevel: ".$FloatingTextLevel." PlayerName: " . $player->getName() . "\n");
                                
    if($playerLevel == $FloatingTextLevel){
                                    
    $FloatingTextObject->update($player);
                                    
    //echo("Re-Created "."PlayerLevel: ".$playerLevel." FTPLevel: ".$FloatingTextLevel." PlayerName: " . $player->getName() . "\n");
                                
    }
                            }
                        }
                    }
                    
    $this->IndexFTC++;
                }
            }
        }

        public function 
    hideAllFTPs(){
            if(isset(
    $this->FloatingTexts)){
                foreach(
    $this->FloatingTexts as $FloatingTextObject){
                    
    $FloatingTextObject->setInvisible(true);
                }
            }
            unset(
    $this->FloatingTexts);
            
    $this->IndexFTC 0;
        }

        public function 
    showAllFTPs(){
            foreach(
    $this->floatingTextConfig->getAll() as $configFT){
                
    $configFT $configFT[0];
                
    $this->FloatingTexts[$this->IndexFTC] = new FloatingText($this$this->getServer()->getLevelByName($configFT[0]), new Vector3($configFT[1], $configFT[2], $configFT[3]), $configFT[4]);
                if(isset(
    $this->FloatingTexts)){
                    foreach(
    $this->getServer()->getOnlinePlayers() as $player){
                        foreach(
    $this->FloatingTexts as $FloatingTextObject){
                            
    $playerLevel $player->getLevel()->getName();
                            
    $FloatingTextLevel $FloatingTextObject->getLevel()->getName();
                            
    //echo("Checking "."PlayerLevel: ".$playerLevel." FTPLevel: ".$FloatingTextLevel." PlayerName: " . $player->getName() . "\n");
                            
    if($playerLevel == $FloatingTextLevel){
                                
    $FloatingTextObject->update($player);
                                
    //echo("Re-Created "."PlayerLevel: ".$playerLevel." FTPLevel: ".$FloatingTextLevel." PlayerName: " . $player->getName() . "\n");
                            
    }
                        }
                    }
                }
                
    $this->IndexFTC++;
            }
        }
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes. You can even use multiple symbols in your file to represent different particles.
    You realize that you are talking in front of an open-source terrorist, right? :p
  9. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    *terrorists (Including me)
    [Although not all of my code is open source, but only because it's so bad, I still have much to learn]
  10. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    OMG why aren't you BANNED >.<
    thebigsmileXD likes this.
  11. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Idk.

    But still. @Tim // robske Büba just posted content stolen from an closed code paid plugin, which is illegal.
    Yes, that was ORIGINALLY the way i did it. Hooray, mapped arrays. Always a good way.

    But now i get different particle types etc from the config. Configurable wings. High 5, yml.
    Sure, have fun with wings spawning INSIDE the player.
    You generate the particles at the players position. Not cool. You would always have the particles in your face in first person.
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    You can always change it to make it work...
    applqpak likes this.
  13. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    And 1 more thing.

    Why the whole wing, not just an half?
  14. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Well, i did. He didn't. It was just a remembering for PEMapModder that this will happen.
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What if I want the two sides to be different? Actually if I am making the plugin myself, I would even make the wings 3D, but since this is just an example I don't need to be so serious ;P
    What?
    Actually, the code above should create a pair of wings in front of the player, both of them, perpendicular to the one in the image, but that doesn't matter, just swap $factorX and $factorZ :p
    Actually the bitmap format I mentioned was supposed to be used in https://github.com/LegendOfMCPE/Vehicles, but it never got finished because I was waiting for the addition of vehicles that time (and you know what's the result).
    Not really. Not really in the face. The wings aren't that high if you use the height in my code.

    Also, could you make your tone a bit less hostile ;) maybe you didn't mean it, but it gives me that impression like you're trying to pick a fight.
  16. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I can bet that you find this out of your own failures.
  17. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    Thx but $line[$i] I Think Thats better then $line{$i}
    Why ?
    Some Peepol he donot know what is $line{$i} I Think $line[$i] is famous
    That is just Suggestion
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is just my own practice (common practice) that [$i] is used for arrays and {$i} is used for strings (seems @shoghicp is doing this too).
  19. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    Thats good
  20. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Nope. I didn't fail. @isoz wanted me to change it so it wont happen.

Share This Page

Advertisement