Skip to content

Commit

Permalink
Large Schematic Muqsit#1 Attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
benda95280 committed Jun 2, 2020
1 parent 711a494 commit dfff05b
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/muqsit/worldstyler/schematics/Schematic.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use muqsit\worldstyler\utils\BlockIterator;
use muqsit\worldstyler\utils\Utils;

use wumpotamus\chunkloader\ChunkRegion;

use pocketmine\level\ChunkManager;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
Expand Down Expand Up @@ -72,23 +74,26 @@ public function paste(ChunkManager $level, Vector3 $relative_pos, bool $replace_
for ($z = 0; $z < $length; ++$z) {
$zPos = $z + $relz;
$zwx = $z * $width + $x;

for ($y = 0; $y < $height; ++$y) {
$index = $y * $wl + $zwx;

$id = ord($blockIds{$index});
$damage = ord($blockDatas{$index});

if ($replace_pc_blocks && isset(Utils::REPLACEMENTS[$id])) {
[$new_id, $new_damage] = Utils::REPLACEMENTS[$id][$damage] ?? Utils::REPLACEMENTS[$id][-1] ?? [$id, $damage];
$id = $new_id ?? $id;
$damage = $new_damage ?? $damage;
}

$yPos = $y + $rely;
$iterator->moveTo($xPos, $yPos, $zPos);
$iterator->currentSubChunk->setBlock($xPos & 0x0f, $yPos & 0x0f, $zPos & 0x0f, $id, $damage);
}

ChunkRegion::onChunkGenerated($level, $xPos >> 4, $zPos >> 4, function() use($rely, $replace_pc_blocks, $iterator, $xPos, $zPos, $height, $wl, $zwx, $blockIds, $blockDatas){
for ($y = 0; $y < $height; ++$y) {
$index = $y * $wl + $zwx;

$id = ord($blockIds{$index});
$damage = ord($blockDatas{$index});

if ($replace_pc_blocks && isset(Utils::REPLACEMENTS[$id])) {
[$new_id, $new_damage] = Utils::REPLACEMENTS[$id][$damage] ?? Utils::REPLACEMENTS[$id][-1] ?? [$id, $damage];
$id = $new_id ?? $id;
$damage = $new_damage ?? $damage;
}

$yPos = $y + $rely;
$iterator->moveTo($xPos, $yPos, $zPos);
$iterator->currentSubChunk->setBlock($xPos & 0x0f, $yPos & 0x0f, $zPos & 0x0f, $id, $damage);
}
});
$level->unloadChunk( $xPos >> 4, $zPos >> 4);
}
}

Expand Down

0 comments on commit dfff05b

Please sign in to comment.