mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 03:51:37 +00:00
Merge 'minor-next' into 'major-next'
Automatic merge performed by: https://github.com/pmmp/RestrictedActions/actions/runs/18510095782
This commit is contained in:
@@ -826,8 +826,9 @@ final class BlockTypeIds{
|
|||||||
public const COPPER_CHAIN = 10796;
|
public const COPPER_CHAIN = 10796;
|
||||||
public const COPPER_LANTERN = 10797;
|
public const COPPER_LANTERN = 10797;
|
||||||
public const COPPER_TORCH = 10798;
|
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;
|
private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID;
|
||||||
|
|
||||||
|
@@ -33,12 +33,14 @@ use pocketmine\event\entity\EntityDamageByBlockEvent;
|
|||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
|
use function mt_rand;
|
||||||
|
|
||||||
class Cactus extends Transparent implements Ageable{
|
class Cactus extends Transparent implements Ageable{
|
||||||
use AgeableTrait;
|
use AgeableTrait;
|
||||||
use StaticSupportTrait;
|
use StaticSupportTrait;
|
||||||
|
|
||||||
public const MAX_AGE = 15;
|
public const MAX_AGE = 15;
|
||||||
|
public const MAX_HEIGHT = 3;
|
||||||
|
|
||||||
public function hasEntityCollision() : bool{
|
public function hasEntityCollision() : bool{
|
||||||
return true;
|
return true;
|
||||||
@@ -78,26 +80,52 @@ class Cactus extends Transparent implements Ageable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onRandomTick() : void{
|
public function onRandomTick() : void{
|
||||||
if(!$this->getSide(Facing::DOWN)->hasSameTypeId($this)){
|
$up = $this->getSide(Facing::UP);
|
||||||
$world = $this->position->getWorld();
|
if($up->getTypeId() !== BlockTypeIds::AIR){
|
||||||
if($this->age === self::MAX_AGE){
|
return;
|
||||||
for($y = 1; $y < 3; ++$y){
|
}
|
||||||
if(!$world->isInWorld($this->position->x, $this->position->y + $y, $this->position->z)){
|
|
||||||
break;
|
$world = $this->position->getWorld();
|
||||||
}
|
|
||||||
$b = $world->getBlockAt($this->position->x, $this->position->y + $y, $this->position->z);
|
if(!$world->isInWorld($up->position->x, $up->position->y, $up->position->z)){
|
||||||
if($b->getTypeId() === BlockTypeIds::AIR){
|
return;
|
||||||
BlockEventHelper::grow($b, VanillaBlocks::CACTUS(), null);
|
}
|
||||||
}else{
|
|
||||||
break;
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
46
src/block/CactusFlower.php
Normal file
46
src/block/CactusFlower.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@@ -162,6 +162,7 @@ use function strtolower;
|
|||||||
* @method static BrownMushroomBlock BROWN_MUSHROOM_BLOCK()
|
* @method static BrownMushroomBlock BROWN_MUSHROOM_BLOCK()
|
||||||
* @method static BuddingAmethyst BUDDING_AMETHYST()
|
* @method static BuddingAmethyst BUDDING_AMETHYST()
|
||||||
* @method static Cactus CACTUS()
|
* @method static Cactus CACTUS()
|
||||||
|
* @method static CactusFlower CACTUS_FLOWER()
|
||||||
* @method static Cake CAKE()
|
* @method static Cake CAKE()
|
||||||
* @method static CakeWithCandle CAKE_WITH_CANDLE()
|
* @method static CakeWithCandle CAKE_WITH_CANDLE()
|
||||||
* @method static CakeWithDyedCandle CAKE_WITH_DYED_CANDLE()
|
* @method static CakeWithDyedCandle CAKE_WITH_DYED_CANDLE()
|
||||||
@@ -1378,6 +1379,7 @@ final class VanillaBlocks{
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
self::register("cactus_flower", fn(BID $id) => new CactusFlower($id, "Cactus Flower", new Info(BreakInfo::instant())));
|
||||||
|
|
||||||
self::registerBlocksR13();
|
self::registerBlocksR13();
|
||||||
self::registerBlocksR14();
|
self::registerBlocksR14();
|
||||||
|
@@ -461,6 +461,8 @@ final class VanillaBlockMappings{
|
|||||||
$reg->mapSimple(Blocks::PINK_TULIP(), Ids::PINK_TULIP);
|
$reg->mapSimple(Blocks::PINK_TULIP(), Ids::PINK_TULIP);
|
||||||
$reg->mapSimple(Blocks::RED_TULIP(), Ids::RED_TULIP);
|
$reg->mapSimple(Blocks::RED_TULIP(), Ids::RED_TULIP);
|
||||||
$reg->mapSimple(Blocks::WHITE_TULIP(), Ids::WHITE_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{
|
private static function registerColoredMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
|
||||||
|
@@ -211,6 +211,7 @@ final class StringToItemParser extends StringToTParser{
|
|||||||
$result->registerBlock("burning_furnace", fn() => Blocks::FURNACE());
|
$result->registerBlock("burning_furnace", fn() => Blocks::FURNACE());
|
||||||
$result->registerBlock("bush", fn() => Blocks::DEAD_BUSH());
|
$result->registerBlock("bush", fn() => Blocks::DEAD_BUSH());
|
||||||
$result->registerBlock("cactus", fn() => Blocks::CACTUS());
|
$result->registerBlock("cactus", fn() => Blocks::CACTUS());
|
||||||
|
$result->registerBlock("cactus_flower", fn() => Blocks::CACTUS_FLOWER());
|
||||||
$result->registerBlock("cake", fn() => Blocks::CAKE());
|
$result->registerBlock("cake", fn() => Blocks::CAKE());
|
||||||
$result->registerBlock("cake_block", fn() => Blocks::CAKE());
|
$result->registerBlock("cake_block", fn() => Blocks::CAKE());
|
||||||
$result->registerBlock("calcite", fn() => Blocks::CALCITE());
|
$result->registerBlock("calcite", fn() => Blocks::CALCITE());
|
||||||
|
@@ -90,36 +90,18 @@ parameters:
|
|||||||
count: 3
|
count: 3
|
||||||
path: ../../../src/block/Block.php
|
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\.$#'
|
message: '#^Parameter \#1 \$x of method pocketmine\\world\\World\:\:isInWorld\(\) expects int, float\|int given\.$#'
|
||||||
identifier: argument.type
|
identifier: argument.type
|
||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/block/Cactus.php
|
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\.$#'
|
message: '#^Parameter \#2 \$y of method pocketmine\\world\\World\:\:isInWorld\(\) expects int, float\|int given\.$#'
|
||||||
identifier: argument.type
|
identifier: argument.type
|
||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/block/Cactus.php
|
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\.$#'
|
message: '#^Parameter \#3 \$z of method pocketmine\\world\\World\:\:isInWorld\(\) expects int, float\|int given\.$#'
|
||||||
identifier: argument.type
|
identifier: argument.type
|
||||||
|
@@ -82,6 +82,7 @@
|
|||||||
"BROWN_MUSHROOM_BLOCK": 11,
|
"BROWN_MUSHROOM_BLOCK": 11,
|
||||||
"BUDDING_AMETHYST": 1,
|
"BUDDING_AMETHYST": 1,
|
||||||
"CACTUS": 16,
|
"CACTUS": 16,
|
||||||
|
"CACTUS_FLOWER": 1,
|
||||||
"CAKE": 7,
|
"CAKE": 7,
|
||||||
"CAKE_WITH_CANDLE": 2,
|
"CAKE_WITH_CANDLE": 2,
|
||||||
"CAKE_WITH_DYED_CANDLE": 32,
|
"CAKE_WITH_DYED_CANDLE": 32,
|
||||||
|
Reference in New Issue
Block a user