QtCraft API C++ classes QML types Handbook

QcItemDefinition Struct

An item kind of a content pack (items/<name>.json, QcItemParser): its stack size, tool, food and fuel values and all the ways it can be used. More...

Header: #include <common/content/items/QcItemDefinition.h>

Public Functions

int keptDamage(int damage) const
bool placesBoat() const
QStringList settleProjectileUses()

Public Variables

std::optional<QcAnvilSwap> anvilSwap
std::optional<QcArmourDefinition> armour
double attackDamage
QString boatBlock
bool bottles
QString cartBlock
bool carves
QString descriptionKey
QcItemDial dial
QcDispenseAction dispense
std::optional<QcDrinkDefinition> drink
int durability
QString dye
QString emptiesTo
int enchantability
QString enchantsInto
bool fertilizes
QString filledMap
std::optional<QcFishingDefinition> fishing
bool flattens
int food
double fuelSeconds
std::optional<QcHangingDefinition> hangs
QcHoldDisplay hold
bool ignites
std::optional<QcLauncherDefinition> launcher
QcMapItem map
int maxStack
QString name
bool namesCreatures
QString placesBlock
bool placesCart
bool placesStand
bool portableContainer
QString projectile
QString releasesMob
QString repairWith
bool scoops
bool storesEnchantments
bool strips
QStringList tags
QString texture
std::optional<QcThrowableDefinition> throwable
bool tills
QString tool
int toolLevel
double toolSpeed
QString translationKey
QString zoomsWith

Static Public Members

const double fertilizeSaplingChance
const int maxFood
const int maxStackLimit

Detailed Description

Fields marked "Server side only" are left out of the content sync (QcItemSerializer).

Member Function Documentation

int QcItemDefinition::keptDamage(int damage) const

Returns the damage a stack of this item may carry (decision E-798): worn uses below the durability, else 0 (the map id of a filled map is item data, decision E-823).

bool QcItemDefinition::placesBoat() const

Returns whether it places a boat (boatBlock is set).

QStringList QcItemDefinition::settleProjectileUses()

Leaves out what does not go together with the projectile uses (when the content is finished): the use button throws a throwable item (QcClientLauncher::uses), so its other uses would never happen (decision E-427), and an empty ammunition list is dropped (the launcher then takes all ammunition that is not thrown). Returns the warnings, one per change.

Member Variable Documentation

std::optional<QcAnvilSwap> QcItemDefinition::anvilSwap

The item the anvil swaps it for and with what (decision E-870), set by QcAnvilSwaps on both items of a block's anvilSwap. Server side only.

std::optional<QcArmourDefinition> QcItemDefinition::armour

Worn in an equipment slot (decision E-234); items with armour stack to 1.

double QcItemDefinition::attackDamage

Damage dealt when hitting with this item, in health points.

QString QcItemDefinition::boatBlock

Used on water or on the top of a block, places a boat built of this block (its planks, decision E-920) that drops this item again; empty for items that place no boat. Reaches the client, which aims the item at water and draws the boat with the block's side texture.

bool QcItemDefinition::bottles

Used on a liquid, fills from it and becomes the liquid's bottle item, leaving the liquid (glass bottle, decision E-211).

QString QcItemDefinition::cartBlock

The block the placed cart carries (decision E-386): a container block (a chest) makes a container cart with the block's slots, a Signal Hopper a hopper cart; empty for a plain cart. Reaches the client, which draws the block in the cart and names the cart's screen.

bool QcItemDefinition::carves

Used on a block with carvesInto (a pumpkin), carves it facing the clicked side and wears by one (shears, decision E-472). Server side only.

QString QcItemDefinition::descriptionKey

Translation key of the handbook's text about it ("<translation>.description" unless set); a missing text leaves only the facts. Server side only.

QcItemDial QcItemDefinition::dial

The dial the client shows while the item is held ("dial": "compass" or "clock", decision E-769); reaches the client.

QcDispenseAction QcItemDefinition::dispense

What a Signal Dispenser does with it ("dispense", default "throw"). Server side only.

std::optional<QcDrinkDefinition> QcItemDefinition::drink

Drunk with the use button (milk, decision E-500); reaches the client, which sends the use as QcMsg::ConsumeItem.

int QcItemDefinition::durability

Uses until a tool breaks; 0 for items without durability.

QString QcItemDefinition::dye

The colour a dye gives ("dye": "red"): used on a block with dyeProperty that has this value, sets it and takes one item (the signal indicator light, decision E-765); empty for none. Server side only.

QString QcItemDefinition::emptiesTo

What the item turns into once it placed its block (a filled bucket becomes empty) or was eaten (soup leaves its bowl).

int QcItemDefinition::enchantability

