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

fill area with blocks lag

Comments in 'Plugin Development' started by Creeperface, Jun 26, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    i have this function for fill area but when i call it, entire server hangs forever
    PHP:
    public function resetFloor(){
            
    $y $this->data['arena']['floor_y'];
            
    $level =  $this->plugin->getServer()->getLevelByName($this->data['arena']['arena_world']);
            for(
    $x min($this->data['arena']['first_corner_x'], $this->data['arena']['second_corner_x']); $x <= max($this->data['arena']['first_corner_x'], $this->data['arena']['second_corner_x']); $x+2){
                for(
    $z min($this->data['arena']['first_corner_z'], $this->data['arena']['second_corner_z']); $z <= max($this->data['arena']['first_corner_z'], $this->data['arena']['second_corner_z']); $z+2){
                    
    $color rand(015);
                    
    $block Block::get($this->plugin->getBlock($this->id), $color);
                    
    $level->setBlock(new Vector3($x$y$z), $blockfalsetrue);
                    
    $level->setBlock(new Vector3($x$y$z+1), $blockfalsetrue);
                    
    $level->setBlock(new Vector3($x+1$y$z), $blockfalsetrue);
                    
    $level->setBlock(new Vector3($x+1$y$z+1), $blockfalsetrue);
                }
            }
        }
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    Maby you went out with infinity loop?

    When you kill a server the floor is filled or not?
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    no because when i kill server map is not saved.
    and i looked for infinity loop but i didnĀ“t find anything, so i ask here.
    and $color is same for all 4 blocks right?
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    Idk i would test out with
    PHP:
    break;
    on both "for" loops to test infinity loop ! Then see if server still hangs if not check is anything changed at those pos.
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    i think there must be infinite loop but idk where
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    Why are you adding 2 not incrementing?
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    because i want to set 4 blocks in one color
  8. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    why are you using for($value1, $value; ....)
    is it possible

    Try with something simple with just 1 color then add colors
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
  10. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    no there is not $value1, $value2 there is function max() and min()
  11. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    PEMapModder likes this.
  12. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    yes i know :D (i think) and yes. I try only fill it with one type of block
  13. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    And did that worked? Try to output something to see where it stops.

    EDIT: Can you post your pos?
  14. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    it works now :D i cant use $x+2 but $x++
  15. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    Told ya! :p
    Falk likes this.
  16. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    You can do $x+=2 if you want that functionality.
    Creeperface likes this.
  17. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    thx!!!

Share This Page

Advertisement