Hi, Currently for a blockParty minigame, this code below is used to reset the floor and set the block colors of the floor. At the moment this piece of code sets a certain block color with size 3x3. PHP: public function resetFloor(){ $colorcount = 0; $blocks = 0; $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 += 3){ 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 += 3){ $blocks++; $color = rand(0, 15); if($colorcount === 0 && $blocks === 15 || $colorcount <= 1 && $blocks === 40){ $color = $this->currentColor; } $block = Block::get($this->getBlock(), $color); if($block->getDamage() === $this->currentColor){ $colorcount++; } $level->setBlock(new Position($x, $y, $z, $level), $block, false, true); $level->setBlock(new Position($x, $y, $z+1, $level), $block, false, true); $level->setBlock(new Position($x, $y, $z+2, $level), $block, false, true); $level->setBlock(new Position($x+1, $y, $z, $level), $block, false, true); $level->setBlock(new Position($x+1, $y, $z+1, $level), $block, false, true); $level->setBlock(new Position($x+1, $y, $z+2, $level), $block, false, true); $level->setBlock(new Position($x+2, $y, $z, $level), $block, false, true); $level->setBlock(new Position($x+2, $y, $z+1, $level), $block, false, true); $level->setBlock(new Position($x+2, $y, $z+2, $level), $block, false, true); } } } However, I would like it so that it only sets the color blocks as 1x1 not 3x3. How can I achieve this thru editing the code above? Any help would be very appreciated
remove all of these: PHP: $level->setBlock(new Position($x, $y, $z+1, $level), $block, false, true);$level->setBlock(new Position($x, $y, $z+2, $level), $block, false, true);$level->setBlock(new Position($x+1, $y, $z, $level), $block, false, true);$level->setBlock(new Position($x+1, $y, $z+1, $level), $block, false, true);$level->setBlock(new Position($x+1, $y, $z+2, $level), $block, false, true);$level->setBlock(new Position($x+2, $y, $z, $level), $block, false, true);$level->setBlock(new Position($x+2, $y, $z+1, $level), $block, false, true);$level->setBlock(new Position($x+2, $y, $z+2, $level), $block, false, true);
After removing those and only leaving these 2 lines PHP: $level->setBlock(new Position($x, $y, $z, $level), $block, false, true); $level->setBlock(new Position($x, $y, $z+1, $level), $block, false, true); This is the result: https://www.imgur.com/a/zn3hU
Just leave this line: PHP: $level->setBlock(new Position($x, $y, $z, $level), $block, false, true); The additions and subtractions to the $x and $z are what make it 3x3. If you really want it to be 1x1 without any chance of any blocks going next to one another, I'd check the blocks around it to see if they match the color about to be set, and if so, change the color.