Skip to content

Commit

Permalink
PocketMine-MP v5.0.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Muqsit committed Jun 1, 2023
1 parent 661f77b commit 7992beb
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 263 deletions.
4 changes: 2 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: WorldBuilder
main: cosmicpe\worldbuilder\Loader
api: 4.0.0
version: 0.0.2
api: 5.0.0
version: 0.0.3
author: CosmicPE
commands:
/copy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use cosmicpe\worldbuilder\editor\utils\replacement\BlockToBlockReplacementMap;
use cosmicpe\worldbuilder\Loader;
use cosmicpe\worldbuilder\session\utils\Selection;
use pocketmine\block\BlockFactory;
use pocketmine\block\RuntimeBlockStateRegistry;
use pocketmine\block\VanillaBlocks;
use pocketmine\block\Water;
use pocketmine\command\Command;
Expand All @@ -31,7 +31,7 @@ public function __construct(

$this->map = new BlockToBlockReplacementMap();
$air = VanillaBlocks::AIR();
foreach(BlockFactory::getInstance()->getAllKnownStates() as $state){
foreach(RuntimeBlockStateRegistry::getInstance()->getAllKnownStates() as $state){
if($state instanceof Water){
$this->map->put($state, $air);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function executeCommand(CommandSender $sender, \pocketmine\command\Com
return true;
}

$randomizer->add($replacement_block->getFullId(), $weight);
$randomizer->add($replacement_block->getStateId(), $weight);
}

$randomizer->setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function executeCommand(CommandSender $sender, \pocketmine\command\Com
return true;
}

$randomizer->add($block->getFullId(), $weight);
$randomizer->add($block->getStateId(), $weight);
}

$randomizer->setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace cosmicpe\worldbuilder\editor\format;

use cosmicpe\worldbuilder\editor\format\mcschematic\MinecraftSchematicEditorFormat;
use InvalidArgumentException;

final class EditorFormatRegistry{
Expand All @@ -13,7 +12,6 @@ final class EditorFormatRegistry{
private array $formats = [];

public function __construct(){
$this->register(EditorFormatIds::MINECRAFT_SCHEMATIC, new MinecraftSchematicEditorFormat());
}

public function register(string $identifier, EditorFormat $format) : void{
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions src/cosmicpe/worldbuilder/editor/task/ReplaceEditorTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function getName() : string{
}

protected function onIterate(SubChunkIteratorCursor $cursor) : bool{
if(isset($this->replacement_map[$find = $cursor->sub_chunk->getFullBlock($cursor->x, $cursor->y, $cursor->z)])){
$cursor->sub_chunk->setFullBlock($cursor->x, $cursor->y, $cursor->z, $this->replacement_map[$find]);
if(isset($this->replacement_map[$find = $cursor->sub_chunk->getBlockStateId($cursor->x, $cursor->y, $cursor->z)])){
$cursor->sub_chunk->setBlockStateId($cursor->x, $cursor->y, $cursor->z, $this->replacement_map[$find]);
$tile = $cursor->chunk->getTile($cursor->x, ($cursor->subChunkY << Chunk::COORD_BIT_SIZE) + $cursor->y, $cursor->z);
if($tile !== null){
$cursor->chunk->removeTile($tile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function getName() : string{
}

protected function onIterate(SubChunkIteratorCursor $cursor) : bool{
if(isset($this->replacement_map[$find = $cursor->sub_chunk->getFullBlock($cursor->x, $cursor->y, $cursor->z)])){
$cursor->sub_chunk->setFullBlock($cursor->x, $cursor->y, $cursor->z, $this->replacement_map[$find]->generate(1)->current());
if(isset($this->replacement_map[$find = $cursor->sub_chunk->getBlockStateId($cursor->x, $cursor->y, $cursor->z)])){
$cursor->sub_chunk->setBlockStateId($cursor->x, $cursor->y, $cursor->z, $this->replacement_map[$find]->generate(1)->current());
$tile = $cursor->chunk->getTile($cursor->x, ($cursor->subChunkY << Chunk::COORD_BIT_SIZE) + $cursor->y, $cursor->z);
if($tile !== null){
$cursor->chunk->removeTile($tile);
Expand Down
8 changes: 7 additions & 1 deletion src/cosmicpe/worldbuilder/editor/task/SetBiomeEditorTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
class SetBiomeEditorTask extends AdvancedPlaneEditorTask{

private int $biome_id;
private int $min_y;
private int $max_y;

public function __construct(World $world, Selection $selection, int $biome_id){
parent::__construct($world, $selection, (int) Vector3Utils::calculateVolume($selection->getPoint(0), $selection->getPoint(1)));
$this->biome_id = $biome_id;
$this->min_y = $world->getMinY();
$this->max_y = $world->getMaxY();
}

final public function getBiomeId() : int{
Expand All @@ -27,7 +31,9 @@ public function getName() : string{
}

protected function onIterate(ChunkIteratorCursor $cursor) : bool{
$cursor->chunk->setBiomeId($cursor->x, $cursor->z, $this->biome_id);
for($y = $this->min_y; $y < $this->max_y; ++$y) {
$cursor->chunk->setBiomeId($cursor->x, $y, $cursor->z, $this->biome_id);
}
return true;
}
}
8 changes: 4 additions & 4 deletions src/cosmicpe/worldbuilder/editor/task/SetEditorTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use cosmicpe\worldbuilder\session\utils\Selection;
use cosmicpe\worldbuilder\utils\Vector3Utils;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\RuntimeBlockStateRegistry;
use pocketmine\world\format\Chunk;
use pocketmine\world\World;

Expand All @@ -18,19 +18,19 @@ class SetEditorTask extends AdvancedEditorTask{

public function __construct(World $world, Selection $selection, Block $block){
parent::__construct($world, $selection, (int) Vector3Utils::calculateVolume($selection->getPoint(0), $selection->getPoint(1)));
$this->full_block = $block->getFullId();
$this->full_block = $block->getStateId();
}

final public function getBlockSet() : Block{
return BlockFactory::getInstance()->fromFullBlock($this->full_block);
return RuntimeBlockStateRegistry::getInstance()->fromStateId($this->full_block);
}

public function getName() : string{
return "set";
}

protected function onIterate(SubChunkIteratorCursor $cursor) : bool{
$cursor->sub_chunk->setFullBlock($cursor->x, $cursor->y, $cursor->z, $this->full_block);
$cursor->sub_chunk->setBlockStateId($cursor->x, $cursor->y, $cursor->z, $this->full_block);
$tile = $cursor->chunk->getTile($cursor->x, ($cursor->subChunkY << Chunk::COORD_BIT_SIZE) + $cursor->y, $cursor->z);
if($tile !== null){
$cursor->chunk->removeTile($tile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getName() : string{
}

protected function onIterate(SubChunkIteratorCursor $cursor) : bool{
$cursor->sub_chunk->setFullBlock($cursor->x, $cursor->y, $cursor->z, $this->selector->generate(1)->current());
$cursor->sub_chunk->setBlockStateId($cursor->x, $cursor->y, $cursor->z, $this->selector->generate(1)->current());
$tile = $cursor->chunk->getTile($cursor->x, ($cursor->subChunkY << Chunk::COORD_BIT_SIZE) + $cursor->y, $cursor->z);
if($tile !== null){
$cursor->chunk->removeTile($tile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function run() : Generator{
$tiles[] = $tile_factory->createFromData($world, NamedtagCopierManager::moveTo($entry->tile_nbt, $x, $y, $z));
}

$iterator->currentSubChunk->setFullBlock($x & Chunk::COORD_MASK, $y & Chunk::COORD_MASK, $z & Chunk::COORD_MASK, $entry->full_block);
$iterator->currentSubChunk->setBlockStateId($x & Chunk::COORD_MASK, $y & Chunk::COORD_MASK, $z & Chunk::COORD_MASK, $entry->block_state_id);
$chunks[World::chunkHash($x >> Chunk::COORD_BIT_SIZE, $z >> Chunk::COORD_BIT_SIZE)] = true;
yield true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function onIterate(SubChunkIteratorCursor $cursor) : bool{
$y - $this->minimum->y,
($cursor->chunkZ << Chunk::COORD_BIT_SIZE) + $cursor->z - $this->minimum->z,
new SchematicEntry(
$cursor->sub_chunk->getFullBlock($cursor->x, $cursor->y, $cursor->z),
$cursor->sub_chunk->getBlockStateId($cursor->x, $cursor->y, $cursor->z),
$tile !== null ? NamedtagCopierManager::copy($tile) : null
)
);
Expand Down
Loading

0 comments on commit 7992beb

Please sign in to comment.