Skip to content

Go: Items and containers

Functions

ContainerItems

Go
func ContainerItems(ref ContainerRef) ([]SlotItem, error)

ContainerItems lists the occupied slots of a container. Server thread only.

ItemOf

Go
func ItemOf(snbt string) Item

ItemOf is the item stack these SNBT describe.

  • Parameters:
    • snbt : string
  • Return type: Item

Item

Go
1
2
3
type Item struct {
    SNBT string
}

Item is an item stack as SNBT, a value: reading it asks the host about that SNBT, and changing it produces a new Item.

Item.Payload

Go
func (i Item) Payload() (*Nbt, error)

Payload is the item's SNBT parsed.

  • Return type: (*Nbt, error)

Item.Enchants

Go
func (i Item) Enchants() (string, error)

Enchants lists the item's enchantments as SNBT.

Item.Matches

Go
func (i Item) Matches(other Item) (bool, error)

Matches reports whether two items stack: the same item, data and user data.

  • Parameters:
    • other : Item
  • Return type: (bool, error)
  • Slots: item_matches

Item.Transform

Go
func (i Item) Transform(op int32, sarg string, narg float64) (Item, error)

Transform applies one of the PIER_IOP_* operations of abi.h and returns the new item.

  • Parameters:
    • op : int32
    • sarg : string
    • narg : float64
  • Return type: (Item, error)
  • Slots: item_transform

Item.Count

Go
func (i Item) Count() (float64, error)

Count reads PIER_IPROP_COUNT: ItemStackBase::mCount

Item.MaxStackSize

Go
func (i Item) MaxStackSize() (float64, error)

MaxStackSize reads PIER_IPROP_MAX_STACK_SIZE: ItemStackBase::getMaxStackSize

Item.AuxValue

Go
func (i Item) AuxValue() (float64, error)

AuxValue reads PIER_IPROP_AUX_VALUE: ItemStackBase::getAuxValue

Item.Id

Go
func (i Item) Id() (float64, error)

Id reads PIER_IPROP_ID: ItemStackBase::getId

Item.Damage

Go
func (i Item) Damage() (float64, error)

Damage reads PIER_IPROP_DAMAGE: ItemStackBase::getDamageValue

Item.IsNull

Go
func (i Item) IsNull() (bool, error)

IsNull reads PIER_IPROP_IS_NULL: ItemStackBase::isNull

Item.IsBlock

Go
func (i Item) IsBlock() (bool, error)

IsBlock reads PIER_IPROP_IS_BLOCK: ItemStackBase::isBlock

Item.IsEnchanted

Go
func (i Item) IsEnchanted() (bool, error)

IsEnchanted reads PIER_IPROP_IS_ENCHANTED: ItemStackBase::isEnchanted

Item.IsArmor

Go
func (i Item) IsArmor() (bool, error)

IsArmor reads PIER_IPROP_IS_ARMOR: ItemStackBase::isArmorItem

Item.IsDamageable

Go
func (i Item) IsDamageable() (bool, error)

IsDamageable reads PIER_IPROP_IS_DAMAGEABLE: ItemStackBase::isDamageableItem

Item.IsDamaged

Go
func (i Item) IsDamaged() (bool, error)

IsDamaged reads PIER_IPROP_IS_DAMAGED: ItemStackBase::isDamaged

Item.MaxDamage

Go
func (i Item) MaxDamage() (float64, error)

MaxDamage reads PIER_IPROP_MAX_DAMAGE: ItemStackBase::getMaxDamage

Item.IsUnbreakable

Go
func (i Item) IsUnbreakable() (bool, error)

IsUnbreakable reads PIER_IPROP_IS_UNBREAKABLE: ItemStackBase::isUnbreakable

Item.HasDurability

Go
func (i Item) HasDurability() (bool, error)

HasDurability reads PIER_IPROP_HAS_DURABILITY: ItemStackBase::hasDurability

Item.IsPotion

Go
func (i Item) IsPotion() (bool, error)

IsPotion reads PIER_IPROP_IS_POTION: ItemStackBase::isPotionItem

Item.IsThrowable

Go
func (i Item) IsThrowable() (bool, error)

IsThrowable reads PIER_IPROP_IS_THROWABLE: ItemStackBase::isThrowable

Item.IsFireResistant

Go
func (i Item) IsFireResistant() (bool, error)

IsFireResistant reads PIER_IPROP_IS_FIRE_RESISTANT: ItemStackBase::isFireResistant

Item.AttackDamage

Go
func (i Item) AttackDamage() (float64, error)

AttackDamage reads PIER_IPROP_ATTACK_DAMAGE: ItemStackBase::getAttackDamage

Item.RepairCost

Go
func (i Item) RepairCost() (float64, error)

RepairCost reads PIER_IPROP_REPAIR_COST: ItemStackBase::getBaseRepairCost

Item.EnchantValue

Go
func (i Item) EnchantValue() (float64, error)

EnchantValue reads PIER_IPROP_ENCHANT_VALUE: ItemStackBase::getEnchantValue

Item.IsStackable

Go
func (i Item) IsStackable() (bool, error)

