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

Solved Create outline of square with particles

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

  1. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    What's the best way to create an outline of a square with particles?
  2. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Do you mean the outer part of a square? The walls of a square?
    If you want to create a aquare use this:
    PHP:
    public function squareParticles(){
            
    $startX 130;//STARTING POINT X
            
    $endX 140;//END POINT X
            
    $startY 4;//STARTING POINT Y
            
    $endY 14;//END POINT Y
            
    $startZ 130;//STARTING POINT Z
            
    $endZ 140;//END POINT Z
            
    for($x $startX$x <= $endX; ++$x){
                for(
    $y $startY$y <= $endY; ++$y){
                    for(
    $z $startZ$z <= $endZ; ++$z){
                        
    $level $this->getServer()->getLevelByName("world");
                        
    $level->addParticle(new DustParticle(new Vector3($x$y$z), 000));
                    }
                }
            }
        }
  3. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    I don't need an entire square, I need the outer part.
    PEMapModder likes this.
  4. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    PHP:
        public function squareParticles(){
            
    $startX 130;//STARTING POINT X
            
    $endX 140;//END POINT X
            
    $startY 4;//STARTING POINT Y
            
    $endY 14;//END POINT Y
            
    $startZ 130;//STARTING POINT Z
            
    $endZ 140;//END POINT Z
            
    for($x $startX$x <= $endX; ++$x){
                for(
    $y $startY$y <= $endY; ++$y){
                    for(
    $z $startZ$z <= $endZ; ++$z){
                        if(
                            
    $x == $startX || $x == $endX ||
                            
    $y == $startY || $y == $endY ||
                            
    $z == $startZ || $z == $endZ
                        
    ) {
                            
    $level $this->getServer()->getLevelByName("world");
                            
    $level->addParticle(new DustParticle(new Vector3($x$y$z), 000));
                        }
                    }
                }
            }
        }
  5. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Doesn't that only do the 2 corners?
  6. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Wait, nvm.
  7. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    PHP:
    $y == $startY || $y == $endY ||
    will make the function create an entire square btw :3
  8. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    No.
  9. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    $y == $startY... If $y == $startY, it'll spawn the particle...
  10. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    What?
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    This is too slow.
    (And this is a cuboid, not a square, but never mind)
    PHP:
    for($x $startX$x <= $endX$x++){
      
    addParticle($x$y$startZ);
      
    addParticle($x$y$endZ);
    }
    for(
    $z $startZ 1$z $endZ$z++){
      
    addParticle($startX$y$z);
      
    addParticle($endX$y$z);
    }
  12. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Ah OK. I heard `++$var` was faster.
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I am not sure about that, but I'm quite sure that the difference is very negligible. Both exist in low-level instructions, so there shouldn't really be any difference.
  14. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    http://php.net/manual/en/language.operators.increment.php Look in the comments, second from the top
  15. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    and the third says $var += 1 is the fastest
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    xXNiceAssassinlo likes this.

Share This Page

Advertisement