Skip to content

Commit e48a218

Browse files
committed
PM5.8: Move to native enums
1 parent 85c06a6 commit e48a218

File tree

7 files changed

+32
-32
lines changed

7 files changed

+32
-32
lines changed

plugin.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: VanillaGenerator
22
main: muqsit\vanillagenerator\Loader
3-
api: 5.0.0
3+
api: 5.8.0
44
version: 0.0.4
55
author: Muqsit
66
github: https://github.com/Muqsit

src/muqsit/vanillagenerator/generator/ground/DirtAndStonePatchGroundGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class DirtAndStonePatchGroundGenerator extends GroundGenerator{
1414
public function generateTerrainColumn(ChunkManager $world, Random $random, int $x, int $z, int $biome, float $surface_noise) : void{
1515
[$top, $ground] = match(true){
1616
$surface_noise > 1.75 => [VanillaBlocks::STONE(), VanillaBlocks::STONE()],
17-
$surface_noise > -0.5 => [VanillaBlocks::DIRT()->setDirtType(DirtType::COARSE()), VanillaBlocks::DIRT()],
17+
$surface_noise > -0.5 => [VanillaBlocks::DIRT()->setDirtType(DirtType::COARSE), VanillaBlocks::DIRT()],
1818
default => [VanillaBlocks::GRASS(), VanillaBlocks::DIRT()]
1919
};
2020
$this->setTopMaterial($top);

src/muqsit/vanillagenerator/generator/ground/DirtPatchGroundGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DirtPatchGroundGenerator extends GroundGenerator{
1313

1414
public function generateTerrainColumn(ChunkManager $world, Random $random, int $x, int $z, int $biome, float $surface_noise) : void{
1515
$this->setTopMaterial(match(true){
16-
$surface_noise > 1.75 => VanillaBlocks::DIRT()->setDirtType(DirtType::COARSE()),
16+
$surface_noise > 1.75 => VanillaBlocks::DIRT()->setDirtType(DirtType::COARSE),
1717
$surface_noise > -0.95 => VanillaBlocks::PODZOL(),
1818
default => VanillaBlocks::GRASS()
1919
});

src/muqsit/vanillagenerator/generator/ground/MesaGroundGenerator.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MesaGroundGenerator extends GroundGenerator{
3030
private ?int $seed = null;
3131

3232
public function __construct(int $type = self::NORMAL){
33-
parent::__construct(VanillaBlocks::RED_SAND(), VanillaBlocks::STAINED_CLAY()->setColor(DyeColor::ORANGE()));
33+
parent::__construct(VanillaBlocks::RED_SAND(), VanillaBlocks::STAINED_CLAY()->setColor(DyeColor::ORANGE));
3434
$this->type = $type;
3535
}
3636

@@ -81,7 +81,7 @@ public function generateTerrainColumn(ChunkManager $world, Random $random, int $
8181
$ground_set = false;
8282

8383
$grass = VanillaBlocks::GRASS();
84-
$coarse_dirt = VanillaBlocks::DIRT()->setDirtType(DirtType::COARSE());
84+
$coarse_dirt = VanillaBlocks::DIRT()->setDirtType(DirtType::COARSE);
8585

8686
for($y = 255; $y >= 0; --$y){
8787
if($y < (int) $bryce_canyon_height && $world->getBlockAt($x, $y, $z)->getTypeId() === BlockTypeIds::AIR){
@@ -109,7 +109,7 @@ public function generateTerrainColumn(ChunkManager $world, Random $random, int $
109109
$color = $this->color_layer[($y + (int) round(
110110
$this->color_noise->noise($chunk_x, $chunk_z, 0, 0.5, 2.0, false) * 2.0))
111111
% count($this->color_layer)];
112-
$this->setColoredGroundLayer($world, $x, $y, $z, $y < $sea_level || $y > 128 ? DyeColor::ORANGE() : ($colored ? $color : null));
112+
$this->setColoredGroundLayer($world, $x, $y, $z, $y < $sea_level || $y > 128 ? DyeColor::ORANGE : ($colored ? $color : null));
113113
}else{
114114
$world->setBlockAt($x, $y, $z, $this->top_material);
115115
$ground_set = true;
@@ -154,22 +154,22 @@ private function initializeColorLayers(Random $random) : void{
154154
while($i < count($this->color_layer)){
155155
$i += $random->nextBoundedInt(5) + 1;
156156
if($i < count($this->color_layer)){
157-
$this->color_layer[$i++] = DyeColor::ORANGE();
157+
$this->color_layer[$i++] = DyeColor::ORANGE;
158158
}
159159
}
160-
$this->setRandomLayerColor($random, 2, 1, DyeColor::YELLOW());
161-
$this->setRandomLayerColor($random, 2, 2, DyeColor::BROWN());
162-
$this->setRandomLayerColor($random, 2, 1, DyeColor::RED());
160+
$this->setRandomLayerColor($random, 2, 1, DyeColor::YELLOW);
161+
$this->setRandomLayerColor($random, 2, 2, DyeColor::BROWN);
162+
$this->setRandomLayerColor($random, 2, 1, DyeColor::RED);
163163
$j = 0;
164164
for($i = 0; $i < $random->nextBoundedInt(3) + 3; ++$i){
165165
$j += $random->nextBoundedInt(16) + 4;
166166
if($j >= count($this->color_layer)){
167167
break;
168168
}
169169
if(($random->nextBoundedInt(2) === 0) || (($j < count($this->color_layer) - 1) && ($random->nextBoundedInt(2) === 0))){
170-
$this->color_layer[$j - 1] = DyeColor::LIGHT_GRAY();
170+
$this->color_layer[$j - 1] = DyeColor::LIGHT_GRAY;
171171
}else{
172-
$this->color_layer[$j] = DyeColor::WHITE();
172+
$this->color_layer[$j] = DyeColor::WHITE;
173173
}
174174
}
175175
}

src/muqsit/vanillagenerator/generator/object/SugarCane.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function generate(ChunkManager $world, Random $random, int $source_x, int
4343
if($block_id === BlockTypeIds::SUGARCANE
4444
|| $block_id === BlockTypeIds::GRASS
4545
|| $block_id === BlockTypeIds::SAND
46-
|| ($block instanceof Dirt && $block->getDirtType()->equals(DirtType::NORMAL()))
46+
|| ($block instanceof Dirt && $block->getDirtType()->equals(DirtType::NORMAL))
4747
){
4848
$cane_block = $world->getBlockAt($source_x, $source_y + $n, $source_z);
4949
if($cane_block->getTypeId() !== BlockTypeIds::AIR && $world->getBlockAt($source_x, $source_y + $n + 1, $source_z)->getTypeId() !== BlockTypeIds::AIR){

src/muqsit/vanillagenerator/generator/object/tree/BrownMushroomTree.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,19 @@ public function generate(ChunkManager $world, Random $random, int $source_x, int
108108
// cap's borders/corners treatment
109109
$data = match(true){
110110
$x === $source_x - $radius => match(true){
111-
$z === $source_z - $radius => MushroomBlockType::CAP_NORTHWEST(),
112-
$z === $source_z + $radius => MushroomBlockType::CAP_SOUTHWEST(),
113-
default => MushroomBlockType::CAP_WEST()
111+
$z === $source_z - $radius => MushroomBlockType::CAP_NORTHWEST,
112+
$z === $source_z + $radius => MushroomBlockType::CAP_SOUTHWEST,
113+
default => MushroomBlockType::CAP_WEST
114114
},
115115
$x === $source_x + $radius => match(true){
116-
$z === $source_z - $radius => MushroomBlockType::CAP_NORTHEAST(),
117-
$z === $source_z + $radius => MushroomBlockType::CAP_SOUTHEAST(),
118-
default => MushroomBlockType::CAP_EAST()
116+
$z === $source_z - $radius => MushroomBlockType::CAP_NORTHEAST,
117+
$z === $source_z + $radius => MushroomBlockType::CAP_SOUTHEAST,
118+
default => MushroomBlockType::CAP_EAST
119119
},
120120
default => match(true){
121-
$z === $source_z - $radius => MushroomBlockType::CAP_NORTH(),
122-
$z === $source_z + $radius => MushroomBlockType::CAP_SOUTH(),
123-
default => MushroomBlockType::CAP_MIDDLE()
121+
$z === $source_z - $radius => MushroomBlockType::CAP_NORTH,
122+
$z === $source_z + $radius => MushroomBlockType::CAP_SOUTH,
123+
default => MushroomBlockType::CAP_MIDDLE
124124
}
125125
};
126126

@@ -137,26 +137,26 @@ public function generate(ChunkManager $world, Random $random, int $source_x, int
137137

138138
// mushroom's cap corners treatment
139139
if($x === $source_x - ($radius - 1) && $z === $source_z - $radius){
140-
$data = MushroomBlockType::CAP_NORTHWEST();
140+
$data = MushroomBlockType::CAP_NORTHWEST;
141141
}elseif($x === $source_x - $radius && $z === $source_z - ($radius - 1)){
142-
$data = MushroomBlockType::CAP_NORTHWEST();
142+
$data = MushroomBlockType::CAP_NORTHWEST;
143143
}elseif($x === $source_x + $radius - 1 && $z === $source_z - $radius){
144-
$data = MushroomBlockType::CAP_NORTHEAST();
144+
$data = MushroomBlockType::CAP_NORTHEAST;
145145
}elseif($x === $source_x + $radius && $z === $source_z - ($radius - 1)){
146-
$data = MushroomBlockType::CAP_NORTHEAST();
146+
$data = MushroomBlockType::CAP_NORTHEAST;
147147
}elseif($x === $source_x - ($radius - 1) && $z === $source_z + $radius){
148-
$data = MushroomBlockType::CAP_SOUTHWEST();
148+
$data = MushroomBlockType::CAP_SOUTHWEST;
149149
}elseif($x === $source_x - $radius && $z === $source_z + $radius - 1){
150-
$data = MushroomBlockType::CAP_SOUTHWEST();
150+
$data = MushroomBlockType::CAP_SOUTHWEST;
151151
}elseif($x === $source_x + $radius - 1 && $z === $source_z + $radius){
152-
$data = MushroomBlockType::CAP_SOUTHEAST();
152+
$data = MushroomBlockType::CAP_SOUTHEAST;
153153
}elseif($x === $source_x + $radius && $z === $source_z + $radius - 1){
154-
$data = MushroomBlockType::CAP_SOUTHEAST();
154+
$data = MushroomBlockType::CAP_SOUTHEAST;
155155
}
156156
}
157157

158158
// a $data of CAP_MIDDLE below the top layer means air
159-
if($data !== MushroomBlockType::CAP_MIDDLE() || $y >= $source_y + $this->height){
159+
if($data !== MushroomBlockType::CAP_MIDDLE || $y >= $source_y + $this->height){
160160
$this->transaction->addBlockAt($x, $y, $z, $this->getType()->setMushroomBlockType($data));
161161
}
162162
}

src/muqsit/vanillagenerator/generator/overworld/decorator/MushroomDecorator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function decorate(ChunkManager $world, Random $random, int $chunk_x, int
5858
break;
5959
case BlockTypeIds::DIRT:
6060
assert($below_below instanceof Dirt);
61-
if(!$below_below->getDirtType()->equals(DirtType::COARSE())){
61+
if($below_below->getDirtType() !== DirtType::COARSE){
6262
$can_place_shroom = $block->getLightLevel() < 13;
6363
}else{
6464
$can_place_shroom = false;

0 commit comments

Comments
 (0)