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. Offline

### MCPEPIGNotable Member

Joined:
Jun 22, 2014
Posts:
349
Minecraft User:
What's the simplest & best way to make the shape of wings with particles. Example:
2. Offline

### minebuilder0110Notable Member

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

### PEMapModderNotable MemberPlugin Developer

Joined:
Oct 9, 2013
Posts:
7,294
Plugins:
11
Minecraft User:
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->y = \$vector->y;  \$particle->x = \$xFactor * \$vector->x;  \$particle->z = \$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. Offline

### Tim // robske BübaNotable Member

Joined:
Feb 26, 2014
Posts:
606
Minecraft User:
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. Offline

### thebigsmileXDBanned

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

### Legoboy0215Notable Member

Joined:
Nov 1, 2014
Posts:
1,724
Minecraft User:
Wait... Would that work with everything I draw in the file?
7. Offline

### Tim // robske BübaNotable Member

Joined:
Feb 26, 2014
Posts:
606
Minecraft User:
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. Offline

### PEMapModderNotable MemberPlugin Developer

Joined:
Oct 9, 2013
Posts:
7,294
Plugins:
11
Minecraft User:
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?
9. Offline

### Tim // robske BübaNotable Member

Joined:
Feb 26, 2014
Posts:
606
Minecraft User:
*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. Offline

### Legoboy0215Notable Member

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

### thebigsmileXDBanned

Joined:
May 19, 2015
Posts:
845
Plugins:
1
Minecraft User:
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. Offline

### Legoboy0215Notable Member

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

### thebigsmileXDBanned

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

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

### thebigsmileXDBanned

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

### PEMapModderNotable MemberPlugin Developer

Joined:
Oct 9, 2013
Posts:
7,294
Plugins:
11
Minecraft User:
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
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. Offline

### PrimusNotable Member

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

### Nawaf_Craft1bActive MemberPlugin Developer

Joined:
May 8, 2015
Posts:
232
Plugins:
1
Minecraft User:
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. Offline

### PEMapModderNotable MemberPlugin Developer

Joined:
Oct 9, 2013
Posts:
7,294
Plugins:
11
Minecraft User:
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. Offline

### Nawaf_Craft1bActive MemberPlugin Developer

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

### thebigsmileXDBanned

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

Advertisement