mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Added API methods for getting & setting armour dye colours
This commit is contained in:
parent
78d24b9183
commit
9da19b5f15
@ -24,9 +24,35 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Color;
|
||||
|
||||
abstract class Armor extends Item{
|
||||
|
||||
public const TAG_CUSTOM_COLOR = "customColor"; //TAG_Int
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dyed colour of this armour piece. This generally only applies to leather armour.
|
||||
* @return Color|null
|
||||
*/
|
||||
public function getCustomColor() : ?Color{
|
||||
if($this->getNamedTag()->hasTag(self::TAG_CUSTOM_COLOR, IntTag::class)){
|
||||
return Color::fromARGB(Binary::unsignInt($this->getNamedTag()->getInt(self::TAG_CUSTOM_COLOR)));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dyed colour of this armour piece. This generally only applies to leather armour.
|
||||
* @param Color $color
|
||||
*/
|
||||
public function setCustomColor(Color $color) : void{
|
||||
$this->setNamedTagEntry(new IntTag(self::TAG_CUSTOM_COLOR, Binary::signInt($color->toARGB())));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user