You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== get_itemmeta ==
[[../objects/ms.lang.CastException|ms.lang.CastException]] |- ! scope="row" | Since | 3.3.1 |- ! scope="row" | Restricted |
Copy Code
The output might be:
Copy Code
The output might be:
Copy Code
The output might be:
Copy Code
The output might be:
Returns an associative array of known item meta for the slot given, or null if there isn't any.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| get_itemmeta
|-
! scope="row" | Returns
| array
|-
! scope="row" | Usages
| [player,] slot
|-
! scope="row" | Throws
| [[../objects/com.commandhelper.PlayerOfflineException|com.commandhelper.PlayerOfflineException]][[../objects/ms.lang.CastException|ms.lang.CastException]] |- ! scope="row" | Since | 3.3.1 |- ! scope="row" | Restricted |
Yes
|-
! scope="row" | Optimizations
| None
|}Below are the available fields in the item meta array. Most fields can be null when the item meta doesn't have that value.
Some data is not yet supported in item meta, and should be documented below. In addition, as of 1.20.5, many of the new
data components are not yet supported:
From 1.20.5+: "enchantment_glint_override", "food", "hide_tooltip", "instrument", "intangible_projectile", "item_name",
"lock", "lodestone_tracker", "max_damage", "max_stack_size", "note_block_sound", "ominous_bottle_amplifier", "rarity",
and "tool".
From 1.21.0+: "jukebox_playable".
From 1.21.2+: "consumable", "damage_resistant", "death_protection", "enchantable", "equippable", "item_model", "glider",
"repairable", "tooltip_style", "use_cooldown", and "use_remainder".
From 1.21.4+: "custom_model_data" for anything other than a single float.
{| width="80%" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="14%" | Item Type
! scope="col" width="86%" | Meta
|-
! All Items
|
These fields are present in all items with meta.
* '''display''' : (string) The display name seen when renamed in an anvil (or null).
* '''lore''' : (array) A list of strings that is displayed when hovering the item (or null). As lines are plain text, they do not yet support some advanced text components, but color codes are supported.
* '''model''' : (int) Represents vanilla's CustomModelData tag for use with resource packs (or null). Is converted to a float for the custom_model_data component in 1.21.4+.
* '''flags''' : (array) Flags used to hide meta in the item tooltip: HIDE_ENCHANTS, HIDE_ATTRIBUTES, HIDE_UNBREAKABLE, HIDE_DESTROYS, HIDE_PLACED_ON, HIDE_POTION_EFFECTS, HIDE_ADDITIONAL_TOOLTIP, HIDE_DYE, HIDE_ARMOR_TRIM, or HIDE_STORED_ENCHANTS.
* '''repair''' : (int) The additional cost to repair or combine this item in an anvil.
* '''enchants''' : (associative array) The enchantments on this item.
** '''<enchantment_name>l;''' : (associative array) Name of enchantment as the key (e.g. "fire_aspect") An integer for the level can be used as the value instead of an array.
*** '''elevel''' : (int) The level of the enchantment.
* '''modifiers''' : (array) A list of attribute modifier arrays (or null).
** (associative array)
*** '''attribute''' : (string) One of GENERIC_ARMOR, GENERIC_ARMOR_TOUGHNESS, GENERIC_ATTACK_DAMAGE, GENERIC_ATTACK_KNOCKBACK, GENERIC_ATTACK_SPEED, GENERIC_FLYING_SPEED, GENERIC_FOLLOW_RANGE, GENERIC_KNOCKBACK_RESISTANCE, GENERIC_LUCK, GENERIC_MAX_HEALTH, GENERIC_MOVEMENT_SPEED, ZOMBIE_SPAWN_REINFORCEMENTS, GENERIC_MAX_ABSORPTION, GENERIC_FALL_DAMAGE_MULTIPLIER, GENERIC_GRAVITY, GENERIC_JUMP_STRENGTH, GENERIC_SAFE_FALL_DISTANCE, GENERIC_SCALE, GENERIC_STEP_HEIGHT, PLAYER_BLOCK_BREAK_SPEED, PLAYER_BLOCK_INTERACTION_RANGE, PLAYER_ENTITY_INTERACTION_RANGE, GENERIC_BURNING_TIME, GENERIC_EXPLOSION_KNOCKBACK_RESISTANCE, GENERIC_MOVEMENT_EFFICIENCY, GENERIC_OXYGEN_BONUS, GENERIC_WATER_MOVEMENT_EFFICIENCY, PLAYER_MINING_EFFICIENCY, PLAYER_SNEAKING_SPEED, PLAYER_SUBMERGED_MINING_SPEED, PLAYER_SWEEPING_DAMAGE_RATIO, or TEMPT_RANGE.
*** '''operation''' : (string) One of ADD_NUMBER, ADD_SCALAR, or MULTIPLY_SCALAR_1.
*** '''amount''' : (double) The value used in the modifier operation.
*** '''id''' : (string) An item can only have one modifier with the same id.
*** '''slot''' : (string) Possible slots are WEAPON, OFF_HAND, BOOTS, LEGGINGS, CHESTPLATE, or HELMET or one of the slot groups ANY, HAND, ARMOR, BODY, or SADDLE.
* '''tags''' : (associative array) Custom tags used by plugins (or null).
** '''<custom_key>''' : (associative array) Each tag's key is namespaced (e.g. "commandhelper:mytag").
*** '''type''' : (string) Possible types: BYTE, BYTE_ARRAY, DOUBLE, FLOAT, INTEGER, INTEGER_ARRAY, LONG, LONG_ARRAY, SHORT, STRING, TAG_CONTAINER, or TAG_CONTAINER_ARRAY.
*** '''value''' : (mixed) A valid value for the given tag type.
The "CanPlaceOn" tag for blocks and "CanDestroy" tag for tools in adventure mode are not yet supported.
|-
! Damageable Items
|
* '''damage''' : (int) The amount of damage on the item. 0 is undamaged. Maximum is determined by each item type's max durability.
* '''unbreakable''' : (boolean) Whether or not the item can be damaged.
|-
! Armor
|
* '''trim''' : (associative array) Defines an armor trim. (MC 1.20+)
** '''pattern''' : Pattern can be BOLT, COAST, DUNE, EYE, FLOW, HOST, RAISER, RIB, SENTRY, SHAPER, SILENCE, SNOUT, SPIRE, TIDE, VEX, WARD, WAYFINDER, or WILD.
** '''material''' : Material can be AMETHYST, COPPER, DIAMOND, EMERALD, GOLD, IRON, LAPIS, NETHERITE, QUARTZ, REDSTONE, or RESIN.
|-
! AxolotlBucket
|
* '''variant''' : (string) The type of axolotl, one of BLUE, CYAN, GOLD, LUCY, or WILD. (MC 1.17+)
The entity's custom name is derived from the item "display" string. All other axolotl NBT is not yet supported.
|-
! Banners
|
* '''patterns''' : (array) An array of pattern associative arrays for each layer.
** (associative array)
*** '''color''' : One of WHITE, ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, PINK, GRAY, LIGHT_GRAY, CYAN, PURPLE, BLUE, BROWN, GREEN, RED, or BLACK.
*** '''shape''' : One of BASE, BORDER, BRICKS, CIRCLE_MIDDLE, CREEPER, CROSS, CURLY_BORDER, DIAGONAL_LEFT, DIAGONAL_LEFT_MIRROR, DIAGONAL_RIGHT, DIAGONAL_RIGHT_MIRROR, FLOW, FLOWER, GLOBE, GRADIENT, GRADIENT_UP, GUSTER, HALF_HORIZONTAL, HALF_HORIZONTAL_MIRROR, HALF_VERTICAL, HALF_VERTICAL_MIRROR, MOJANG, PIGLIN, RHOMBUS_MIDDLE, SKULL, SQUARE_BOTTOM_LEFT, SQUARE_BOTTOM_RIGHT, SQUARE_TOP_LEFT, SQUARE_TOP_RIGHT, STRAIGHT_CROSS, STRIPE_BOTTOM, STRIPE_CENTER, STRIPE_DOWNLEFT, STRIPE_DOWNRIGHT, STRIPE_LEFT, STRIPE_MIDDLE, STRIPE_RIGHT, STRIPE_SMALL, STRIPE_TOP, TRIANGLE_BOTTOM, TRIANGLE_TOP, TRIANGLES_BOTTOM, or TRIANGLES_TOP.
|-
! Bee Hives/Nests
|
* '''beecount''' : (int) The number of bees stored in this hive or nest (0 - 3). (requires MC 1.20.6+ to set)
Stored Bee NBT is not yet supported.
|-
! BlockData
|
* '''blockdata''' : (associative array) Block data, also known as block states in vanilla, like is returned from get_blockdata() (or null).
** '''block''' : (string) Block material name (optional)
** '''<state_name>''' : (int, boolean, string) The state value.
Only returns specified states as of 1.20.6. Prior versions return all states. Can only set specific states without defaults as of 1.21.3.
|-
! Books
|
* '''pages''' : (array) An array of pages as strings. New lines supported. (100 page limit)
In addition, signed Written Books have the following keys:
* '''title''' : (string) The title of the book. (32 character limit)
* '''author''' : (string) The author of the book.
* '''generation''' : (string) The generation of the book. Can be ORIGINAL, COPY_OF_ORIGINAL, COPY_OF_COPY, or TATTERED (the last two cannot be copied).
As pages are plain text, they do not yet support some advanced text components.
|-
! Brewing Stands
|
* '''brewtime''' : (int) The amount of time left in ticks before brewing completes.
* '''fuel''' : (int) The amount of fuel left.
* '''inventory''' : (associative array) Defines items in each slot
** '''fuel''' : (item array) The item that will consumed when brewing stand fuel is empty. Typically blaze powder or null.
** '''ingredient''' : (item array) The top slot item ingredient or null.
** '''leftbottle''' : (item array) Bottle slots are typically a type of potion or null, but can also be a glass bottle.
** '''middlebottle''' : (item array)
** '''rightbottle''' : (item array)
|-
! Bundle
|
* '''items''' : (array) An array of item arrays that exist in this bundle. (MC 1.17+)
|-
! CommandBlocks
|
* '''command''' : (string) The command set for this commandblock.
* '''customname''' : (string) The name of this commandblock. (default: '@')
The remaining tags are not yet supported.
|-
! Compass
|
* '''target''' : (associative array) The location this compass will point to, or null to use normal compass target.
* '''lodestone''' : (boolean) If the target location is a tracked lodestone. If true, compass spins if no lodestone exists there.
|-
! Crossbows
|
* '''projectiles''' : (array) An array of item arrays that are loaded in the crossbow. Items must be arrows or fireworks. When fired, the first item is the middle projectile. (maximum of three projectiles)
|-
! Decorated Pots
|
* '''sherds''' : (associative array) Pottery sherds for each side of the decorated pot.
** '''front''' : (string) Can only be a sherd material name or brick if empty.
** '''back''' : (string)
** '''left''' : (string)
** '''right''' : (string)
* '''item''' : (associative array) An item array for the stack contained in the decorated pot, or null if empty. (MC 1.20.4+)
|-
! Enchanted Books
|
* '''stored''' : (associative array) An array of enchantments, in the same format as "enchants".
|-
! Firework Star
|
* '''effect''' : (associative array) A firework star effect that can be used to craft fireworks
** '''flicker''' : (boolean) Whether the sparks twinkle and pop. (default: false)
** '''trail''' : (boolean) Whether the sparks leave particle trails. (default: false)
** '''type''' : (string) One of BALL, BALL_LARGE, STAR, BURST, or CREEPER. (default: BALL)
** '''colors''' : (array) The starting colors of the sparks as multiple color arrays. (can use color names; can be set to one color) (default: WHITE)
** '''fade''' : (array) The ending colors of the sparks as multiple color arrays. (can use color names; can be set to one color)
|-
! Firework Rockets
|
* '''firework''' : (associative array) A firework rocket's attributes.
** '''strength''' : (int) How long in seconds the rocket will last. (-1 for instant detonation)
** '''effects''' : (array) Multiple firework star effect arrays. (see Firework Star above)
|-
! Furnaces
|
* '''burntime''' : (int) The amount of time left in ticks before the furnace extinguishes.
* '''cooktime''' : (int) The amount of time in ticks the item has been cooking for.
* '''inventory''' : (associative array) Defines items in each slot
** '''result''' : (associative array) The resulting smelted item, or null.
** '''fuel''' : (associative array) The item stack that will be consumed when "burntime" reaches zero, or null.
** '''smelting''' : (associative array) The current item stack being smelted, or null.
|-
! GoatHorns
|
* '''instrument''' : (string) The instrument name (can be ponder_goat_horn, sing_goat_horn, seek_goat_horn, feel_goat_horn, admire_goat_horn, call_goat_horn, yearn_goat_horn, dream_goat_horn). (MC 1.19.3+)
|-
! Inventory Blocks
|
* '''inventory''' : (associative array) An array of item arrays, where each existing index is an inventory slot. (exceptions exist for furnaces and brewing stands)
|-
! Knowledge Books
|
* '''recipes''' : (array) A list of namespaced recipe keys. (or null)
|-
! Leather Armor
|
* '''color''' : (associative array) An RGB color array for the dye in the leather armor.
** '''r''' : (int) Red value ranging from 0 to 255
** '''g''' : (int) Green value
** '''b''' : (int) Blue value
|-
! Filled Maps
|
* '''mapid''' : (int) The unique id for a map on the server.
* '''color''' : (associative array) An RGB color array for the ink used on the map item.
** '''r''' : (int) Red value ranging from 0 to 255
** '''g''' : (int) Green value
** '''b''' : (int) Blue value
|-
! Player Heads
|
* '''owner''' : (string) The user name. Can be null if there is no owner.
* '''owneruuid''' : (string) The user UUID. Can be null if there is no owner.
* '''texture''' : (string) The texture property value used for custom heads. This is a base64 encoded JSON object seen under the "Value" key in vanilla. It contains the skin texture URL among other things. Requires an owner. (Paper only)
|-
! Potions
|
* '''potiontype''' : (string) The base potion type, which can be one of: AWKWARD, FIRE_RESISTANCE, LONG_FIRE_RESISTANCE, INFESTED, HARMING, STRONG_HARMING, HEALING, STRONG_HEALING, INVISIBILITY, LONG_INVISIBILITY, LEAPING, LONG_LEAPING, STRONG_LEAPING, LUCK, MUNDANE, NIGHT_VISION, LONG_NIGHT_VISION, OOZING, POISON, LONG_POISON, STRONG_POISON, REGENERATION, LONG_REGENERATION, STRONG_REGENERATION, SLOWNESS, LONG_SLOWNESS, STRONG_SLOWNESS, SLOW_FALLING, LONG_SLOW_FALLING, SWIFTNESS, LONG_SWIFTNESS, STRONG_SWIFTNESS, STRENGTH, LONG_STRENGTH, STRONG_STRENGTH, THICK, TURTLE_MASTER, LONG_TURTLE_MASTER, STRONG_TURTLE_MASTER, WATER, WATER_BREATHING, LONG_WATER_BREATHING, WEAKNESS, LONG_WEAKNESS, WEAVING, or WIND_CHARGED. (MC 1.20.6+)
* '''base''' : (associative array) Legacy base potion effect. This was used prior to MC 1.20.6 and is converted in later versions. Use "potiontype" on later versions.
** '''extended''' : (boolean)
** '''upgraded''' : (boolean)
** '''type''' : (string)
* '''potions''' : (associative array) A list of effects that get applied with this potion.
** '''<effect_name>''' : (associative array)
*** '''id''' : (int) Legacy effect id. Only used if potions array is not associative.
*** '''strength''' : (int) The level of the potion effect, starting with zero. (default: 0)
*** '''seconds''' : (int) The number of seconds the effect lasts for. (default: 30)
*** '''ambient''' : (boolean) Whether the particles are more transparent. (default: false)
*** '''particles''' : (boolean) Whether the particles are visible at all. (default: true)
*** '''icon''' : (boolean) Whether the effect icon is visible for the player. (default: true)
* '''color''' : (array) An RGB color array for the tint of the potion item.
** '''r''' : (int) Red value ranging from 0 to 255
** '''g''' : (int) Green value
** '''b''' : (int) Blue value
|-
! Suspicious Stew
|
* '''potions''' : (associative array) See potion meta.
|-
! Shields
|
* '''basecolor''' : (string) A color name, one of WHITE, ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, PINK, GRAY, LIGHT_GRAY, CYAN, PURPLE, BLUE, BROWN, GREEN, RED, or BLACK.
* '''patterns''' : (array) See Banner "patterns".
|-
! Signs
|
* '''signtext''' : (array) An array of 4 strings, one for each line of text on the front.
* '''color''' : (string) The dye color for the text on the front. (default: 'BLACK')
* '''glowing''' : (boolean) Whether the sign has glowing text on the front. (MC 1.17.1+)
* '''backtext''' : (array) An array of 4 strings, one for each line of text on the back. (MC 1.20+)
* '''backcolor''' : (string) The dye color for the text on the back. (default: 'BLACK') (MC 1.20+)
* '''backglowing''' : (boolean) Whether the sign has glowing text on the back. (MC 1.20+)
* '''waxed''' : (boolean) Whether the sign is waxed. (MC 1.20.1+)
|-
! Spawn Eggs
|
The entity's custom name is derived from the item "display" string. Additional NBT for the entity spawned is not supported.
|-
! Spawners
|
* '''spawntype''' : (string) May be one of ALLAY, AREA_EFFECT_CLOUD, ARMADILLO, ARMOR_STAND, ARROW, AXOLOTL, BAT, BEE, BLAZE, BLOCK_DISPLAY, ACACIA_BOAT, ACACIA_CHEST_BOAT, BAMBOO_RAFT, BAMBOO_CHEST_RAFT, BIRCH_BOAT, BIRCH_CHEST_BOAT, CHERRY_BOAT, CHERRY_CHEST_BOAT, DARK_OAK_BOAT, DARK_OAK_CHEST_BOAT, JUNGLE_BOAT, JUNGLE_CHEST_BOAT, MANGROVE_BOAT, MANGROVE_CHEST_BOAT, OAK_BOAT, OAK_CHEST_BOAT, PALE_OAK_BOAT, PALE_OAK_CHEST_BOAT, SPRUCE_BOAT, SPRUCE_CHEST_BOAT, BOGGED, BREEZE, BREEZE_WIND_CHARGE, CAMEL, CAT, CAVE_SPIDER, CHICKEN, COD, COW, CREAKING, CREEPER, DOLPHIN, DRAGON_FIREBALL, DROPPED_ITEM, DROWNED, DONKEY, EGG, ELDER_GUARDIAN, ENDERMAN, ENDERMITE, ENDER_CRYSTAL, ENDER_DRAGON, ENDER_EYE, ENDER_PEARL, EVOKER, EVOKER_FANGS, EXPERIENCE_ORB, FALLING_BLOCK, FIREBALL, FIREWORK, FOX, FROG, GHAST, GIANT, GLOW_ITEM_FRAME, GLOW_SQUID, GOAT, GUARDIAN, HOGLIN, HORSE, HUSK, ILLUSIONER, INTERACTION, IRON_GOLEM, ITEM_DISPLAY, ITEM_FRAME, LLAMA, LLAMA_SPIT, LEASH_HITCH, LIGHTNING, LINGERING_POTION, MAGMA_CUBE, MARKER, MINECART, MINECART_CHEST, MINECART_COMMAND, MINECART_FURNACE, MINECART_HOPPER, MINECART_MOB_SPAWNER, MINECART_TNT, MULE, MUSHROOM_COW, OCELOT, OMINOUS_ITEM_SPAWNER, PAINTING, PANDA, PARROT, PHANTOM, PIG, PIGLIN, PIGLIN_BRUTE, PILLAGER, POLAR_BEAR, PRIMED_TNT, PUFFERFISH, RABBIT, RAVAGER, SALMON, SHEEP, SILVERFISH, SKELETON, SHULKER, SHULKER_BULLET, SKELETON_HORSE, SLIME, SMALL_FIREBALL, SNIFFER, SNOWBALL, SNOWMAN, SQUID, SPECTRAL_ARROW, SPIDER, SPLASH_POTION, STRAY, STRIDER, TADPOLE, TEXT_DISPLAY, THROWN_EXP_BOTTLE, TRADER_LLAMA, TRIDENT, TROPICAL_FISH, TURTLE, VEX, VILLAGER, VINDICATOR, WANDERING_TRADER, WARDEN, WIND_CHARGE, WITCH, WITHER, WITHER_SKELETON, WITHER_SKULL, WOLF, ZOGLIN, ZOMBIE, ZOMBIE_HORSE, ZOMBIE_VILLAGER, or ZOMBIFIED_PIGLIN. Not all entity types will spawn from spawners, and some require special conditions.
* '''delay''' : (int) The time in ticks until the spawner will spawn the next batch of entities.
* '''mindelay''' : (int) The lower bounds of a new random delay chosen after each batch of entities spawn. (must be <= "maxdelay")
* '''maxdelay''' : (int) The upper bounds of a new random delay. (must be above zero and >= mindelay)
* '''spawncount''' : (int) The number of entities to attempt to spawn in each batch.
* '''maxnearbyentities''' : (int) The number of "spawntype" entities within just over "spawnrange" distance that'll prevent further spawns.
* '''spawnrange''' : (int) The maximum distance in the x or z axis new entities will spawn from the spawner.
* '''playerrange''' : (int) The maximum distance a player must be within to cause the spawner to spawn.
NBT for spawn potentials other than entity type is not yet supported.
|-
! Tropical Fish Bucket
|
* '''fishcolor''' : (string) The color of the fish, can be one of WHITE, ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, PINK, GRAY, LIGHT_GRAY, CYAN, PURPLE, BLUE, BROWN, GREEN, RED, or BLACK.
* '''fishpatterncolor''' : (string) The color of the pattern on the fish.
* '''fishpattern''' : (string) The pattern type on the fish, can be one of KOB, SUNSTREAK, SNOOPER, DASHER, BRINELY, SPOTTY, FLOPPER, STRIPEY, GLITTER, BLOCKFISH, BETTY, or CLAYFISH.
The entity's custom name is derived from the item "display" string. All other tropical fish NBT is not yet supported.
|}
=== Usages ===
get_itemmeta([player,] slot)=== Examples === ====Example 1==== Demonstrates generic meta for a tool in your main hand. Given the following code:
msg(get_itemmeta(null))