IsStackable reads PIER_IPROP_IS_STACKABLE: ItemStackBase::isStackable

Item.IsMusicDisc

Go
func (i Item) IsMusicDisc() (bool, error)

IsMusicDisc reads PIER_IPROP_IS_MUSIC_DISC: ItemStackBase::isMusicDiscItem

Item.IsOffhand

Go
func (i Item) IsOffhand() (bool, error)

IsOffhand reads PIER_IPROP_IS_OFFHAND: ItemStackBase::isOffhandItem

Item.UseDuration

Go
func (i Item) UseDuration() (float64, error)

UseDuration reads PIER_IPROP_USE_DURATION: ItemStackBase::getMaxUseDuration

Item.IsGlint

Go
func (i Item) IsGlint() (bool, error)

IsGlint reads PIER_IPROP_IS_GLINT: ItemStackBase::isGlint

Item.IsBundle

Go
func (i Item) IsBundle() (bool, error)

IsBundle reads PIER_IPROP_IS_BUNDLE: ItemStackBase::isBundle

Item.HasUserData

Go
func (i Item) HasUserData() (bool, error)

HasUserData reads PIER_IPROP_HAS_USER_DATA: ItemStackBase::hasUserData

Item.HasCustomName

Go
func (i Item) HasCustomName() (bool, error)

HasCustomName reads PIER_IPROP_HAS_CUSTOM_NAME: ItemStackBase::hasCustomHoverName

Item.TypeName

Go
func (i Item) TypeName() (string, error)

TypeName reads PIER_ISTR_TYPE_NAME: ItemStackBase::getTypeName ("minecraft:apple")

Item.Name

Go
func (i Item) Name() (string, error)

Name reads PIER_ISTR_NAME: ItemStackBase::getName (display)

Item.CustomName

Go
func (i Item) CustomName() (string, error)

CustomName reads PIER_ISTR_CUSTOM_NAME: ItemStackBase::getCustomName

Item.RawNameId

Go
func (i Item) RawNameId() (string, error)

RawNameId reads PIER_ISTR_RAW_NAME_ID: ItemStackBase::getRawNameId

Item.Lore

Go
func (i Item) Lore() (string, error)

Lore reads PIER_ISTR_LORE: SNBT list ["l1","l2"] ItemStackBase::getCustomLore

Item.CanDestroy

Go
func (i Item) CanDestroy() (string, error)

CanDestroy reads PIER_ISTR_CAN_DESTROY: SNBT list ["minecraft:stone",…]

Item.CanPlaceOn

Go
func (i Item) CanPlaceOn() (string, error)

CanPlaceOn reads PIER_ISTR_CAN_PLACE_ON: SNBT list

Item.UserData

Go
func (i Item) UserData() (string, error)

UserData reads PIER_ISTR_USER_DATA: full NBT user data as SNBT

Item.HoverName

Go
func (i Item) HoverName() (string, error)

HoverName reads PIER_ISTR_HOVER_NAME: ItemStackBase::getHoverName

Item.EffectName

Go
func (i Item) EffectName() (string, error)

EffectName reads PIER_ISTR_EFFECT_NAME: ItemStackBase::getEffectName

Item.Color

Go
func (i Item) Color() (string, error)

Color reads PIER_ISTR_COLOR: SNBT {r,g,b} ItemStackBase::getColor

Container

Go
1
2
3
type Container struct {
    Ref ContainerRef
}

Container is a player's or a block's container.

Container.Size

Go
func (c Container) Size() (int32, error)

Size is the number of slots.

Container.Item

Go
func (c Container) Item(slot int32) (Item, error)

Item is the item in one slot.

Container.SetItem

Go
func (c Container) SetItem(slot int32, item Item) error

SetItem puts an item into one slot.

Container.AddItem

Go
func (c Container) AddItem(item Item) error

AddItem adds an item where it fits.

Container.RemoveItem

Go
func (c Container) RemoveItem(slot, count int32) error

RemoveItem removes count items from one slot.

Container.Clear

Go
func (c Container) Clear() error

Clear empties the container.

Container.Items

Go
func (c Container) Items() ([]SlotItem, error)

Items lists the occupied slots.

SlotItem

Go
1
2
3
4
type SlotItem struct {
    Slot int32
    SNBT string
}

SlotItem is one occupied slot of a container and its item as SNBT.

ContainerRef

Go
1
2
3
4
5
6
type ContainerRef struct {
    Which   int32
    Player  PlayerSel
    Dim     int32
    X, Y, Z int32
}

ContainerRef names a container: a player's inventory, ender chest, armor or offhand, or the container of a block.

IProp*

