Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Added support for PocketMine-MP 5.0.0-ALPHA1 #280

Merged
merged 4 commits into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
</p>


## 👍 1.7.0 Update:
> **ALPHA VERSION!**
> This is an alpha version. This version can contain bugs. Please report them to help MultiWorld to get better for PM5.

> - Bug fixes
> - Update to PocketMine 4.x api
## 👍 1.8.0-ALPHA1 Update:

> - Update to PocketMine 5.x api


## ⬇️ Downloads:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"ext-pthreads": "*",
"ext-json": "*",
"czechpmdevs/libpmform": "dev-main",
"pocketmine/pocketmine-mp": "^4.4.0-BETA1"
"pocketmine/pocketmine-mp": "^5.0.0-ALPHA1"
},
"require-dev": {
"phpstan/phpstan": "1.7.1"
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: MultiWorld
author: CzechPMDevs
authors: [VixikCZ, fuyutsuki, kaliiks]
api: 4.0.0
version: 1.7.0
api: 5.0.0
version: 1.8.0-ALPHA1
main: czechpmdevs\multiworld\MultiWorld
description: Plugin that manage with worlds
website: https://github.com/CzechPMDevs/MultiWorld
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function generateChunk(ChunkManager $world, int $chunkX, int $chunkZ): vo
$chunk = $world->getChunk($chunkX, $chunkZ);
$noise = $this->noiseBase->getFastNoise2D(16, 16, 2, $chunkX * 16, 0, $chunkZ * 16);

$endStone = VanillaBlocks::END_STONE()->getFullId();
$endStone = VanillaBlocks::END_STONE()->getStateId();

$baseX = $chunkX * Chunk::EDGE_LENGTH;
$baseZ = $chunkZ * Chunk::EDGE_LENGTH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function populate(ChunkManager $world, int $chunkX, int $chunkZ, Random $

$centerY = $this->getWorkableBlockAt($chunk, $relativeX, $relativeZ) - 1;

$air = VanillaBlocks::AIR()->getFullId();
$air = VanillaBlocks::AIR()->getStateId();
if($chunk->getFullBlock($relativeX, $centerY, $relativeZ) === $air) {
return;
}
Expand Down Expand Up @@ -83,7 +83,7 @@ public function populate(ChunkManager $world, int $chunkX, int $chunkZ, Random $
}

private function getWorkableBlockAt(Chunk $chunk, int $x, int $z): int {
$air = VanillaBlocks::AIR()->getFullId();
$air = VanillaBlocks::AIR()->getStateId();
for($y = EnderGenerator::MAX_BASE_ISLAND_HEIGHT, $maxY = EnderGenerator::MAX_BASE_ISLAND_HEIGHT + EnderGenerator::NOISE_SIZE; $y <= $maxY; ++$y ) {
if($chunk->getFullBlock($x, $y, $z) === $air) {
return $y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public function generateChunk(ChunkManager $world, int $chunkX, int $chunkZ): vo
/** @var Chunk $chunk */
$chunk = $world->getChunk($chunkX, $chunkZ);

$bedrock = VanillaBlocks::BEDROCK()->getFullId();
$netherrack = VanillaBlocks::NETHERRACK()->getFullId();
$stillLava = VanillaBlocks::LAVA()->getFullId();
$bedrock = VanillaBlocks::BEDROCK()->getStateId();
$netherrack = VanillaBlocks::NETHERRACK()->getStateId();
$stillLava = VanillaBlocks::LAVA()->getStateId();

for($x = 0; $x < 16; ++$x) {
for($z = 0; $z < 16; ++$z) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public function generateChunk(ChunkManager $world, int $chunkX, int $chunkZ): vo

$biomeCache = [];

$bedrock = VanillaBlocks::BEDROCK()->getFullId();
$stillWater = VanillaBlocks::WATER()->getFullId();
$stone = VanillaBlocks::STONE()->getFullId();
$bedrock = VanillaBlocks::BEDROCK()->getStateId();
$stillWater = VanillaBlocks::WATER()->getStateId();
$stone = VanillaBlocks::STONE()->getStateId();

$baseX = $chunkX * 16;
$baseZ = $chunkZ * 16;
Expand Down
46 changes: 34 additions & 12 deletions src/czechpmdevs/multiworld/generator/normal/object/AcaciaTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@

namespace czechpmdevs\multiworld\generator\normal\object;

use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\math\Vector2;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
use pocketmine\world\ChunkManager;
use function abs;
use function in_array;

class AcaciaTree extends Tree {

Expand All @@ -37,9 +38,9 @@ public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random
$i = $random->nextBoundedInt(3) + $random->nextBoundedInt(3) + 5;

$down = $position->down();
$block = $world->getBlockAt($down->getFloorX(), $down->getFloorY(), $down->getFloorZ())->getId();
$block = $world->getBlockAt($down->getFloorX(), $down->getFloorY(), $down->getFloorZ())->getTypeId();

if(($block == BlockLegacyIds::GRASS || $block == BlockLegacyIds::DIRT) && $position->getY() < 256 - $i - 1) {
if(($block == BlockTypeIds::GRASS || $block == BlockTypeIds::DIRT) && $position->getY() < 256 - $i - 1) {
/** @phpstan-ignore-next-line */
$world->setBlockAt($position->getX(), $position->getY() - 1, $position->getZ(), VanillaBlocks::DIRT());
$face = $random->nextRange(0, 3);
Expand All @@ -59,9 +60,16 @@ public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random
}

$blockpos = new Vector3($i3, $i2, $j1);
$material = $world->getBlockAt($blockpos->getFloorX(), $blockpos->getFloorY(), $blockpos->getFloorZ())->getId();

if($material == BlockLegacyIds::AIR || $material == BlockLegacyIds::LEAVES) {
$material = $world->getBlockAt($blockpos->getFloorX(), $blockpos->getFloorY(), $blockpos->getFloorZ())->getTypeId();

if($material == BlockTypeIds::AIR || in_array($material, [
BlockTypeIds::ACACIA_LEAVES,
BlockTypeIds::BIRCH_LEAVES,
BlockTypeIds::JUNGLE_LEAVES,
BlockTypeIds::OAK_LEAVES,
BlockTypeIds::DARK_OAK_LEAVES,
BlockTypeIds::SPRUCE_LEAVES
])) {
$this->placeLogAt($world, $blockpos);
$k1 = $i2;
}
Expand Down Expand Up @@ -104,9 +112,16 @@ public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random
$i3 += $this->getXYFromDirection($face)->getX();
$j1 += $this->getXYFromDirection($face)->getY();
$blockpos1 = new Vector3($i3, $j2, $j1);
$material1 = $world->getBlockAt($blockpos1->getFloorX(), $blockpos1->getFloorY(), $blockpos1->getFloorZ())->getId();

if($material1 == BlockLegacyIds::AIR || $material1 == BlockLegacyIds::LEAVES) {
$material1 = $world->getBlockAt($blockpos1->getFloorX(), $blockpos1->getFloorY(), $blockpos1->getFloorZ())->getTypeId();

if($material1 == BlockTypeIds::AIR || in_array($material1, [
BlockTypeIds::ACACIA_LEAVES,
BlockTypeIds::BIRCH_LEAVES,
BlockTypeIds::JUNGLE_LEAVES,
BlockTypeIds::OAK_LEAVES,
BlockTypeIds::DARK_OAK_LEAVES,
BlockTypeIds::SPRUCE_LEAVES
])) {
$this->placeLogAt($world, $blockpos1);
$k1 = $j2;
}
Expand Down Expand Up @@ -157,9 +172,16 @@ private function placeLogAt(ChunkManager $worldIn, Vector3 $pos): void {
}

private function placeLeafAt(ChunkManager $worldIn, Vector3 $pos): void {
$material = $worldIn->getBlockAt($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ())->getId();

if($material == BlockLegacyIds::AIR || $material == BlockLegacyIds::LEAVES) {
$material = $worldIn->getBlockAt($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ())->getTypeId();

if($material == BlockTypeIds::AIR || in_array($material, [
BlockTypeIds::ACACIA_LEAVES,
BlockTypeIds::BIRCH_LEAVES,
BlockTypeIds::JUNGLE_LEAVES,
BlockTypeIds::OAK_LEAVES,
BlockTypeIds::DARK_OAK_LEAVES,
BlockTypeIds::SPRUCE_LEAVES
])) {
$worldIn->setBlockAt((int)$pos->getX(), (int)$pos->getY(), (int)$pos->getZ(), VanillaBlocks::ACACIA_LEAVES());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace czechpmdevs\multiworld\generator\normal\object;

use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
Expand Down Expand Up @@ -106,7 +106,7 @@ public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random
$sizeZ = abs($zz) + 0.5;
if($sizeX * $sizeX + $sizeZ * $sizeZ <= $size * $size && $node->getY() + $yy - 3 >= $y) {
/** @phpstan-ignore-next-line */
if($world->getBlockAt($node->getX() + $xx, $node->getY() + $yy, $node->getZ() + $zz)->getId() == BlockLegacyIds::AIR) {
if($world->getBlockAt($node->getX() + $xx, $node->getY() + $yy, $node->getZ() + $zz)->getTypeId() == BlockTypeIds::AIR) {
/** @phpstan-ignore-next-line */
$world->setBlockAt($node->getX() + $xx, $node->getY() + $yy, $node->getZ() + $zz, VanillaBlocks::OAK_LEAVES());
}
Expand Down
15 changes: 11 additions & 4 deletions src/czechpmdevs/multiworld/generator/normal/object/DarkOakTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace czechpmdevs\multiworld\generator\normal\object;

use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\utils\Random;
use pocketmine\world\ChunkManager;
Expand Down Expand Up @@ -56,9 +56,16 @@ public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random
}

$y2 = $y + $x2;
$material = $world->getBlockAt($x1, $y2, $z1)->getId();

if($material == BlockLegacyIds::AIR || $material == BlockLegacyIds::LEAVES) {
$material = $world->getBlockAt($x1, $y2, $z1)->getTypeId();

if($material == BlockTypeIds::AIR || in_array($material, [
BlockTypeIds::ACACIA_LEAVES,
BlockTypeIds::BIRCH_LEAVES,
BlockTypeIds::JUNGLE_LEAVES,
BlockTypeIds::OAK_LEAVES,
BlockTypeIds::DARK_OAK_LEAVES,
BlockTypeIds::SPRUCE_LEAVES
])) {
$world->setBlockAt($x1, $y2, $z1, VanillaBlocks::DARK_OAK_WOOD());
$world->setBlockAt($x1 + 1, $y2, $z1, VanillaBlocks::DARK_OAK_WOOD());
$world->setBlockAt($x1 + 1, $y2, $z1 + 1, VanillaBlocks::DARK_OAK_WOOD());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class HugeMushroom extends Tree {

// public function __construct() {
// $this->overridable[BlockLegacyIds::MYCELIUM] = true;
// $this->overridable[BlockTypeIds::MYCELIUM] = true;
// }

public function placeObject(ChunkManager $world, int $spawnX, int $spawnY, int $spawnZ, Random $random): void {
Expand Down
49 changes: 35 additions & 14 deletions src/czechpmdevs/multiworld/generator/normal/object/SwampTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace czechpmdevs\multiworld\generator\normal\object;

use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
Expand All @@ -38,9 +38,9 @@ public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random
$i = $random->nextBoundedInt(4) + 5;

$down = $position->down();
$block = $world->getBlockAt($down->getFloorX(), $down->getFloorY(), $down->getFloorZ())->getId();
$block = $world->getBlockAt($down->getFloorX(), $down->getFloorY(), $down->getFloorZ())->getTypeId();

if(($block == BlockLegacyIds::GRASS || $block == BlockLegacyIds::DIRT) && $position->getY() < 256 - $i - 1) {
if(($block == BlockTypeIds::GRASS || $block == BlockTypeIds::DIRT) && $position->getY() < 256 - $i - 1) {
$world->setBlockAt($down->getFloorX(), $down->getFloorY(), $down->getFloorZ(), VanillaBlocks::DIRT());

for($k1 = $position->getY() - 3 + $i; $k1 <= $position->getY() + $i; ++$k1) {
Expand All @@ -54,8 +54,15 @@ public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random
$j1 = $i4 - $position->getZ();

if(abs($k3) != $l2 || abs($j1) != $l2 || $random->nextBoundedInt(2) != 0 && $j2 != 0) {
$id = $world->getBlockAt((int)$j3, (int)$k1, (int)$i4)->getId();
if($id == BlockLegacyIds::AIR || $id == BlockLegacyIds::LEAVES || $id == BlockLegacyIds::VINE) {
$id = $world->getBlockAt((int)$j3, (int)$k1, (int)$i4)->getTypeId();
if($id == BlockTypeIds::AIR || in_array($id, [
BlockTypeIds::ACACIA_LEAVES,
BlockTypeIds::BIRCH_LEAVES,
BlockTypeIds::JUNGLE_LEAVES,
BlockTypeIds::OAK_LEAVES,
BlockTypeIds::DARK_OAK_LEAVES,
BlockTypeIds::SPRUCE_LEAVES
]) || $id == BlockTypeIds::VINES) {
$world->setBlockAt((int)$j3, (int)$k1, (int)$i4, VanillaBlocks::OAK_LEAVES());
}
}
Expand All @@ -65,9 +72,16 @@ public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random

for($l1 = 0; $l1 < $i; ++$l1) {
$up = $position->up($l1);
$id = $world->getBlockAt($position->getFloorX(), $up->getFloorY(), $position->getFloorZ())->getId();

if($id == BlockLegacyIds::AIR || $id == BlockLegacyIds::LEAVES || $id == BlockLegacyIds::WATER || $id == BlockLegacyIds::STILL_WATER) {
$id = $world->getBlockAt($position->getFloorX(), $up->getFloorY(), $position->getFloorZ())->getTypeId();

if($id == BlockTypeIds::AIR || in_array($id, [
BlockTypeIds::ACACIA_LEAVES,
BlockTypeIds::BIRCH_LEAVES,
BlockTypeIds::JUNGLE_LEAVES,
BlockTypeIds::OAK_LEAVES,
BlockTypeIds::DARK_OAK_LEAVES,
BlockTypeIds::SPRUCE_LEAVES
]) || $id == BlockTypeIds::WATER) {
$world->setBlockAt((int)$up->getX(), (int)$up->getY(), (int)$up->getZ(), VanillaBlocks::OAK_WOOD());
}
}
Expand All @@ -80,25 +94,32 @@ public function placeObject(ChunkManager $world, int $x, int $y, int $z, Random
for($j4 = $position->getZ() - $i3; $j4 <= $position->getZ() + $i3; ++$j4) {
$pos2 = new Vector3($l3, $i2, $j4);

if($world->getBlockAt((int)$pos2->x, (int)$pos2->y, (int)$pos2->z)->getId() == BlockLegacyIds::LEAVES) {
if(in_array($world->getBlockAt((int)$pos2->x, (int)$pos2->y, (int)$pos2->z)->getTypeId(), [
BlockTypeIds::ACACIA_LEAVES,
BlockTypeIds::BIRCH_LEAVES,
BlockTypeIds::JUNGLE_LEAVES,
BlockTypeIds::OAK_LEAVES,
BlockTypeIds::DARK_OAK_LEAVES,
BlockTypeIds::SPRUCE_LEAVES
])) {
$blockpos2 = $pos2->west();
$blockpos3 = $pos2->east();
$blockpos4 = $pos2->north();
$blockpos1 = $pos2->south();

if($random->nextBoundedInt(4) == 0 && $world->getBlockAt((int)$blockpos2->x, (int)$blockpos2->y, (int)$blockpos2->z)->getId() == BlockLegacyIds::AIR) {
if($random->nextBoundedInt(4) == 0 && $world->getBlockAt((int)$blockpos2->x, (int)$blockpos2->y, (int)$blockpos2->z)->getTypeId() == BlockTypeIds::AIR) {
$this->addHangingVine($world, $blockpos2);
}

if($random->nextBoundedInt(4) == 0 && $world->getBlockAt((int)$blockpos3->x, (int)$blockpos3->y, (int)$blockpos3->z)->getId() == BlockLegacyIds::AIR) {
if($random->nextBoundedInt(4) == 0 && $world->getBlockAt((int)$blockpos3->x, (int)$blockpos3->y, (int)$blockpos3->z)->getTypeId() == BlockTypeIds::AIR) {
$this->addHangingVine($world, $blockpos3);
}

if($random->nextBoundedInt(4) == 0 && $world->getBlockAt((int)$blockpos4->x, (int)$blockpos4->y, (int)$blockpos4->z)->getId() == BlockLegacyIds::AIR) {
if($random->nextBoundedInt(4) == 0 && $world->getBlockAt((int)$blockpos4->x, (int)$blockpos4->y, (int)$blockpos4->z)->getTypeId() == BlockTypeIds::AIR) {
$this->addHangingVine($world, $blockpos4);
}

if($random->nextBoundedInt(4) == 0 && $world->getBlockAt((int)$blockpos1->x, (int)$blockpos1->y, (int)$blockpos1->z)->getId() == BlockLegacyIds::AIR) {
if($random->nextBoundedInt(4) == 0 && $world->getBlockAt((int)$blockpos1->x, (int)$blockpos1->y, (int)$blockpos1->z)->getTypeId() == BlockTypeIds::AIR) {
$this->addHangingVine($world, $blockpos1);
}
}
Expand All @@ -112,7 +133,7 @@ private function addHangingVine(ChunkManager $worldIn, Vector3 $pos): void {
$this->addVine($worldIn, $pos);
$i = 4;

for($pos = $pos->down(); $i > 0 && $worldIn->getBlockAt((int)$pos->x, (int)$pos->y, (int)$pos->z)->getId() == BlockLegacyIds::AIR; --$i) {
for($pos = $pos->down(); $i > 0 && $worldIn->getBlockAt((int)$pos->x, (int)$pos->y, (int)$pos->z)->getTypeId() == BlockTypeIds::AIR; --$i) {
$this->addVine($worldIn, $pos);
$pos = $pos->down();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function getSpawnPositionOn(?Chunk $chunk, Random $random, array $requ
return false;
}

$requiredUnderground = array_map(fn(Block $block) => $block->getFullId(), $requiredUnderground);
$requiredUnderground = array_map(fn(Block $block) => $block->getStateId(), $requiredUnderground);

$i = 0;
do {
Expand Down
Loading