Item

Base class for an Item.

class Item {}

Constructors

this
this()
Undocumented in source.
this
this(string data)

Constructs an item with some extra data.

this
this(std.json.JSONValue data)

Constructs an item adding properties from a JSON.

Alias This

slot

Members

Functions

addEnchantment
void addEnchantment(Enchantment ench)
void addEnchantment(sel.data.enchantment.Enchantment ench, ubyte level)
void addEnchantment(sel.data.enchantment.Enchantment ench, string level)

Adds an enchantment to the item.

attackOnEntity
bool attackOnEntity(Player player, Entity entity)

Function called when the item is used against an entity as a left click or screen tap.

clear
void clear()

Removes the custom behaviours of the item, like custom name and enchantments.

destroyOn
bool destroyOn(Player player, Block block, BlockPosition position)

Function called when the item is used to the destroy a block.

onConsumed
Item onConsumed(Player player)

If consumeable is true, this function is called. when the item is eaten/drunk by its holder, who's passed as the first arguments. Return: null: the item count will be reduced by 1 item: the item will substitutes the consumed item

onPlaced
bool onPlaced(Player player, BlockPosition tpos, uint tface)

Function called when the item is ready to be placed by a player (the event for the player has already been called).

onReleased
bool onReleased(Player holder)

Function called when the item is released, usually after it has been throwed (which is used as aim-start function).

onThrowed
bool onThrowed(Player player)

Function called when the item is throwed or aimed.

opBinaryRight
void opBinaryRight(Enchantment ench)

Adds an enchantment to the item.

opBinaryRight
Enchantment* opBinaryRight(sel.data.enchantment.Enchantment ench)

Gets a pointer to the enchantment. This method can be used to check if the item has an enchantment and its level.

opBinaryRight
void opBinaryRight(sul.enchantments.Enchantment ench)

Removes an enchantment from the item.

opEquals
bool opEquals(Object o)

Deep comparation of 2 instantiated items. Compare ids, metas, custom names and enchantments.

opEquals
bool opEquals(item_t item)
bool opEquals(item_t[] items)

Compare an item with its type as a string or a group of strings.

parseBedrockCompound
void parseBedrockCompound(Compound compound)

Parses a compound, usually received from the client or saved in a world. The tag should never be null as the method doesn't check it.

parseJSON
void parseJSON(std.json.JSONValue data)
Undocumented in source. Be warned that the author may not have intended to support it.
parseJavaCompound
void parseJavaCompound(Compound compound)

Parses a compound, usually received from the client or saved in a world. The tag should never be null as the method doesn't check it.

place
ushort place(World world, BlockPosition position, uint face)

If Item::placeable returns true, this function should return an instance of the block that will be placed.

removeEnchantment
void removeEnchantment(sel.data.enchantment.Enchantment ench)

Removes an enchantment from the item.

toString
string toString()

Returns the item as string in format "name" or "name:damage" for tools.

useOnBlock
bool useOnBlock(Player player, Block block, BlockPosition position, ubyte face)

Function called when the item is used on a block clicking the right mouse button or performing a long pressure on the screen.

useOnEntity
bool useOnEntity(Player player, Entity entity)

Function called when the item is used on an entity as right click or long screen pressure.

Properties

alwaysConsumeable
bool alwaysConsumeable [@property getter]

Indicates whether the item can be consumed when the holder's hunger is full.

attack
uint attack [@property getter]

Indicates the damage caused by the item when used as a weapon. The value indicates the base damage without the influence of enchantments or effects.

bedrock
bool bedrock [@property getter]

Indicates whether the item exists in Minecraft.

bedrockId
ushort bedrockId [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
bedrockMeta
ushort bedrockMeta [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
consumeable
bool consumeable [@property getter]

Indicates whether or not an item can be eaten/drunk. If true, Item::onConsumed(Human consumer) will be called when this item is eaten/drunk.

customName
string customName [@property getter]

Gets the item's custom name.

customName
string customName [@property setter]

Sets the item's custom name.

data
sul.items.Item data [@property getter]

Gets the item's data.

finished
bool finished [@property getter]

If the item is a tool, checks whether its damage is higher than its durability.

java
bool java [@property getter]

Indicates wether the item exists in Minecraft.

javaCompound
Compound javaCompound [@property getter]

Gets the item's compound tag with the custom data of the item. It may be null if the item has no custom behaviours.

javaId
ushort javaId [@property getter]
javaMeta
ushort javaMeta [@property getter]

Indicates wether the item exists in Minecraft.

lore
string lore [@property getter]

Gets the item's lore or description which is displayed under the item's name when the item is hovered in the player's inventory.

lore
string[] lore [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
lore
string lore [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
max
ubyte max [@property getter]

Indicates the highest number of items that can be stacked in a slot. This number is the default slot's count if not specified when created.

name
string name [@property getter]

Gets the name (not the custom name!) of the item.

placeable
bool placeable [@property getter]

Indicates whether or not the item can be placed. If this function returns true, Item::place(World world) will be probably called next for place a block

pocketCompound
Compound pocketCompound [@property getter]

Gets the item's compound tag with the custom data of the item. It may be null if the item has no custom behaviours.

slot
Slot slot [@property getter]

Create a slot with the Item::max as count

tool
bool tool [@property getter]

Indicates whether the item is a tool. A tool can be used on blocks and entities and its meta will vary.

toolMaterial
ubyte toolMaterial [@property getter]

Gets the tool's material if the item is a tool. Items with ID 0 have unspecified material, 1 is the minimum (wood) and 5 is the maximum (diamond).

toolType
ubyte toolType [@property getter]

Gets the item's tool type.

unbreakable
bool unbreakable [@property getter]

If the item is a tool, indicates whether the item is consumed when used for breaking or combat.

unbreakable
bool unbreakable [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

m_pc_tag
Compound m_pc_tag;
Undocumented in source.
m_pe_tag
Compound m_pe_tag;
Undocumented in source.

Meta