Name Value Description
IPropCount 0 IPropCount is PIER_IPROP_COUNT: ItemStackBase::mCount
IPropMaxStackSize 1 IPropMaxStackSize is PIER_IPROP_MAX_STACK_SIZE: ItemStackBase::getMaxStackSize
IPropAuxValue 2 IPropAuxValue is PIER_IPROP_AUX_VALUE: ItemStackBase::getAuxValue
IPropId 3 IPropId is PIER_IPROP_ID: ItemStackBase::getId
IPropDamage 4 IPropDamage is PIER_IPROP_DAMAGE: ItemStackBase::getDamageValue
IPropIsNull 5 IPropIsNull is PIER_IPROP_IS_NULL: ItemStackBase::isNull
IPropIsBlock 6 IPropIsBlock is PIER_IPROP_IS_BLOCK: ItemStackBase::isBlock
IPropIsEnchanted 7 IPropIsEnchanted is PIER_IPROP_IS_ENCHANTED: ItemStackBase::isEnchanted
IPropIsArmor 8 IPropIsArmor is PIER_IPROP_IS_ARMOR: ItemStackBase::isArmorItem
IPropIsDamageable 9 IPropIsDamageable is PIER_IPROP_IS_DAMAGEABLE: ItemStackBase::isDamageableItem
IPropIsDamaged 10 IPropIsDamaged is PIER_IPROP_IS_DAMAGED: ItemStackBase::isDamaged
IPropMaxDamage 11 IPropMaxDamage is PIER_IPROP_MAX_DAMAGE: ItemStackBase::getMaxDamage
IPropIsUnbreakable 12 IPropIsUnbreakable is PIER_IPROP_IS_UNBREAKABLE: ItemStackBase::isUnbreakable
IPropHasDurability 13 IPropHasDurability is PIER_IPROP_HAS_DURABILITY: ItemStackBase::hasDurability
IPropIsPotion 14 IPropIsPotion is PIER_IPROP_IS_POTION: ItemStackBase::isPotionItem
IPropIsThrowable 15 IPropIsThrowable is PIER_IPROP_IS_THROWABLE: ItemStackBase::isThrowable
IPropIsFireResistant 16 IPropIsFireResistant is PIER_IPROP_IS_FIRE_RESISTANT: ItemStackBase::isFireResistant
IPropAttackDamage 17 IPropAttackDamage is PIER_IPROP_ATTACK_DAMAGE: ItemStackBase::getAttackDamage
IPropRepairCost 18 IPropRepairCost is PIER_IPROP_REPAIR_COST: ItemStackBase::getBaseRepairCost
IPropEnchantValue 19 IPropEnchantValue is PIER_IPROP_ENCHANT_VALUE: ItemStackBase::getEnchantValue
IPropIsStackable 20 IPropIsStackable is PIER_IPROP_IS_STACKABLE: ItemStackBase::isStackable
IPropIsMusicDisc 21 IPropIsMusicDisc is PIER_IPROP_IS_MUSIC_DISC: ItemStackBase::isMusicDiscItem
IPropIsOffhand 22 IPropIsOffhand is PIER_IPROP_IS_OFFHAND: ItemStackBase::isOffhandItem
IPropUseDuration 23 IPropUseDuration is PIER_IPROP_USE_DURATION: ItemStackBase::getMaxUseDuration
IPropIsGlint 24 IPropIsGlint is PIER_IPROP_IS_GLINT: ItemStackBase::isGlint
IPropIsBundle 25 IPropIsBundle is PIER_IPROP_IS_BUNDLE: ItemStackBase::isBundle
IPropHasUserData 26 IPropHasUserData is PIER_IPROP_HAS_USER_DATA: ItemStackBase::hasUserData
IPropHasCustomName 27 IPropHasCustomName is PIER_IPROP_HAS_CUSTOM_NAME: ItemStackBase::hasCustomHoverName

IStr*

Name Value Description
IStrTypeName 0 IStrTypeName is PIER_ISTR_TYPE_NAME: ItemStackBase::getTypeName ("minecraft:apple")
IStrName 1 IStrName is PIER_ISTR_NAME: ItemStackBase::getName (display)
IStrCustomName 2 IStrCustomName is PIER_ISTR_CUSTOM_NAME: ItemStackBase::getCustomName
IStrRawNameId 3 IStrRawNameId is PIER_ISTR_RAW_NAME_ID: ItemStackBase::getRawNameId
IStrLore 4 IStrLore is PIER_ISTR_LORE: SNBT list ["l1","l2"] ItemStackBase::getCustomLore
IStrCanDestroy 5 IStrCanDestroy is PIER_ISTR_CAN_DESTROY: SNBT list ["minecraft:stone",…]
IStrCanPlaceOn 6 IStrCanPlaceOn is PIER_ISTR_CAN_PLACE_ON: SNBT list
IStrUserData 7 IStrUserData is PIER_ISTR_USER_DATA: full NBT user data as SNBT
IStrHoverName 8 IStrHoverName is PIER_ISTR_HOVER_NAME: ItemStackBase::getHoverName
IStrEffectName 9 IStrEffectName is PIER_ISTR_EFFECT_NAME: ItemStackBase::getEffectName
IStrColor 10 IStrColor is PIER_ISTR_COLOR: SNBT {r,g,b} ItemStackBase::getColor

Container*

The values of ContainerRef.Which.

Name Value Description
ContainerInventory 0
ContainerEnderChest 1
ContainerArmor 2
ContainerOffhand 3
ContainerBlock 4