mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 13:25:16 +00:00
Merge branch 'stable' into minor-next
This commit is contained in:
commit
093b1e1b18
@ -77,7 +77,8 @@ class CaveVines extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block) : bool{
|
private function canBeSupportedAt(Block $block) : bool{
|
||||||
return $block->getAdjacentSupportType(Facing::UP) === SupportType::FULL || $block->hasSameTypeId($this);
|
$supportBlock = $block->getSide(Facing::UP);
|
||||||
|
return $supportBlock->getSupportType(Facing::DOWN) === SupportType::FULL || $supportBlock->hasSameTypeId($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
|
@ -32,19 +32,19 @@ use pocketmine\world\BlockTransaction;
|
|||||||
|
|
||||||
final class HangingRoots extends Flowable{
|
final class HangingRoots extends Flowable{
|
||||||
|
|
||||||
private function canBeSupportedBy(Block $block) : bool{
|
private function canBeSupportedAt(Block $block) : bool{
|
||||||
return $block->isSolid(); //TODO: not sure if this is the correct logic
|
return $block->getAdjacentSupportType(Facing::UP)->hasCenterSupport(); //weird I know, but they can be placed on the bottom of fences
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
if(!$blockReplace->getSide(Facing::UP)->isSolid()){
|
if(!$this->canBeSupportedAt($blockReplace)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
if(!$this->canBeSupportedBy($this->getSide(Facing::UP))){
|
if(!$this->canBeSupportedAt($this)){
|
||||||
$this->position->getWorld()->useBreakOn($this->position);
|
$this->position->getWorld()->useBreakOn($this->position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ use function preg_match;
|
|||||||
*/
|
*/
|
||||||
trait RegistryTrait{
|
trait RegistryTrait{
|
||||||
/**
|
/**
|
||||||
* @var object[]
|
* @var object[]|null
|
||||||
* @phpstan-var array<string, object>
|
* @phpstan-var array<string, object>|null
|
||||||
*/
|
*/
|
||||||
private static $members = null;
|
private static $members = null;
|
||||||
|
|
||||||
@ -54,6 +54,9 @@ trait RegistryTrait{
|
|||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private static function _registryRegister(string $name, object $member) : void{
|
private static function _registryRegister(string $name, object $member) : void{
|
||||||
|
if(self::$members === null){
|
||||||
|
throw new AssumptionFailedError("Cannot register members outside of " . self::class . "::setup()");
|
||||||
|
}
|
||||||
self::verifyName($name);
|
self::verifyName($name);
|
||||||
$upperName = mb_strtoupper($name);
|
$upperName = mb_strtoupper($name);
|
||||||
if(isset(self::$members[$upperName])){
|
if(isset(self::$members[$upperName])){
|
||||||
@ -86,6 +89,9 @@ trait RegistryTrait{
|
|||||||
*/
|
*/
|
||||||
private static function _registryFromString(string $name) : object{
|
private static function _registryFromString(string $name) : object{
|
||||||
self::checkInit();
|
self::checkInit();
|
||||||
|
if(self::$members === null){
|
||||||
|
throw new AssumptionFailedError(self::class . "::checkInit() did not initialize self::\$members correctly");
|
||||||
|
}
|
||||||
$upperName = mb_strtoupper($name);
|
$upperName = mb_strtoupper($name);
|
||||||
if(!isset(self::$members[$upperName])){
|
if(!isset(self::$members[$upperName])){
|
||||||
throw new \InvalidArgumentException("No such registry member: " . self::class . "::" . $upperName);
|
throw new \InvalidArgumentException("No such registry member: " . self::class . "::" . $upperName);
|
||||||
@ -121,6 +127,6 @@ trait RegistryTrait{
|
|||||||
*/
|
*/
|
||||||
private static function _registryGetAll() : array{
|
private static function _registryGetAll() : array{
|
||||||
self::checkInit();
|
self::checkInit();
|
||||||
return array_map(self::preprocessMember(...), self::$members);
|
return array_map(self::preprocessMember(...), self::$members ?? throw new AssumptionFailedError(self::class . "::checkInit() did not initialize self::\$members correctly"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user