Skip to content

Commit 2c5c9b0

Browse files
committed
Merge branch 'minor-next' of https://github.com/pmmp/PocketMine-MP into waterlogging
2 parents b115e28 + 14114f6 commit 2c5c9b0

File tree

16 files changed

+243
-48
lines changed

16 files changed

+243
-48
lines changed

src/block/BlockTypeIds.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,13 @@ private function __construct(){
822822
public const WARPED_CEILING_CENTER_HANGING_SIGN = 10792;
823823
public const WARPED_CEILING_EDGES_HANGING_SIGN = 10793;
824824
public const WARPED_WALL_HANGING_SIGN = 10794;
825+
public const COPPER_BARS = 10795;
826+
public const COPPER_CHAIN = 10796;
827+
public const COPPER_LANTERN = 10797;
828+
public const COPPER_TORCH = 10798;
829+
public const CACTUS_FLOWER = 10799;
825830

826-
public const FIRST_UNUSED_BLOCK_ID = 10795;
831+
public const FIRST_UNUSED_BLOCK_ID = 10800;
827832

828833
private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID;
829834

src/block/Cactus.php

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@
3333
use pocketmine\event\entity\EntityDamageEvent;
3434
use pocketmine\math\AxisAlignedBB;
3535
use pocketmine\math\Facing;
36+
use function mt_rand;
3637

3738
class Cactus extends Transparent implements Ageable{
3839
use AgeableTrait;
3940
use StaticSupportTrait;
4041

4142
public const MAX_AGE = 15;
43+
public const MAX_HEIGHT = 3;
4244

4345
public function hasEntityCollision() : bool{
4446
return true;
@@ -78,26 +80,52 @@ public function ticksRandomly() : bool{
7880
}
7981

8082
public function onRandomTick() : void{
81-
if(!$this->getSide(Facing::DOWN)->hasSameTypeId($this)){
82-
$world = $this->position->getWorld();
83-
if($this->age === self::MAX_AGE){
84-
for($y = 1; $y < 3; ++$y){
85-
if(!$world->isInWorld($this->position->x, $this->position->y + $y, $this->position->z)){
86-
break;
87-
}
88-
$b = $world->getBlockAt($this->position->x, $this->position->y + $y, $this->position->z);
89-
if($b->getTypeId() === BlockTypeIds::AIR){
90-
BlockEventHelper::grow($b, VanillaBlocks::CACTUS(), null);
91-
}else{
92-
break;
83+
$up = $this->getSide(Facing::UP);
84+
if($up->getTypeId() !== BlockTypeIds::AIR){
85+
return;
86+
}
87+
88+
$world = $this->position->getWorld();
89+
90+
if(!$world->isInWorld($up->position->x, $up->position->y, $up->position->z)){
91+
return;
92+
}
93+
94+
$height = 1;
95+
while($height < self::MAX_HEIGHT && $this->getSide(Facing::DOWN, $height)->hasSameTypeId($this)){
96+
$height++;
97+
}
98+
99+
if($this->age === 9){
100+
$canGrowFlower = true;
101+
foreach(Facing::HORIZONTAL as $side){
102+
if($up->getSide($side)->isSolid()){
103+
$canGrowFlower = false;
104+
break;
105+
}
106+
}
107+
108+
if($canGrowFlower){
109+
$chance = $height >= self::MAX_HEIGHT ? 25 : 10;
110+
if(mt_rand(1, 100) <= $chance){
111+
if(BlockEventHelper::grow($up, VanillaBlocks::CACTUS_FLOWER(), null)){
112+
$this->age = 0;
113+
$world->setBlock($this->position, $this, update: false);
93114
}
115+
return;
94116
}
95-
$this->age = 0;
96-
$world->setBlock($this->position, $this, update: false);
97-
}else{
98-
++$this->age;
99-
$world->setBlock($this->position, $this, update: false);
100117
}
101118
}
119+
120+
if($this->age === self::MAX_AGE){
121+
$this->age = 0;
122+
123+
if($height < self::MAX_HEIGHT){
124+
BlockEventHelper::grow($up, VanillaBlocks::CACTUS(), null);
125+
}
126+
}else{
127+
++$this->age;
128+
}
129+
$world->setBlock($this->position, $this, update: false);
102130
}
103131
}

src/block/CactusFlower.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
* @link http://www.pocketmine.net/
18+
*
19+
*
20+
*/
21+
22+
declare(strict_types=1);
23+
24+
namespace pocketmine\block;
25+
26+
use pocketmine\block\utils\StaticSupportTrait;
27+
use pocketmine\math\Facing;
28+
29+
class CactusFlower extends Flowable{
30+
use StaticSupportTrait;
31+
32+
private function canBeSupportedAt(Block $block) : bool{
33+
$supportBlock = $block->getSide(Facing::DOWN);
34+
return
35+
$supportBlock->getSupportType(Facing::UP)->hasCenterSupport() ||
36+
$supportBlock->getTypeId() === BlockTypeIds::CACTUS;
37+
}
38+
39+
public function getFlameEncouragement() : int{
40+
return 60;
41+
}
42+
43+
public function getFlammability() : int{
44+
return 100;
45+
}
46+
}

src/block/Chain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
use pocketmine\math\AxisAlignedBB;
3131
use pocketmine\math\Facing;
3232

33-
final class Chain extends Transparent implements PillarRotation{
33+
class Chain extends Transparent implements PillarRotation{
3434
use PillarRotationTrait;
3535

3636
public function getSupportType(int $facing) : SupportType{

src/block/CopperBars.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
* @link http://www.pocketmine.net/
18+
*
19+
*
20+
*/
21+
22+
declare(strict_types=1);
23+
24+
namespace pocketmine\block;
25+
26+
use pocketmine\block\utils\CopperMaterial;
27+
use pocketmine\block\utils\CopperTrait;
28+
29+
class CopperBars extends Thin implements CopperMaterial{
30+
use CopperTrait;
31+
}

src/block/CopperChain.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
* @link http://www.pocketmine.net/
18+
*
19+
*
20+
*/
21+
22+
declare(strict_types=1);
23+
24+
namespace pocketmine\block;
25+
26+
use pocketmine\block\utils\CopperMaterial;
27+
use pocketmine\block\utils\CopperTrait;
28+
29+
class CopperChain extends Chain implements CopperMaterial{
30+
use CopperTrait;
31+
}

src/block/CopperLantern.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
* @link http://www.pocketmine.net/
18+
*
19+
*
20+
*/
21+
22+
declare(strict_types=1);
23+
24+
namespace pocketmine\block;
25+
26+
use pocketmine\block\utils\CopperMaterial;
27+
use pocketmine\block\utils\CopperTrait;
28+
29+
class CopperLantern extends Lantern implements CopperMaterial{
30+
use CopperTrait;
31+
}

src/block/LightningRod.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
use pocketmine\block\utils\AnyFacing;
2727
use pocketmine\block\utils\AnyFacingTrait;
28+
use pocketmine\block\utils\CopperMaterial;
29+
use pocketmine\block\utils\CopperTrait;
2830
use pocketmine\item\Item;
2931
use pocketmine\math\Axis;
3032
use pocketmine\math\AxisAlignedBB;
@@ -33,7 +35,8 @@
3335
use pocketmine\player\Player;
3436
use pocketmine\world\BlockTransaction;
3537

36-
final class LightningRod extends Transparent implements AnyFacing{
38+
final class LightningRod extends Transparent implements AnyFacing, CopperMaterial{
39+
use CopperTrait;
3740
use AnyFacingTrait;
3841

3942
protected function recalculateCollisionBoxes() : array{

src/block/VanillaBlocks.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
* @method static BrownMushroomBlock BROWN_MUSHROOM_BLOCK()
163163
* @method static BuddingAmethyst BUDDING_AMETHYST()
164164
* @method static Cactus CACTUS()
165+
* @method static CactusFlower CACTUS_FLOWER()
165166
* @method static Cake CAKE()
166167
* @method static CakeWithCandle CAKE_WITH_CANDLE()
167168
* @method static CakeWithDyedCandle CAKE_WITH_DYED_CANDLE()
@@ -225,10 +226,14 @@
225226
* @method static Concrete CONCRETE()
226227
* @method static ConcretePowder CONCRETE_POWDER()
227228
* @method static Copper COPPER()
229+
* @method static CopperBars COPPER_BARS()
228230
* @method static CopperBulb COPPER_BULB()
231+
* @method static CopperChain COPPER_CHAIN()
229232
* @method static CopperDoor COPPER_DOOR()
230233
* @method static CopperGrate COPPER_GRATE()
234+
* @method static CopperLantern COPPER_LANTERN()
231235
* @method static CopperOre COPPER_ORE()
236+
* @method static Torch COPPER_TORCH()
232237
* @method static CopperTrapdoor COPPER_TRAPDOOR()
233238
* @method static Coral CORAL()
234239
* @method static CoralBlock CORAL_BLOCK()
@@ -1035,6 +1040,7 @@ public function getBreakTime(Item $item) : float{
10351040
$ironBreakInfo = new Info(BreakInfo::pickaxe(5.0, ToolTier::STONE, 30.0));
10361041
self::register("iron", fn(BID $id) => new Opaque($id, "Iron Block", $ironBreakInfo));
10371042
self::register("iron_bars", fn(BID $id) => new Thin($id, "Iron Bars", $ironBreakInfo));
1043+
self::register("copper_bars", fn(BID $id) => new CopperBars($id, "Copper Bars", $ironBreakInfo));
10381044

10391045
self::register("iron_door", fn(BID $id) => new Door($id, "Iron Door", new Info(BreakInfo::pickaxe(5.0))));
10401046
self::register("iron_trapdoor", fn(BID $id) => new Trapdoor($id, "Iron Trapdoor", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD))));
@@ -1049,6 +1055,7 @@ public function getBreakTime(Item $item) : float{
10491055
$lanternBreakInfo = new Info(BreakInfo::pickaxe(3.5));
10501056
self::register("lantern", fn(BID $id) => new Lantern($id, "Lantern", $lanternBreakInfo, 15));
10511057
self::register("soul_lantern", fn(BID $id) => new Lantern($id, "Soul Lantern", $lanternBreakInfo, 10));
1058+
self::register("copper_lantern", fn(BID $id) => new CopperLantern($id, "Copper Lantern", $lanternBreakInfo, 15));
10521059

10531060
self::register("lapis_lazuli", fn(BID $id) => new Opaque($id, "Lapis Lazuli Block", new Info(BreakInfo::pickaxe(3.0, ToolTier::STONE))));
10541061
self::register("lava", fn(BID $id) => new Lava($id, "Lava", new Info(BreakInfo::indestructible(500.0))));
@@ -1227,6 +1234,7 @@ public function isAffectedBySilkTouch() : bool{
12271234
self::register("tall_grass", fn(BID $id) => new TallGrass($id, "Tall Grass", new Info(BreakInfo::instant(ToolType::SHEARS, 1))));
12281235

12291236
self::register("blue_torch", fn(BID $id) => new Torch($id, "Blue Torch", new Info(BreakInfo::instant())));
1237+
self::register("copper_torch", fn(BID $id) => new Torch($id, "Copper Torch", new Info(BreakInfo::instant())));
12301238
self::register("purple_torch", fn(BID $id) => new Torch($id, "Purple Torch", new Info(BreakInfo::instant())));
12311239
self::register("red_torch", fn(BID $id) => new Torch($id, "Red Torch", new Info(BreakInfo::instant())));
12321240
self::register("green_torch", fn(BID $id) => new Torch($id, "Green Torch", new Info(BreakInfo::instant())));
@@ -1371,6 +1379,7 @@ public function getDropsForCompatibleTool(Item $item) : array{
13711379
return [];
13721380
}
13731381
});
1382+
self::register("cactus_flower", fn(BID $id) => new CactusFlower($id, "Cactus Flower", new Info(BreakInfo::instant())));
13741383

13751384
self::registerBlocksR13();
13761385
self::registerBlocksR14();
@@ -1704,6 +1713,7 @@ public function getLightLevel() : int{ return 10;}
17041713
self::register("warped_roots", fn(BID $id) => new NetherRoots($id, "Warped Roots", $netherRootsInfo));
17051714

17061715
self::register("chain", fn(BID $id) => new Chain($id, "Chain", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 30.0))));
1716+
self::register("copper_chain", fn(BID $id) => new CopperChain($id, "Copper Chain", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 30.0))));
17071717

17081718
self::register("respawn_anchor", fn(BID $id) => new RespawnAnchor($id, "Respawn Anchor", new Info(BreakInfo::pickaxe(50.0, ToolTier::DIAMOND, 6000.0))));
17091719
}
@@ -1765,7 +1775,6 @@ public function isAffectedBySilkTouch() : bool{
17651775

17661776
self::register("tinted_glass", fn(BID $id) => new TintedGlass($id, "Tinted Glass", new Info(new BreakInfo(0.3))));
17671777

1768-
//blast resistance should be 30 if we were matched with java :(
17691778
$copperBreakInfo = new Info(BreakInfo::pickaxe(3.0, ToolTier::STONE, 30.0));
17701779
self::register("lightning_rod", fn(BID $id) => new LightningRod($id, "Lightning Rod", $copperBreakInfo));
17711780

0 commit comments

Comments
 (0)