Merge branch 'next-major' into modern-world-support

This commit is contained in:
Dylan K. Taylor
2022-06-04 18:43:11 +01:00
114 changed files with 436 additions and 863 deletions

View File

@@ -42,8 +42,7 @@ class Armor extends Durable{
private ArmorTypeInfo $armorInfo;
/** @var Color|null */
protected $customColor = null;
protected ?Color $customColor = null;
public function __construct(ItemIdentifier $identifier, string $name, ArmorTypeInfo $info){
parent::__construct($identifier, $name);

View File

@@ -29,9 +29,7 @@ use function lcg_value;
use function min;
abstract class Durable extends Item{
/** @var int */
protected $damage = 0;
protected int $damage = 0;
private bool $unbreakable = false;
public function getMeta() : int{

View File

@@ -65,36 +65,28 @@ class Item implements \JsonSerializable{
public const TAG_DISPLAY_NAME = "Name";
public const TAG_DISPLAY_LORE = "Lore";
private ItemIdentifier $identifier;
private CompoundTag $nbt;
/** @var int */
protected $count = 1;
/** @var string */
protected $name;
protected int $count = 1;
//TODO: this stuff should be moved to itemstack properties, not mushed in with type properties
/** @var string */
protected $customName = "";
protected string $customName = "";
/** @var string[] */
protected $lore = [];
/**
* TODO: this needs to die in a fire
* @var CompoundTag|null
*/
protected $blockEntityTag = null;
protected array $lore = [];
/** TODO: this needs to die in a fire */
protected ?CompoundTag $blockEntityTag = null;
/**
* @var string[]
* @phpstan-var array<string, string>
*/
protected $canPlaceOn = [];
protected array $canPlaceOn = [];
/**
* @var string[]
* @phpstan-var array<string, string>
*/
protected $canDestroy;
protected array $canDestroy = [];
/**
* Constructs a new Item type. This constructor should ONLY be used when constructing a new item TYPE to register
@@ -103,12 +95,10 @@ class Item implements \JsonSerializable{
* NOTE: This should NOT BE USED for creating items to set into an inventory. Use {@link ItemFactory#get} for that
* purpose.
*/
public function __construct(ItemIdentifier $identifier, string $name = "Unknown"){
$this->identifier = $identifier;
$this->name = $name;
$this->canPlaceOn = [];
$this->canDestroy = [];
public function __construct(
private ItemIdentifier $identifier,
protected string $name = "Unknown"
){
$this->nbt = new CompoundTag();
}

View File

@@ -34,7 +34,7 @@ use function spl_object_id;
*/
trait ItemEnchantmentHandlingTrait{
/** @var EnchantmentInstance[] */
protected $enchantments = [];
protected array $enchantments = [];
public function hasEnchantments() : bool{
return count($this->enchantments) > 0;

View File

@@ -24,9 +24,7 @@ declare(strict_types=1);
namespace pocketmine\item;
abstract class TieredTool extends Tool{
/** @var ToolTier */
protected $tier;
protected ToolTier $tier;
public function __construct(ItemIdentifier $identifier, string $name, ToolTier $tier){
parent::__construct($identifier, $name);

View File

@@ -29,10 +29,9 @@ use function array_flip;
use function floor;
class ProtectionEnchantment extends Enchantment{
/** @var float */
protected $typeModifier;
protected float $typeModifier;
/** @var int[]|null */
protected $applicableDamageTypes = null;
protected ?array $applicableDamageTypes = null;
/**
* ProtectionEnchantment constructor.