Merge 'minor-next' into 'major-next'

Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/18510095782
This commit is contained in:
pmmp-admin-bot[bot]
2025-10-14 21:06:15 +00:00
8 changed files with 100 additions and 37 deletions

View File

@@ -826,8 +826,9 @@ final class BlockTypeIds{
public const COPPER_CHAIN = 10796;
public const COPPER_LANTERN = 10797;
public const COPPER_TORCH = 10798;
public const CACTUS_FLOWER = 10799;
public const FIRST_UNUSED_BLOCK_ID = 10799;
public const FIRST_UNUSED_BLOCK_ID = 10800;
private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID;

View File

@@ -33,12 +33,14 @@ use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
use function mt_rand;
class Cactus extends Transparent implements Ageable{
use AgeableTrait;
use StaticSupportTrait;
public const MAX_AGE = 15;
public const MAX_HEIGHT = 3;
public function hasEntityCollision() : bool{
return true;
@@ -78,26 +80,52 @@ class Cactus extends Transparent implements Ageable{
}
public function onRandomTick() : void{
if(!$this->getSide(Facing::DOWN)->hasSameTypeId($this)){
$world = $this->position->getWorld();
if($this->age === self::MAX_AGE){
for($y = 1; $y < 3; ++$y){
if(!$world->isInWorld($this->position->x, $this->position->y + $y, $this->position->z)){
break;
}
$b = $world->getBlockAt($this->position->x, $this->position->y + $y, $this->position->z);
if($b->getTypeId() === BlockTypeIds::AIR){
BlockEventHelper::grow($b, VanillaBlocks::CACTUS(), null);
}else{
break;
}
$up = $this->getSide(Facing::UP);
if($up->getTypeId() !== BlockTypeIds::AIR){
return;
}
$world = $this->position->getWorld();
if(!$world->isInWorld($up->position->x, $up->position->y, $up->position->z)){
return;
}
$height = 1;
while($height < self::MAX_HEIGHT && $this->getSide(Facing::DOWN, $height)->hasSameTypeId($this)){
$height++;
}
if($this->age === 9){
$canGrowFlower = true;
foreach(Facing::HORIZONTAL as $side){
if($up->getSide($side)->isSolid()){
$canGrowFlower = false;
break;
}
}
if($canGrowFlower){
$chance = $height >= self::MAX_HEIGHT ? 25 : 10;
if(mt_rand(1, 100) <= $chance){
if(BlockEventHelper::grow($up, VanillaBlocks::CACTUS_FLOWER(), null)){
$this->age = 0;
$world->setBlock($this->position, $this, update: false);
}
return;
}
$this->age = 0;
$world->setBlock($this->position, $this, update: false);
}else{
++$this->age;
$world->setBlock($this->position, $this, update: false);
}
}
if($this->age === self::MAX_AGE){
$this->age = 0;
if($height < self::MAX_HEIGHT){
BlockEventHelper::grow($up, VanillaBlocks::CACTUS(), null);
}
}else{
++$this->age;
}
$world->setBlock($this->position, $this, update: false);
}
}

View File

@@ -0,0 +1,46 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\StaticSupportTrait;
use pocketmine\math\Facing;
class CactusFlower extends Flowable{
use StaticSupportTrait;
private function canBeSupportedAt(Block $block) : bool{
$supportBlock = $block->getSide(Facing::DOWN);
return
$supportBlock->getSupportType(Facing::UP)->hasCenterSupport() ||
$supportBlock->getTypeId() === BlockTypeIds::CACTUS;
}
public function getFlameEncouragement() : int{
return 60;
}
public function getFlammability() : int{
return 100;
}
}

View File

@@ -162,6 +162,7 @@ use function strtolower;
* @method static BrownMushroomBlock BROWN_MUSHROOM_BLOCK()
* @method static BuddingAmethyst BUDDING_AMETHYST()
* @method static Cactus CACTUS()
* @method static CactusFlower CACTUS_FLOWER()
* @method static Cake CAKE()
* @method static CakeWithCandle CAKE_WITH_CANDLE()
* @method static CakeWithDyedCandle CAKE_WITH_DYED_CANDLE()
@@ -1378,6 +1379,7 @@ final class VanillaBlocks{
return [];
}
});
self::register("cactus_flower", fn(BID $id) => new CactusFlower($id, "Cactus Flower", new Info(BreakInfo::instant())));
self::registerBlocksR13();
self::registerBlocksR14();

View File

@@ -461,6 +461,8 @@ final class VanillaBlockMappings{
$reg->mapSimple(Blocks::PINK_TULIP(), Ids::PINK_TULIP);
$reg->mapSimple(Blocks::RED_TULIP(), Ids::RED_TULIP);
$reg->mapSimple(Blocks::WHITE_TULIP(), Ids::WHITE_TULIP);
$reg->mapSimple(Blocks::CACTUS_FLOWER(), Ids::CACTUS_FLOWER);
}
private static function registerColoredMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{

View File

@@ -211,6 +211,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("burning_furnace", fn() => Blocks::FURNACE());
$result->registerBlock("bush", fn() => Blocks::DEAD_BUSH());
$result->registerBlock("cactus", fn() => Blocks::CACTUS());
$result->registerBlock("cactus_flower", fn() => Blocks::CACTUS_FLOWER());
$result->registerBlock("cake", fn() => Blocks::CAKE());
$result->registerBlock("cake_block", fn() => Blocks::CAKE());
$result->registerBlock("calcite", fn() => Blocks::CALCITE());

View File

@@ -90,36 +90,18 @@ parameters:
count: 3
path: ../../../src/block/Block.php
-
message: '#^Parameter \#1 \$x of method pocketmine\\world\\World\:\:getBlockAt\(\) expects int, float\|int given\.$#'
identifier: argument.type
count: 1
path: ../../../src/block/Cactus.php
-
message: '#^Parameter \#1 \$x of method pocketmine\\world\\World\:\:isInWorld\(\) expects int, float\|int given\.$#'
identifier: argument.type
count: 1
path: ../../../src/block/Cactus.php
-
message: '#^Parameter \#2 \$y of method pocketmine\\world\\World\:\:getBlockAt\(\) expects int, float\|int given\.$#'
identifier: argument.type
count: 1
path: ../../../src/block/Cactus.php
-
message: '#^Parameter \#2 \$y of method pocketmine\\world\\World\:\:isInWorld\(\) expects int, float\|int given\.$#'
identifier: argument.type
count: 1
path: ../../../src/block/Cactus.php
-
message: '#^Parameter \#3 \$z of method pocketmine\\world\\World\:\:getBlockAt\(\) expects int, float\|int given\.$#'
identifier: argument.type
count: 1
path: ../../../src/block/Cactus.php
-
message: '#^Parameter \#3 \$z of method pocketmine\\world\\World\:\:isInWorld\(\) expects int, float\|int given\.$#'
identifier: argument.type

View File

@@ -82,6 +82,7 @@
"BROWN_MUSHROOM_BLOCK": 11,
"BUDDING_AMETHYST": 1,
"CACTUS": 16,
"CACTUS_FLOWER": 1,
"CAKE": 7,
"CAKE_WITH_CANDLE": 2,
"CAKE_WITH_DYED_CANDLE": 32,