How well the enchanting table enchants it (the reference's enchantability, decision E-864): 0 for items the table does not take. Server side only.

QString QcItemDefinition::enchantsInto

The item the enchanting table makes of it (decision E-873; a book becomes an enchanted book); empty: it stays itself. Server side only.

const double QcItemDefinition::fertilizeSaplingChance

Chance that a fertilizing item lets a sapling grow into its tree.

bool QcItemDefinition::fertilizes

Used on a crop, makes it grow by a few stages; on a sapling, lets it grow into its tree soon with fertilizeSaplingChance (bone meal, decision E-426). Server side only.

QString QcItemDefinition::filledMap

The filled map an empty map becomes when used ("filledMap", decision E-804). Server side only.

std::optional<QcFishingDefinition> QcItemDefinition::fishing

A fishing rod (decision E-503): the use button casts and reels in its bobber. Only that it fishes reaches the client, which sends the use as QcMsg::ThrowItem.

bool QcItemDefinition::flattens

Used on the top of a block with flattensInto (grass, dirt), turns it into that block (a shovel making a dirt path, decision E-406). Server side only.

int QcItemDefinition::food

Food points restored when eaten (a full player has 20); 0 for items that are not food.

double QcItemDefinition::fuelSeconds

Seconds the item burns as fuel in a machine; 0 for items that are no fuel.

std::optional<QcHangingDefinition> QcItemDefinition::hangs

Used on a block face, hangs an item frame or a painting there that drops this item again (decision E-790).

QcHoldDisplay QcItemDefinition::hold

How a hand holds it (decision E-831); unset fields come from the block it places, then from its category's defaults.

bool QcItemDefinition::ignites

Used on a block face, lights fire in the cell in front of it and wears by one (flint and steel, decision E-393). Also reaches the client (the creative inventory files it under tools).

std::optional<QcLauncherDefinition> QcItemDefinition::launcher

Drawn with the use button and shooting ammunition (a bow, decision E-425); reaches the client, which draws it while the button is held.

QcMapItem QcItemDefinition::map

An empty or filled map ("map": "empty" or "filled", decision E-804); reaches the client.

const int QcItemDefinition::maxFood

Food points of a full player.

int QcItemDefinition::maxStack

Most items in a stack ("maxStack", 1 to maxStackLimit, default 64); 1 for armour and items with a durability, and for tools that do not set it.

const int QcItemDefinition::maxStackLimit

Largest allowed maxStack.

QString QcItemDefinition::name

Qualified name ("name", required).

bool QcItemDefinition::namesCreatures

A name tag (decision E-866): with a custom name, used on a creature it names it. Server side only.

QString QcItemDefinition::placesBlock

Block placed when the item is used on a block face; empty for non-placeable items.

bool QcItemDefinition::placesCart

Used on a rail, places a minecart that drops this item again (decision E-382). Server side only.

bool QcItemDefinition::placesStand

Used on the top of a block, places an armour stand that drops this item again (decision E-238).

bool QcItemDefinition::portableContainer

Places a portable container (a backpack, decision E-832; the block's container.portable): the item carries the block's contents, stacks to one, opens from the hand and never goes into a portable container. Reaches the client.

QString QcItemDefinition::projectile

Ammunition: the projectile (QcProjectileDefinition) it becomes when a launcher shoots it; empty when its kind is unknown (QcContentRegistry::finish). The name reaches the client, which draws a launcher only with ammunition.

QString QcItemDefinition::releasesMob

A creature that comes out where the item places its liquid (a fish bucket, decision E-501): kept with the world like a bred animal. Server side only.

QString QcItemDefinition::repairWith

What repairs it at the anvil (decision E-866): an item name or "#tag"; empty for none. Each item restores a quarter of the durability. Server side only.

bool QcItemDefinition::scoops

Used on a liquid source, takes it and becomes the liquid's bucket item (empty bucket).

bool QcItemDefinition::storesEnchantments

It stores its enchantments instead of using them (an enchanted book, decision E-873): every enchantment fits it, none works while it is held or worn, and the anvil passes them on to the item in its left slot. Sent to the client with the content (its mining prediction).

bool QcItemDefinition::strips

Used on a block with strippedInto (a log), turns it into that block and wears by one (axes, decision E-753). Server side only.

QStringList QcItemDefinition::tags

Groups the item belongs to ("qtcraft:planks"); recipes accept any member of "#group".

QString QcItemDefinition::texture

Icon texture; block items use the block's top texture unless set.

std::optional<QcThrowableDefinition> QcItemDefinition::throwable

Thrown by hand with the use button as its projectile (a snowball, decision E-427); needs projectile. Reaches the client (arm swing and cooldown); launchers without an ammunition list do not shoot it.

bool QcItemDefinition::tills

Used on a block with tillsInto (grass, dirt), turns it into that block (a hoe making farmland, decision E-290). Server side only.

QString QcItemDefinition::tool

Tool category (e.g. "pickaxe"); empty for non-tools.

int QcItemDefinition::toolLevel

Tier of the tool ("toolLevel", 0 to 100, default 0).

double QcItemDefinition::toolSpeed

Mining speed multiplier for blocks of this tool category.

QString QcItemDefinition::translationKey

Translation key of its display name ("translation"); defaults to item.<namespace>.<name>.

QString QcItemDefinition::zoomsWith

The item a filled map is zoomed out with in the crafting grid ("zoomsWith", eight around the map, decision E-804); empty for none. Server side only.