1 {{function|msg}}({{function|get_itemmeta}}({{keyword|null}}))
{display: AmazingSword, enchants: {}, lore: {Look at my sword, my sword is amazing}, repair: 0, model: null, flags: {}, modifiers: null, tags: null, damage: 0, unbreakable: false}====Example 2==== Demonstrates a written book (excluding generic meta) Given the following code:
msg(get_itemmeta(null))

1 {{function|msg}}({{function|get_itemmeta}}({{keyword|null}}))
{author: PseudoKnight, pages: {Once upon a time..., The End.}, title: Short Story, generation: ORIGINAL}====Example 3==== Demonstrates an EnchantedBook (excluding generic meta) Given the following code:
msg(get_itemmeta(null))

1 {{function|msg}}({{function|get_itemmeta}}({{keyword|null}}))
{stored: {flame: {elevel: 1, etype: ARROW_FIRE}}}====Example 4==== Demonstrates a custom firework (excluding generic meta) Given the following code:
msg(get_itemmeta(null))

1 {{function|msg}}({{function|get_itemmeta}}({{keyword|null}}))
{firework: {effects: {{colors: {{b: 240, g: 240, r: 240}, {b: 44, g: 49, r: 179}, {b: 146, g: 49, r: 37}}, fade: {}, flicker: true, trail: false, type: STAR}, {colors: {{b: 255, g: 255, r: 255}}, fade: {{b: 0, g: 0, r: 255}}, flicker: false, trail: true, type: BURST}}, strength: 2}}
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)