mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Promote some constructors
This commit is contained in:
@ -38,18 +38,17 @@ class BlockBreakInfo{
|
||||
*/
|
||||
public const INCOMPATIBLE_TOOL_MULTIPLIER = 5.0;
|
||||
|
||||
private float $hardness;
|
||||
private float $blastResistance;
|
||||
private int $toolType;
|
||||
private int $toolHarvestLevel;
|
||||
|
||||
/**
|
||||
* @param float|null $blastResistance default 5x hardness
|
||||
*/
|
||||
public function __construct(float $hardness, int $toolType = BlockToolType::NONE, int $toolHarvestLevel = 0, ?float $blastResistance = null){
|
||||
$this->hardness = $hardness;
|
||||
$this->toolType = $toolType;
|
||||
$this->toolHarvestLevel = $toolHarvestLevel;
|
||||
public function __construct(
|
||||
private float $hardness,
|
||||
private int $toolType = BlockToolType::NONE,
|
||||
private int $toolHarvestLevel = 0,
|
||||
?float $blastResistance = null
|
||||
){
|
||||
$this->blastResistance = $blastResistance ?? $hardness * 5;
|
||||
}
|
||||
|
||||
|
@ -27,25 +27,18 @@ use pocketmine\block\tile\Tile;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
class BlockIdentifier{
|
||||
|
||||
private int $blockId;
|
||||
private int $variant;
|
||||
private ?int $itemId;
|
||||
/** @phpstan-var class-string<Tile>|null */
|
||||
private ?string $tileClass;
|
||||
|
||||
/**
|
||||
* @phpstan-param class-string<Tile>|null $tileClass
|
||||
*/
|
||||
public function __construct(int $blockId, int $variant, ?int $itemId = null, ?string $tileClass = null){
|
||||
$this->blockId = $blockId;
|
||||
$this->variant = $variant;
|
||||
$this->itemId = $itemId;
|
||||
|
||||
public function __construct(
|
||||
private int $blockId,
|
||||
private int $variant,
|
||||
private ?int $itemId = null,
|
||||
private ?string $tileClass = null
|
||||
){
|
||||
if($tileClass !== null){
|
||||
Utils::testValidInstance($tileClass, Tile::class);
|
||||
}
|
||||
$this->tileClass = $tileClass;
|
||||
}
|
||||
|
||||
public function getBlockId() : int{
|
||||
|
@ -24,16 +24,15 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
class Element extends Opaque{
|
||||
|
||||
private int $atomicWeight;
|
||||
private int $group;
|
||||
private string $symbol;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, string $symbol, int $atomicWeight, int $group){
|
||||
public function __construct(
|
||||
BlockIdentifier $idInfo,
|
||||
string $name,
|
||||
BlockBreakInfo $breakInfo,
|
||||
private string $symbol,
|
||||
private int $atomicWeight,
|
||||
private int $group
|
||||
){
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
$this->atomicWeight = $atomicWeight;
|
||||
$this->group = $group;
|
||||
$this->symbol = $symbol;
|
||||
}
|
||||
|
||||
public function getAtomicWeight() : int{
|
||||
|
@ -33,12 +33,10 @@ use pocketmine\world\sound\Sound;
|
||||
class DoubleChestInventory extends BaseInventory implements BlockInventory, InventoryHolder{
|
||||
use AnimatedBlockInventoryTrait;
|
||||
|
||||
private ChestInventory $left;
|
||||
private ChestInventory $right;
|
||||
|
||||
public function __construct(ChestInventory $left, ChestInventory $right){
|
||||
$this->left = $left;
|
||||
$this->right = $right;
|
||||
public function __construct(
|
||||
private ChestInventory $left,
|
||||
private ChestInventory $right
|
||||
){
|
||||
$this->holder = $this->left->getHolder();
|
||||
parent::__construct();
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ class EnderChestInventory extends DelegateInventory implements BlockInventory{
|
||||
onClose as animatedBlockInventoryTrait_onClose;
|
||||
}
|
||||
|
||||
private PlayerEnderInventory $inventory;
|
||||
|
||||
public function __construct(Position $holder, PlayerEnderInventory $inventory){
|
||||
public function __construct(
|
||||
Position $holder,
|
||||
private PlayerEnderInventory $inventory
|
||||
){
|
||||
parent::__construct($inventory);
|
||||
$this->holder = $holder;
|
||||
$this->inventory = $inventory;
|
||||
}
|
||||
|
||||
public function getEnderInventory() : PlayerEnderInventory{
|
||||
|
@ -35,11 +35,11 @@ class FurnaceInventory extends SimpleInventory implements BlockInventory{
|
||||
public const SLOT_FUEL = 1;
|
||||
public const SLOT_RESULT = 2;
|
||||
|
||||
private FurnaceType $furnaceType;
|
||||
|
||||
public function __construct(Position $holder, FurnaceType $furnaceType){
|
||||
public function __construct(
|
||||
Position $holder,
|
||||
private FurnaceType $furnaceType
|
||||
){
|
||||
$this->holder = $holder;
|
||||
$this->furnaceType = $furnaceType;
|
||||
parent::__construct(3);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user