PaintingItem
extends Item
in package
Table of Contents
- TAG_BLOCK_ENTITY_TAG = "BlockEntityTag"
- TAG_DISPLAY = "display"
- TAG_DISPLAY_LORE = "Lore"
- TAG_DISPLAY_NAME = "Name"
- TAG_ENCH = "ench"
- $blockEntityTag : CompoundTag|null
- TODO: this needs to die in a fire
- $canDestroy : array<string|int, string>
- $canPlaceOn : array<string|int, string>
- $count : int
- $customName : string
- $enchantments : array<string|int, EnchantmentInstance>
- $lore : array<string|int, string>
- $name : string
- $identifier : ItemIdentifier
- $nbt : CompoundTag
- __clone() : mixed
- __construct() : mixed
- Constructs a new Item type. This constructor should ONLY be used when constructing a new item TYPE to register into the index.
- __toString() : string
- addEnchantment() : $this
- canBePlaced() : bool
- canStackWith() : bool
- Returns whether this item could stack with the given item (ignoring stack size and count).
- clearCustomBlockData() : $this
- clearCustomName() : $this
- clearNamedTag() : $this
- Removes the Item's NBT.
- equals() : bool
- Compares an Item to this Item and check if they match.
- equalsExact() : bool
- Returns whether the specified item stack has the same ID, damage, NBT and count as this item stack.
- getAttackPoints() : int
- Returns how many points of damage this item will deal to an entity when used as a weapon.
- getBlock() : Block
- Returns the block corresponding to this Item.
- getBlockToolHarvestLevel() : int
- Returns the harvesting power that this tool has. This affects what blocks it can mine when the tool type matches the mined block.
- getBlockToolType() : int
- Returns what type of block-breaking tool this is. Blocks requiring the same tool type as the item will break faster (except for blocks requiring no tool, which break at the same speed regardless of the tool used)
- getCanDestroy() : array<string|int, string>
- getCanPlaceOn() : array<string|int, string>
- getCooldownTicks() : int
- Returns the number of ticks a player must wait before activating this item again.
- getCount() : int
- getCustomBlockData() : CompoundTag|null
- getCustomName() : string
- getDefensePoints() : int
- Returns how many armor points can be gained by wearing this item.
- getEnchantment() : EnchantmentInstance|null
- getEnchantmentLevel() : int
- Returns the level of the enchantment on this item with the specified ID, or 0 if the item does not have the enchantment.
- getEnchantments() : array<string|int, EnchantmentInstance>
- getFuelResidue() : Item
- Returns an item after burning fuel
- getFuelTime() : int
- Returns the time in ticks which the item will fuel a furnace for.
- getId() : int
- getLore() : array<string|int, string>
- getMaxStackSize() : int
- Returns the highest amount of this item which will fit into one inventory slot.
- getMeta() : int
- getMiningEfficiency() : float
- getName() : string
- Returns the name of the item, or the custom name if it is set.
- getNamedTag() : CompoundTag
- Returns a tree of Tag objects representing the Item's NBT. If the item does not have any NBT, an empty CompoundTag object is returned to allow the caller to manipulate and apply back to the item.
- getVanillaName() : string
- Returns the vanilla name of the item, disregarding custom names.
- hasAnyDamageValue() : bool
- Returns whether this item can match any item with an equivalent ID with any meta value.
- hasCustomBlockData() : bool
- hasCustomName() : bool
- hasEnchantment() : bool
- hasEnchantments() : bool
- hasNamedTag() : bool
- Returns whether this Item has a non-empty NBT.
- isNull() : bool
- jsonDeserialize() : Item
- Returns an Item from properties created in an array by {@link Item#jsonSerialize}
- jsonSerialize() : array<string|int, mixed>
- Returns an array of item stack properties that can be serialized to json.
- nbtDeserialize() : Item
- Deserializes an Item from an NBT CompoundTag
- nbtSerialize() : CompoundTag
- Serializes the item to an NBT CompoundTag
- onAttackEntity() : bool
- Called when this item is used to attack an entity. Usually used to update durability.
- onClickAir() : ItemUseResult
- Called when a player uses the item on air, for example throwing a projectile.
- onDestroyBlock() : bool
- Called when this item is used to destroy a block. Usually used to update durability.
- onInteractBlock() : ItemUseResult
- Called when a player uses this item on a block.
- onReleaseUsing() : ItemUseResult
- Called when a player is using this item and releases it. Used to handle bow shoot actions.
- pop() : static
- Pops an item from the stack and returns it, decreasing the stack count of this item stack by one.
- removeEnchantment() : $this
- removeEnchantments() : $this
- setCanDestroy() : void
- setCanPlaceOn() : void
- setCount() : $this
- setCustomBlockData() : $this
- setCustomName() : $this
- setLore() : $this
- setNamedTag() : $this
- Sets the Item's NBT from the supplied CompoundTag object.
- deserializeCompoundTag() : void
- serializeCompoundTag() : void
Constants
TAG_BLOCK_ENTITY_TAG
public
mixed
TAG_BLOCK_ENTITY_TAG
= "BlockEntityTag"
TAG_DISPLAY
public
mixed
TAG_DISPLAY
= "display"
TAG_DISPLAY_LORE
public
mixed
TAG_DISPLAY_LORE
= "Lore"
TAG_DISPLAY_NAME
public
mixed
TAG_DISPLAY_NAME
= "Name"
TAG_ENCH
public
mixed
TAG_ENCH
= "ench"
Properties
$blockEntityTag
TODO: this needs to die in a fire
protected
CompoundTag|null
$blockEntityTag
= null
$canDestroy
protected
array<string|int, string>
$canDestroy
Tags
$canPlaceOn
protected
array<string|int, string>
$canPlaceOn
= []
Tags
$count
protected
int
$count
= 1
$customName
protected
string
$customName
= ""
$enchantments
protected
array<string|int, EnchantmentInstance>
$enchantments
= []
$lore
protected
array<string|int, string>
$lore
= []
$name
protected
string
$name
$identifier
private
ItemIdentifier
$identifier
$nbt
private
CompoundTag
$nbt
Methods
__clone()
public
__clone() : mixed
Return values
mixed —__construct()
Constructs a new Item type. This constructor should ONLY be used when constructing a new item TYPE to register into the index.
public
__construct(ItemIdentifier $identifier[, string $name = "Unknown" ]) : mixed
NOTE: This should NOT BE USED for creating items to set into an inventory. Use for that purpose.
Parameters
- $identifier : ItemIdentifier
- $name : string = "Unknown"
Return values
mixed —__toString()
public
final __toString() : string
Return values
string —addEnchantment()
public
addEnchantment(EnchantmentInstance $enchantment) : $this
Parameters
- $enchantment : EnchantmentInstance
Return values
$this —canBePlaced()
public
final canBePlaced() : bool
Return values
bool —canStackWith()
Returns whether this item could stack with the given item (ignoring stack size and count).
public
final canStackWith(Item $other) : bool
Parameters
- $other : Item
Return values
bool —clearCustomBlockData()
public
clearCustomBlockData() : $this
Return values
$this —clearCustomName()
public
clearCustomName() : $this
Return values
$this —clearNamedTag()
Removes the Item's NBT.
public
clearNamedTag() : $this
Tags
Return values
$this —equals()
Compares an Item to this Item and check if they match.
public
final equals(Item $item[, bool $checkDamage = true ][, bool $checkCompound = true ]) : bool
Parameters
- $item : Item
- $checkDamage : bool = true
-
Whether to verify that the damage values match.
- $checkCompound : bool = true
-
Whether to verify that the items' NBT match.
Return values
bool —equalsExact()
Returns whether the specified item stack has the same ID, damage, NBT and count as this item stack.
public
final equalsExact(Item $other) : bool
Parameters
- $other : Item
Return values
bool —getAttackPoints()
Returns how many points of damage this item will deal to an entity when used as a weapon.
public
getAttackPoints() : int
Return values
int —getBlock()
Returns the block corresponding to this Item.
public
getBlock([int|null $clickedFace = null ]) : Block
Parameters
- $clickedFace : int|null = null
Return values
Block —getBlockToolHarvestLevel()
Returns the harvesting power that this tool has. This affects what blocks it can mine when the tool type matches the mined block.
public
getBlockToolHarvestLevel() : int
This should return 1 for non-tiered tools, and the tool tier for tiered tools.
Tags
Return values
int —getBlockToolType()
Returns what type of block-breaking tool this is. Blocks requiring the same tool type as the item will break faster (except for blocks requiring no tool, which break at the same speed regardless of the tool used)
public
getBlockToolType() : int
Return values
int —getCanDestroy()
public
getCanDestroy() : array<string|int, string>
Tags
Return values
array<string|int, string> —getCanPlaceOn()
public
getCanPlaceOn() : array<string|int, string>
Tags
Return values
array<string|int, string> —getCooldownTicks()
Returns the number of ticks a player must wait before activating this item again.
public
getCooldownTicks() : int
Return values
int —getCount()
public
getCount() : int
Return values
int —getCustomBlockData()
public
getCustomBlockData() : CompoundTag|null
Return values
CompoundTag|null —getCustomName()
public
getCustomName() : string
Return values
string —getDefensePoints()
Returns how many armor points can be gained by wearing this item.
public
getDefensePoints() : int
Return values
int —getEnchantment()
public
getEnchantment(Enchantment $enchantment) : EnchantmentInstance|null
Parameters
- $enchantment : Enchantment
Return values
EnchantmentInstance|null —getEnchantmentLevel()
Returns the level of the enchantment on this item with the specified ID, or 0 if the item does not have the enchantment.
public
getEnchantmentLevel(Enchantment $enchantment) : int
Parameters
- $enchantment : Enchantment
Return values
int —getEnchantments()
public
getEnchantments() : array<string|int, EnchantmentInstance>
Return values
array<string|int, EnchantmentInstance> —getFuelResidue()
Returns an item after burning fuel
public
getFuelResidue() : Item
Return values
Item —getFuelTime()
Returns the time in ticks which the item will fuel a furnace for.
public
getFuelTime() : int
Return values
int —getId()
public
final getId() : int
Return values
int —getLore()
public
getLore() : array<string|int, string>
Return values
array<string|int, string> —getMaxStackSize()
Returns the highest amount of this item which will fit into one inventory slot.
public
getMaxStackSize() : int
Return values
int —getMeta()
public
getMeta() : int
Return values
int —getMiningEfficiency()
public
getMiningEfficiency(bool $isCorrectTool) : float
Parameters
- $isCorrectTool : bool
Return values
float —getName()
Returns the name of the item, or the custom name if it is set.
public
final getName() : string
Return values
string —getNamedTag()
Returns a tree of Tag objects representing the Item's NBT. If the item does not have any NBT, an empty CompoundTag object is returned to allow the caller to manipulate and apply back to the item.
public
getNamedTag() : CompoundTag
Return values
CompoundTag —getVanillaName()
Returns the vanilla name of the item, disregarding custom names.
public
getVanillaName() : string
Return values
string —hasAnyDamageValue()
Returns whether this item can match any item with an equivalent ID with any meta value.
public
hasAnyDamageValue() : bool
Used in crafting recipes which accept multiple variants of the same item, for example crafting tables recipes.
Return values
bool —hasCustomBlockData()
public
hasCustomBlockData() : bool
Return values
bool —hasCustomName()
public
hasCustomName() : bool
Return values
bool —hasEnchantment()
public
hasEnchantment(Enchantment $enchantment[, int $level = -1 ]) : bool
Parameters
- $enchantment : Enchantment
- $level : int = -1
Return values
bool —hasEnchantments()
public
hasEnchantments() : bool
Return values
bool —hasNamedTag()
Returns whether this Item has a non-empty NBT.
public
hasNamedTag() : bool
Return values
bool —isNull()
public
isNull() : bool
Return values
bool —jsonDeserialize()
Returns an Item from properties created in an array by {@link Item#jsonSerialize}
public
final static jsonDeserialize(array<string|int, mixed> $data) : Item
Parameters
- $data : array<string|int, mixed>
Tags
Return values
Item —jsonSerialize()
Returns an array of item stack properties that can be serialized to json.
public
final jsonSerialize() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —nbtDeserialize()
Deserializes an Item from an NBT CompoundTag
public
static nbtDeserialize(CompoundTag $tag) : Item
Parameters
- $tag : CompoundTag
Tags
Return values
Item —nbtSerialize()
Serializes the item to an NBT CompoundTag
public
nbtSerialize([int $slot = -1 ]) : CompoundTag
Parameters
- $slot : int = -1
-
optional, the inventory slot of the item
Return values
CompoundTag —onAttackEntity()
Called when this item is used to attack an entity. Usually used to update durability.
public
onAttackEntity(Entity $victim) : bool
Parameters
- $victim : Entity
Return values
bool —onClickAir()
Called when a player uses the item on air, for example throwing a projectile.
public
onClickAir(Player $player, Vector3 $directionVector) : ItemUseResult
Returns whether the item was changed, for example count decrease or durability change.
Parameters
Return values
ItemUseResult —onDestroyBlock()
Called when this item is used to destroy a block. Usually used to update durability.
public
onDestroyBlock(Block $block) : bool
Parameters
- $block : Block
Return values
bool —onInteractBlock()
Called when a player uses this item on a block.
public
onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult
Parameters
Return values
ItemUseResult —onReleaseUsing()
Called when a player is using this item and releases it. Used to handle bow shoot actions.
public
onReleaseUsing(Player $player) : ItemUseResult
Returns whether the item was changed, for example count decrease or durability change.
Parameters
- $player : Player
Return values
ItemUseResult —pop()
Pops an item from the stack and returns it, decreasing the stack count of this item stack by one.
public
pop([int $count = 1 ]) : static
Parameters
- $count : int = 1
Tags
Return values
static —A clone of this itemstack containing the amount of items that were removed from this stack.
removeEnchantment()
public
removeEnchantment(Enchantment $enchantment[, int $level = -1 ]) : $this
Parameters
- $enchantment : Enchantment
- $level : int = -1
Return values
$this —removeEnchantments()
public
removeEnchantments() : $this
Return values
$this —setCanDestroy()
public
setCanDestroy(array<string|int, string> $canDestroy) : void
Parameters
- $canDestroy : array<string|int, string>
Return values
void —setCanPlaceOn()
public
setCanPlaceOn(array<string|int, string> $canPlaceOn) : void
Parameters
- $canPlaceOn : array<string|int, string>
Return values
void —setCount()
public
setCount(int $count) : $this
Parameters
- $count : int
Return values
$this —setCustomBlockData()
public
setCustomBlockData(CompoundTag $compound) : $this
Parameters
- $compound : CompoundTag
Return values
$this —setCustomName()
public
setCustomName(string $name) : $this
Parameters
- $name : string
Return values
$this —setLore()
public
setLore(array<string|int, string> $lines) : $this
Parameters
- $lines : array<string|int, string>
Return values
$this —setNamedTag()
Sets the Item's NBT from the supplied CompoundTag object.
public
setNamedTag(CompoundTag $tag) : $this
Parameters
- $tag : CompoundTag
Tags
Return values
$this —deserializeCompoundTag()
protected
deserializeCompoundTag(CompoundTag $tag) : void
Parameters
- $tag : CompoundTag
Tags
Return values
void —serializeCompoundTag()
protected
serializeCompoundTag(CompoundTag $tag) : void
Parameters
- $tag : CompoundTag