server.item
Constants #
const max_book_pages = 50
max_book_pages and max_book_page_bytes bound what a client can push into a book's NBT.
const max_book_page_bytes = 256
const custom_item_runtime_id_start = 10000
Runtime ids for custom items start well above the vanilla palette so they never collide with it.
fn book_pages_from_nbt #
fn book_pages_from_nbt(raw []u8) []string
fn combat_progression_items #
fn combat_progression_items() []Item
fn container_items #
fn container_items() []Item
fn damage_item #
fn damage_item(it Item, current_meta int, amount int) DamageResult
damage_item computes the result of applying amount points of durability damage to an item currently at current_meta.
fn decorative_items #
fn decorative_items() []Item
fn farming_items #
fn farming_items() []Item
fn new_andesite_item #
fn new_andesite_item() AndesiteItem
fn new_apple #
fn new_apple() AppleItem
fn new_armor_item #
fn new_armor_item(tier ArmorTier, slot ArmorSlot) ArmorItem
new_armor_item builds the class for a tier x slot combination.
fn new_baked_potato #
fn new_baked_potato() BakedPotatoItem
fn new_bedrock_item #
fn new_bedrock_item() BedrockItem
fn new_beef #
fn new_beef() BeefItem
fn new_beetroot #
fn new_beetroot() BeetrootItem
fn new_beetroot_soup #
fn new_beetroot_soup() BeetrootSoupItem
fn new_blue_ice_item #
fn new_blue_ice_item() BlueIceItem
fn new_bone_meal_item #
fn new_bone_meal_item() BoneMealItem
fn new_bread #
fn new_bread() BreadItem
fn new_cake #
fn new_cake() CakeItem
fn new_calcite_item #
fn new_calcite_item() CalciteItem
fn new_carrot #
fn new_carrot() CarrotItem
fn new_chicken #
fn new_chicken() ChickenItem
fn new_clay_item #
fn new_clay_item() ClayItem
fn new_coal #
fn new_coal() CoalItem
fn new_coal_block_item #
fn new_coal_block_item() CoalBlockItem
fn new_coal_ore_item #
fn new_coal_ore_item() CoalOreItem
fn new_cobbled_deepslate_item #
fn new_cobbled_deepslate_item() CobbledDeepslateItem
fn new_cobblestone_item #
fn new_cobblestone_item() CobblestoneItem
fn new_cod #
fn new_cod() CodItem
fn new_compass_item #
fn new_compass_item() CompassItem
fn new_cooked_beef #
fn new_cooked_beef() CookedBeefItem
fn new_cooked_chicken #
fn new_cooked_chicken() CookedChickenItem
fn new_cooked_cod #
fn new_cooked_cod() CookedCodItem
fn new_cooked_mutton #
fn new_cooked_mutton() CookedMuttonItem
fn new_cooked_porkchop #
fn new_cooked_porkchop() CookedPorkchopItem
fn new_cooked_salmon #
fn new_cooked_salmon() CookedSalmonItem
fn new_copper_block_item #
fn new_copper_block_item() CopperBlockItem
fn new_copper_ingot #
fn new_copper_ingot() CopperIngotItem
fn new_copper_ore_item #
fn new_copper_ore_item() CopperOreItem
fn new_custom_registry #
fn new_custom_registry() CustomRegistry
fn new_diamond #
fn new_diamond() DiamondItem
fn new_diamond_block_item #
fn new_diamond_block_item() DiamondBlockItem
fn new_diamond_ore_item #
fn new_diamond_ore_item() DiamondOreItem
fn new_diorite_item #
fn new_diorite_item() DioriteItem
fn new_dirt_item #
fn new_dirt_item() DirtItem
fn new_dried_kelp #
fn new_dried_kelp() DriedKelpItem
fn new_dripstone_block_item #
fn new_dripstone_block_item() DripstoneBlockItem
fn new_emerald #
fn new_emerald() EmeraldItem
fn new_emerald_block_item #
fn new_emerald_block_item() EmeraldBlockItem
fn new_emerald_ore_item #
fn new_emerald_ore_item() EmeraldOreItem
fn new_end_bricks_item #
fn new_end_bricks_item() EndBricksItem
fn new_end_stone_item #
fn new_end_stone_item() EndStoneItem
fn new_glow_berries #
fn new_glow_berries() GlowBerriesItem
fn new_glowstone_item #
fn new_glowstone_item() GlowstoneItem
fn new_goat_horn_item #
fn new_goat_horn_item() GoatHornItem
fn new_gold_block_item #
fn new_gold_block_item() GoldBlockItem
fn new_gold_ingot #
fn new_gold_ingot() GoldIngotItem
fn new_gold_ore_item #
fn new_gold_ore_item() GoldOreItem
fn new_golden_apple #
fn new_golden_apple() GoldenAppleItem
fn new_golden_carrot #
fn new_golden_carrot() GoldenCarrotItem
fn new_granite_item #
fn new_granite_item() GraniteItem
fn new_grass_block_item #
fn new_grass_block_item() GrassBlockItem
fn new_gravel_item #
fn new_gravel_item() GravelItem
fn new_honey_bottle #
fn new_honey_bottle() HoneyBottleItem
fn new_ice_item #
fn new_ice_item() IceItem
fn new_iron_block_item #
fn new_iron_block_item() IronBlockItem
fn new_iron_ingot #
fn new_iron_ingot() IronIngotItem
fn new_iron_ore_item #
fn new_iron_ore_item() IronOreItem
fn new_lapis_block_item #
fn new_lapis_block_item() LapisBlockItem
fn new_lapis_lazuli #
fn new_lapis_lazuli() LapisLazuliItem
fn new_lapis_ore_item #
fn new_lapis_ore_item() LapisOreItem
fn new_lodestone_compass_item #
fn new_lodestone_compass_item() LodestoneCompassItem
fn new_magma_block_item #
fn new_magma_block_item() MagmaBlockItem
fn new_melon_slice #
fn new_melon_slice() MelonSliceItem
fn new_mossy_cobblestone_item #
fn new_mossy_cobblestone_item() MossyCobblestoneItem
fn new_mushroom_stew #
fn new_mushroom_stew() MushroomStewItem
fn new_mutton #
fn new_mutton() MuttonItem
fn new_netherrack_item #
fn new_netherrack_item() NetherrackItem
fn new_obsidian_item #
fn new_obsidian_item() ObsidianItem
fn new_packed_ice_item #
fn new_packed_ice_item() PackedIceItem
fn new_poisonous_potato #
fn new_poisonous_potato() PoisonousPotatoItem
fn new_polished_andesite_item #
fn new_polished_andesite_item() PolishedAndesiteItem
fn new_polished_diorite_item #
fn new_polished_diorite_item() PolishedDioriteItem
fn new_polished_granite_item #
fn new_polished_granite_item() PolishedGraniteItem
fn new_porkchop #
fn new_porkchop() PorkchopItem
fn new_potato #
fn new_potato() PotatoItem
fn new_pumpkin_pie #
fn new_pumpkin_pie() PumpkinPieItem
fn new_purpur_block_item #
fn new_purpur_block_item() PurpurBlockItem
fn new_rabbit_stew #
fn new_rabbit_stew() RabbitStewItem
fn new_raw_copper #
fn new_raw_copper() RawCopperItem
fn new_raw_gold #
fn new_raw_gold() RawGoldItem
fn new_raw_iron #
fn new_raw_iron() RawIronItem
fn new_recovery_compass_item #
fn new_recovery_compass_item() RecoveryCompassItem
fn new_red_sand_item #
fn new_red_sand_item() RedSandItem
fn new_redstone #
fn new_redstone() RedstoneItem
fn new_redstone_block_item #
fn new_redstone_block_item() RedstoneBlockItem
fn new_redstone_ore_item #
fn new_redstone_ore_item() RedstoneOreItem
fn new_registry #
fn new_registry() Registry
new_registry builds a Registry pre-populated with the built-in item classes.
fn new_salmon #
fn new_salmon() SalmonItem
fn new_sand_item #
fn new_sand_item() SandItem
fn new_sandstone_item #
fn new_sandstone_item() SandstoneItem
fn new_smooth_basalt_item #
fn new_smooth_basalt_item() SmoothBasaltItem
fn new_snow_item #
fn new_snow_item() SnowItem
fn new_soul_sand_item #
fn new_soul_sand_item() SoulSandItem
fn new_soul_soil_item #
fn new_soul_soil_item() SoulSoilItem
fn new_stick #
fn new_stick() StickItem
fn new_stone_item #
fn new_stone_item() StoneItem
fn new_sweet_berries #
fn new_sweet_berries() SweetBerriesItem
fn new_tool_item #
fn new_tool_item(tier ToolTier, typ ToolType) ToolItem
new_tool_item builds the class for a tier x tool-type combination.
fn new_tuff_item #
fn new_tuff_item() TuffItem
fn new_wheat #
fn new_wheat() WheatItem
fn potion_from_meta #
fn potion_from_meta(meta int) PotionType
fn redstone_component_items #
fn redstone_component_items() []Item
fn wood_items #
fn wood_items() []Item
fn writable_book_nbt #
fn writable_book_nbt(pages []string) []u8
fn written_book_nbt #
fn written_book_nbt(title string, author string, generation int, pages []string) []u8
fn ArmorSlot.from #
fn ArmorSlot.from[W](input W) !ArmorSlot
fn ArmorTier.from #
fn ArmorTier.from[W](input W) !ArmorTier
fn ToolTier.from #
fn ToolTier.from[W](input W) !ToolTier
fn ToolType.from #
fn ToolType.from[W](input W) !ToolType
interface ConsumableItem #
interface ConsumableItem {
consume_result(meta int) ConsumeResult
}
interface CooldownItem #
interface CooldownItem {
cooldown_ticks() int
}
CooldownItem is implemented by items that can't be used again for a period after use (e.g. the goat horn).
interface Item #
interface Item {
// identifier returns the namespaced item id used on the wire.
identifier() string
// max_stack_size is how many of this item fit in a single slot.
max_stack_size() int
// attack_damage is the melee damage dealt on hit, 0 for non-weapons.
attack_damage() f32
// nutrition is the hunger points restored on eat, 0 for non-food.
nutrition() int
// saturation is the saturation modifier applied on eat, 0 for non-food.
saturation() f32
// block_runtime_id is the block placed on use, 0 for non-block items.
block_runtime_id() int
// durability is the max number of uses before the item breaks, 0 for
// items that don't take durability damage.
durability() int
// mining_speed is the block breaking speed multiplier this item grants
// as a tool, 1.0 (no bonus) for non-tools.
mining_speed() f32
// armor_points is the defense value this item grants when worn, 0 for
// non-armor.
armor_points() int
}
Item is the behaviour contract every item class implements. Every item is its own class built on a family base struct (ToolItem, ArmorItem, FoodItem, BlockItem, SimpleItem) and registered in the Registry so the session layer can look it up by its string identifier (e.g. 'minecraft:diamond_sword').
interface UsableOnBlockItem #
interface UsableOnBlockItem {
use_on_block_result(block_name string, meta int) ?UseOnBlockResult
}
UsableOnBlockItem is implemented by items with a behaviour when used on a specific kind of block (e.g. bone meal on crops). Returns none if this item does nothing to a block named block_name.
interface UsableOnEntityItem #
interface UsableOnEntityItem {
use_on_entity_result(meta int) UseOnEntityResult
}
UsableOnEntityItem is implemented by items with a behaviour when used on an entity.
interface UseableItem #
interface UseableItem {
use_result(meta int) UseResult
}
UseableItem is implemented by items with a behaviour on right-click in air (item_use_action_click_air), separate from ConsumableItem's eat on use flow.
enum ArmorSlot #
enum ArmorSlot {
helmet
chestplate
leggings
boots
}
ArmorSlot is the equipment slot an armor piece occupies.
enum ArmorTier #
enum ArmorTier {
leather
gold
copper
iron
diamond
netherite
}
ArmorTier is the material tier shared by every armor piece.
enum ToolTier #
enum ToolTier {
wood
stone
copper
iron
gold
diamond
netherite
}
ToolTier is the material tier shared by every tool and weapon.
enum ToolType #
enum ToolType {
sword
pickaxe
axe
shovel
hoe
}
ToolType is the tool/weapon shape. Attack damage differs by type; mining speed and durability are tier-only (same across all five shapes).
struct AndesiteItem #
struct AndesiteItem {
BlockItem
}
AndesiteItem is the block-item for 'minecraft:andesite'.
struct AppleItem #
struct AppleItem {
FoodItem
}
AppleItem is the class for 'minecraft:apple'.
struct ArmorItem #
struct ArmorItem {
pub:
id string
tier ArmorTier
slot ArmorSlot
defense int
max_durability int
}
fn (ArmorItem) identifier #
fn (i ArmorItem) identifier() string
fn (ArmorItem) max_stack_size #
fn (i ArmorItem) max_stack_size() int
fn (ArmorItem) attack_damage #
fn (i ArmorItem) attack_damage() f32
fn (ArmorItem) nutrition #
fn (i ArmorItem) nutrition() int
fn (ArmorItem) saturation #
fn (i ArmorItem) saturation() f32
fn (ArmorItem) block_runtime_id #
fn (i ArmorItem) block_runtime_id() int
fn (ArmorItem) durability #
fn (i ArmorItem) durability() int
fn (ArmorItem) mining_speed #
fn (i ArmorItem) mining_speed() f32
fn (ArmorItem) armor_points #
fn (i ArmorItem) armor_points() int
struct BakedPotatoItem #
struct BakedPotatoItem {
FoodItem
}
BakedPotatoItem is the class for 'minecraft:baked_potato'.
struct BedrockItem #
struct BedrockItem {
BlockItem
}
BedrockItem is the class for 'minecraft:bedrock'.
struct BeefItem #
struct BeefItem {
FoodItem
}
BeefItem is the class for 'minecraft:beef'.
struct BeetrootItem #
struct BeetrootItem {
FoodItem
}
BeetrootItem is the class for 'minecraft:beetroot'.
fn (BeetrootItem) use_on_block_result #
fn (i BeetrootItem) use_on_block_result(block_name string, meta int) ?UseOnBlockResult
struct BeetrootSoupItem #
struct BeetrootSoupItem {
FoodItem
}
BeetrootSoupItem is the class for 'minecraft:beetroot_soup'.
struct BlockItem #
struct BlockItem {
pub:
id string
block_runtime int
stack_max int = 64
}
BlockItem is the base class for items that place a block when used against a face. It carries the block runtime id the session should set in the world. Concrete block items embed it, one class per block item.
fn (BlockItem) identifier #
fn (i BlockItem) identifier() string
fn (BlockItem) max_stack_size #
fn (i BlockItem) max_stack_size() int
fn (BlockItem) attack_damage #
fn (i BlockItem) attack_damage() f32
fn (BlockItem) nutrition #
fn (i BlockItem) nutrition() int
fn (BlockItem) saturation #
fn (i BlockItem) saturation() f32
fn (BlockItem) block_runtime_id #
fn (i BlockItem) block_runtime_id() int
fn (BlockItem) durability #
fn (i BlockItem) durability() int
fn (BlockItem) mining_speed #
fn (i BlockItem) mining_speed() f32
fn (BlockItem) armor_points #
fn (i BlockItem) armor_points() int
struct BlueIceItem #
struct BlueIceItem {
BlockItem
}
BlueIceItem is the block-item for 'minecraft:blue_ice'.
struct BoneMealItem #
struct BoneMealItem {
SimpleItem
}
BoneMealItem is the class for 'minecraft:bone_meal'.
fn (BoneMealItem) use_on_block_result #
fn (i BoneMealItem) use_on_block_result(block_name string, meta int) ?UseOnBlockResult
struct BreadItem #
struct BreadItem {
FoodItem
}
BreadItem is the class for 'minecraft:bread'.
struct CakeItem #
struct CakeItem {
FoodItem
}
CakeItem is the class for 'minecraft:cake'.
struct CalciteItem #
struct CalciteItem {
BlockItem
}
CalciteItem is the block-item for 'minecraft:calcite'.
struct CarrotItem #
struct CarrotItem {
FoodItem
pub:
block_runtime int
}
CarrotItem is the class for 'minecraft:carrot'. No separate seed item exists (unlike wheat/beetroot).
fn (CarrotItem) block_runtime_id #
fn (i CarrotItem) block_runtime_id() int
fn (CarrotItem) use_on_block_result #
fn (i CarrotItem) use_on_block_result(block_name string, meta int) ?UseOnBlockResult
struct ChickenItem #
struct ChickenItem {
FoodItem
}
ChickenItem is the class for 'minecraft:chicken'.
struct ClayItem #
struct ClayItem {
BlockItem
}
ClayItem is the block-item for 'minecraft:clay'.
struct CoalBlockItem #
struct CoalBlockItem {
BlockItem
}
CoalBlockItem is the block-item for 'minecraft:coal_block'.
struct CoalItem #
struct CoalItem {
SimpleItem
}
CoalItem is the class for 'minecraft:coal'.
struct CoalOreItem #
struct CoalOreItem {
BlockItem
}
CoalOreItem is the block-item for 'minecraft:coal_ore'.
struct CobbledDeepslateItem #
struct CobbledDeepslateItem {
BlockItem
}
CobbledDeepslateItem is the block-item for 'minecraft:cobbled_deepslate'.
struct CobblestoneItem #
struct CobblestoneItem {
BlockItem
}
CobblestoneItem is the block-item for 'minecraft:cobblestone'.
struct CodItem #
struct CodItem {
FoodItem
}
CodItem is the class for 'minecraft:cod'.
struct CompassItem #
struct CompassItem {
SimpleItem
}
CompassItem is the class for 'minecraft:compass'.
struct ConsumeResult #
struct ConsumeResult {
pub:
effects []effect.Effect
replacement_id string
replacement_count int
}
struct CookedBeefItem #
struct CookedBeefItem {
FoodItem
}
CookedBeefItem is the class for 'minecraft:cooked_beef'.
struct CookedChickenItem #
struct CookedChickenItem {
FoodItem
}
CookedChickenItem is the class for 'minecraft:cooked_chicken'.
struct CookedCodItem #
struct CookedCodItem {
FoodItem
}
CookedCodItem is the class for 'minecraft:cooked_cod'.
struct CookedMuttonItem #
struct CookedMuttonItem {
FoodItem
}
CookedMuttonItem is the class for 'minecraft:cooked_mutton'.
struct CookedPorkchopItem #
struct CookedPorkchopItem {
FoodItem
}
CookedPorkchopItem is the class for 'minecraft:cooked_porkchop'.
struct CookedSalmonItem #
struct CookedSalmonItem {
FoodItem
}
CookedSalmonItem is the class for 'minecraft:cooked_salmon'.
struct CookieItem #
struct CookieItem {
FoodItem
}
CookieItem is the class for 'minecraft:cookie'.
struct CooldownComponent #
struct CooldownComponent {
pub:
category string
duration f32
}
CooldownComponent gives the item a use cooldown, grouped by category.
struct CopperBlockItem #
struct CopperBlockItem {
BlockItem
}
CopperBlockItem is the block-item for 'minecraft:copper_block'.
struct CopperIngotItem #
struct CopperIngotItem {
SimpleItem
}
CopperIngotItem is the class for 'minecraft:copper_ingot'.
struct CopperOreItem #
struct CopperOreItem {
BlockItem
}
CopperOreItem is the block-item for 'minecraft:copper_ore'.
struct CustomItemClass #
struct CustomItemClass {
pub:
def CustomItemDefinition
}
CustomItemClass adapts a definition to the Item interface so the session layer treats custom items like any built-in class.
fn (CustomItemClass) identifier #
fn (c CustomItemClass) identifier() string
fn (CustomItemClass) max_stack_size #
fn (c CustomItemClass) max_stack_size() int
fn (CustomItemClass) attack_damage #
fn (c CustomItemClass) attack_damage() f32
fn (CustomItemClass) nutrition #
fn (c CustomItemClass) nutrition() int
fn (CustomItemClass) saturation #
fn (c CustomItemClass) saturation() f32
fn (CustomItemClass) block_runtime_id #
fn (c CustomItemClass) block_runtime_id() int
fn (CustomItemClass) durability #
fn (c CustomItemClass) durability() int
fn (CustomItemClass) mining_speed #
fn (c CustomItemClass) mining_speed() f32
fn (CustomItemClass) armor_points #
fn (c CustomItemClass) armor_points() int
struct CustomItemDefinition #
struct CustomItemDefinition {
pub mut:
id string
display_name string
texture string
max_stack_size int = 64
attack_damage_value int
hand_equipped bool
allow_off_hand bool
glint bool
can_destroy_in_creative bool = true
mining_speed f32 = 1.0
fuel_duration f32
creative_group_index int
tags []string
digger_speeds []DiggerSpeed
food ?FoodComponent
wearable ?WearableComponent
cooldown ?CooldownComponent
enchantable ?EnchantableComponent
durability_component ?DurabilityComponent
runtime_id int
}
CustomItemDefinition describes a data-driven item a plugin registers. The definition is turned into component NBT and shipped to the client inside the ItemRegistryPacket, so no resource pack code is needed server-side beyond the texture name.
fn (CustomItemDefinition) components #
fn (d &CustomItemDefinition) components() nbt.RootTag
components builds the component NBT the client consumes: an item_properties compound for the base properties and one minecraft:* compound per opted-in component.
struct CustomRegistry #
struct CustomRegistry {
mut:
defs []CustomItemDefinition
ids map[string]int
next_id int = custom_item_runtime_id_start
}
CustomRegistry owns every registered custom item definition and hands out runtime ids sequentially, starting at custom_item_runtime_id_start.
fn (CustomRegistry) register #
fn (mut r CustomRegistry) register(def CustomItemDefinition) int
register allocates a runtime id for def and stores it. Registering the same id again returns the previously allocated runtime id unchanged.
fn (CustomRegistry) all #
fn (r &CustomRegistry) all() []CustomItemDefinition
all returns every registered definition with its runtime id filled in.
fn (CustomRegistry) len #
fn (r &CustomRegistry) len() int
fn (CustomRegistry) runtime_id #
fn (r &CustomRegistry) runtime_id(id string) ?int
fn (CustomRegistry) names #
fn (r &CustomRegistry) names() []string
struct DamageResult #
struct DamageResult {
pub:
broken bool
new_meta int
}
DamageResult is the outcome of applying durability damage to a stack. broken means the item should be removed (or replaced with its broken item, once anything defines one. For now, every durable item just disappears.
struct DiamondBlockItem #
struct DiamondBlockItem {
BlockItem
}
DiamondBlockItem is the block-item for 'minecraft:diamond_block'.
struct DiamondItem #
struct DiamondItem {
SimpleItem
}
DiamondItem is the class for 'minecraft:diamond'.
struct DiamondOreItem #
struct DiamondOreItem {
BlockItem
}
DiamondOreItem is the block-item for 'minecraft:diamond_ore'.
struct DiggerSpeed #
struct DiggerSpeed {
pub:
block string
speed int
}
DiggerSpeed is one block (or block tag query) the item digs faster.
struct DioriteItem #
struct DioriteItem {
BlockItem
}
DioriteItem is the block-item for 'minecraft:diorite'.
struct DirtItem #
struct DirtItem {
BlockItem
}
DirtItem is the class for 'minecraft:dirt'.
struct DriedKelpItem #
struct DriedKelpItem {
FoodItem
}
DriedKelpItem is the class for 'minecraft:dried_kelp'.
struct DripstoneBlockItem #
struct DripstoneBlockItem {
BlockItem
}
DripstoneBlockItem is the block-item for 'minecraft:dripstone_block'.
struct DurabilityComponent #
struct DurabilityComponent {
pub:
max_durability int
}
DurabilityComponent gives the item a durability bar.
struct DurabilityItem #
struct DurabilityItem {
pub:
id string
damage f32
max_durability int
}
DurabilityItem is the base class for held combat items whose only shared behaviour is "takes durability damage, one per slot"; unlike ToolItem/ ArmorItem there's no tier x shape matrix here (shield/bow/crossbow/trident are each one-off items).
fn (DurabilityItem) identifier #
fn (i DurabilityItem) identifier() string
fn (DurabilityItem) max_stack_size #
fn (i DurabilityItem) max_stack_size() int
fn (DurabilityItem) attack_damage #
fn (i DurabilityItem) attack_damage() f32
fn (DurabilityItem) nutrition #
fn (i DurabilityItem) nutrition() int
fn (DurabilityItem) saturation #
fn (i DurabilityItem) saturation() f32
fn (DurabilityItem) block_runtime_id #
fn (i DurabilityItem) block_runtime_id() int
fn (DurabilityItem) durability #
fn (i DurabilityItem) durability() int
fn (DurabilityItem) mining_speed #
fn (i DurabilityItem) mining_speed() f32
fn (DurabilityItem) armor_points #
fn (i DurabilityItem) armor_points() int
struct EmeraldBlockItem #
struct EmeraldBlockItem {
BlockItem
}
EmeraldBlockItem is the block-item for 'minecraft:emerald_block'.
struct EmeraldItem #
struct EmeraldItem {
SimpleItem
}
EmeraldItem is the class for 'minecraft:emerald'.
struct EmeraldOreItem #
struct EmeraldOreItem {
BlockItem
}
EmeraldOreItem is the block-item for 'minecraft:emerald_ore'.
struct EnchantableComponent #
struct EnchantableComponent {
pub:
slot string
value int
}
EnchantableComponent controls which enchantment slot the item accepts and its enchantability value.
struct EndBricksItem #
struct EndBricksItem {
BlockItem
}
EndBricksItem is the block-item for 'minecraft:end_bricks'.
struct EndStoneItem #
struct EndStoneItem {
BlockItem
}
EndStoneItem is the block-item for 'minecraft:end_stone'.
struct FallbackEntry #
struct FallbackEntry {
pub:
id string
block_runtime int
}
struct FoodComponent #
struct FoodComponent {
pub:
nutrition int
saturation f32
can_always_eat bool
}
FoodComponent makes a custom item edible.
struct FoodItem #
struct FoodItem {
pub:
id string
food_points int
saturation_mod f32
stack_max int = 64
}
FoodItem is the base class for edibles. food_points is the number of hunger points restored on eat, saturation_mod the saturation modifier. Concrete foods embed it, one class per food.
fn (FoodItem) identifier #
fn (i FoodItem) identifier() string
fn (FoodItem) max_stack_size #
fn (i FoodItem) max_stack_size() int
fn (FoodItem) attack_damage #
fn (i FoodItem) attack_damage() f32
fn (FoodItem) nutrition #
fn (i FoodItem) nutrition() int
fn (FoodItem) saturation #
fn (i FoodItem) saturation() f32
fn (FoodItem) block_runtime_id #
fn (i FoodItem) block_runtime_id() int
fn (FoodItem) durability #
fn (i FoodItem) durability() int
fn (FoodItem) mining_speed #
fn (i FoodItem) mining_speed() f32
fn (FoodItem) armor_points #
fn (i FoodItem) armor_points() int
struct GlowBerriesItem #
struct GlowBerriesItem {
FoodItem
}
GlowBerriesItem is the class for 'minecraft:glow_berries'.
struct GlowstoneItem #
struct GlowstoneItem {
BlockItem
}
GlowstoneItem is the block-item for 'minecraft:glowstone'.
struct GoatHornItem #
struct GoatHornItem {
SimpleItem
}
GoatHornItem is the class for 'minecraft:goat_horn'.
fn (GoatHornItem) use_result #
fn (i GoatHornItem) use_result(meta int) UseResult
fn (GoatHornItem) cooldown_ticks #
fn (i GoatHornItem) cooldown_ticks() int
struct GoldBlockItem #
struct GoldBlockItem {
BlockItem
}
GoldBlockItem is the block-item for 'minecraft:gold_block'.
struct GoldIngotItem #
struct GoldIngotItem {
SimpleItem
}
GoldIngotItem is the class for 'minecraft:gold_ingot'.
struct GoldOreItem #
struct GoldOreItem {
BlockItem
}
GoldOreItem is the block-item for 'minecraft:gold_ore'.
struct GoldenAppleItem #
struct GoldenAppleItem {
FoodItem
}
GoldenAppleItem is the class for 'minecraft:golden_apple'.
struct GoldenCarrotItem #
struct GoldenCarrotItem {
FoodItem
}
GoldenCarrotItem is the class for 'minecraft:golden_carrot'.
struct GraniteItem #
struct GraniteItem {
BlockItem
}
GraniteItem is the block-item for 'minecraft:granite'.
struct GrassBlockItem #
struct GrassBlockItem {
BlockItem
}
GrassBlockItem is the class for 'minecraft:grass_block'.
struct GravelItem #
struct GravelItem {
BlockItem
}
GravelItem is the block-item for 'minecraft:gravel'.
struct HoneyBottleItem #
struct HoneyBottleItem {
FoodItem
}
HoneyBottleItem is the class for 'minecraft:honey_bottle'.
struct IceItem #
struct IceItem {
BlockItem
}
IceItem is the block-item for 'minecraft:ice'.
struct IronBlockItem #
struct IronBlockItem {
BlockItem
}
IronBlockItem is the block-item for 'minecraft:iron_block'.
struct IronIngotItem #
struct IronIngotItem {
SimpleItem
}
IronIngotItem is the class for 'minecraft:iron_ingot'.
struct IronOreItem #
struct IronOreItem {
BlockItem
}
IronOreItem is the block-item for 'minecraft:iron_ore'.
struct LapisBlockItem #
struct LapisBlockItem {
BlockItem
}
LapisBlockItem is the block-item for 'minecraft:lapis_block'.
struct LapisLazuliItem #
struct LapisLazuliItem {
SimpleItem
}
LapisLazuliItem is the class for 'minecraft:lapis_lazuli'.
struct LapisOreItem #
struct LapisOreItem {
BlockItem
}
LapisOreItem is the block-item for 'minecraft:lapis_ore'.
struct LodestoneCompassItem #
struct LodestoneCompassItem {
SimpleItem
}
LodestoneCompassItem is the class for 'minecraft:lodestone_compass'.
struct MagmaBlockItem #
struct MagmaBlockItem {
BlockItem
}
MagmaBlockItem is the block-item for 'minecraft:magma'.
struct MelonSliceItem #
struct MelonSliceItem {
FoodItem
}
MelonSliceItem is the class for 'minecraft:melon_slice'.
struct MossyCobblestoneItem #
struct MossyCobblestoneItem {
BlockItem
}
MossyCobblestoneItem is the block-item for 'minecraft:mossy_cobblestone'.
struct MushroomStewItem #
struct MushroomStewItem {
FoodItem
}
MushroomStewItem is the class for 'minecraft:mushroom_stew'.
struct MuttonItem #
struct MuttonItem {
FoodItem
}
MuttonItem is the class for 'minecraft:mutton'.
struct NetherrackItem #
struct NetherrackItem {
BlockItem
}
NetherrackItem is the block-item for 'minecraft:netherrack'.
struct ObsidianItem #
struct ObsidianItem {
BlockItem
}
ObsidianItem is the block-item for 'minecraft:obsidian'.
struct PackedIceItem #
struct PackedIceItem {
BlockItem
}
PackedIceItem is the block-item for 'minecraft:packed_ice'.
struct PoisonousPotatoItem #
struct PoisonousPotatoItem {
FoodItem
}
PoisonousPotatoItem is the class for 'minecraft:poisonous_potato'.
struct PolishedAndesiteItem #
struct PolishedAndesiteItem {
BlockItem
}
PolishedAndesiteItem is the block-item for 'minecraft:polished_andesite'.
struct PolishedDioriteItem #
struct PolishedDioriteItem {
BlockItem
}
PolishedDioriteItem is the block-item for 'minecraft:polished_diorite'.
struct PolishedGraniteItem #
struct PolishedGraniteItem {
BlockItem
}
PolishedGraniteItem is the block-item for 'minecraft:polished_granite'.
struct PorkchopItem #
struct PorkchopItem {
FoodItem
}
PorkchopItem is the class for 'minecraft:porkchop'.
struct PotatoItem #
struct PotatoItem {
FoodItem
pub:
block_runtime int
}
PotatoItem is the class for 'minecraft:potato'. No separate seed item exists (unlike wheat/beetroot).
fn (PotatoItem) block_runtime_id #
fn (i PotatoItem) block_runtime_id() int
fn (PotatoItem) use_on_block_result #
fn (i PotatoItem) use_on_block_result(block_name string, meta int) ?UseOnBlockResult
struct PotionItem #
struct PotionItem {}
fn (PotionItem) identifier #
fn (i PotionItem) identifier() string
fn (PotionItem) max_stack_size #
fn (i PotionItem) max_stack_size() int
fn (PotionItem) attack_damage #
fn (i PotionItem) attack_damage() f32
fn (PotionItem) nutrition #
fn (i PotionItem) nutrition() int
fn (PotionItem) saturation #
fn (i PotionItem) saturation() f32
fn (PotionItem) block_runtime_id #
fn (i PotionItem) block_runtime_id() int
fn (PotionItem) durability #
fn (i PotionItem) durability() int
fn (PotionItem) mining_speed #
fn (i PotionItem) mining_speed() f32
fn (PotionItem) armor_points #
fn (i PotionItem) armor_points() int
fn (PotionItem) consume_result #
fn (i PotionItem) consume_result(meta int) ConsumeResult
struct PotionType #
struct PotionType {
value int
}
fn (PotionType) id #
fn (p PotionType) id() int
fn (PotionType) effects #
fn (p PotionType) effects() []effect.Effect
struct PumpkinPieItem #
struct PumpkinPieItem {
FoodItem
}
PumpkinPieItem is the class for 'minecraft:pumpkin_pie'.
struct PurpurBlockItem #
struct PurpurBlockItem {
BlockItem
}
PurpurBlockItem is the block-item for 'minecraft:purpur_block'.
struct RabbitStewItem #
struct RabbitStewItem {
FoodItem
}
RabbitStewItem is the class for 'minecraft:rabbit_stew'.
struct RawCopperItem #
struct RawCopperItem {
SimpleItem
}
RawCopperItem is the class for 'minecraft:raw_copper'.
struct RawGoldItem #
struct RawGoldItem {
SimpleItem
}
RawGoldItem is the class for 'minecraft:raw_gold'.
struct RawIronItem #
struct RawIronItem {
SimpleItem
}
RawIronItem is the class for 'minecraft:raw_iron'.
struct RecoveryCompassItem #
struct RecoveryCompassItem {
SimpleItem
}
RecoveryCompassItem is the class for 'minecraft:recovery_compass'.
struct RedSandItem #
struct RedSandItem {
BlockItem
}
RedSandItem is the block-item for 'minecraft:red_sand'.
struct RedstoneBlockItem #
struct RedstoneBlockItem {
BlockItem
}
RedstoneBlockItem is the block-item for 'minecraft:redstone_block'.
struct RedstoneItem #
struct RedstoneItem {
BlockItem
}
RedstoneItem is the class for 'minecraft:redstone' (redstone dust).
struct RedstoneOreItem #
struct RedstoneOreItem {
BlockItem
}
RedstoneOreItem is the block-item for 'minecraft:redstone_ore'.
struct Registry #
struct Registry {
mut:
items map[string]Item
}
Registry maps namespaced item ids to their concrete Item class. The session layer holds one Registry and queries it for per-item behaviour (stack size, attack damage, ...) instead of hard-coding numeric ids.
fn (Registry) register #
fn (mut r Registry) register(it Item)
register adds or overrides the class for an item id.
fn (Registry) register_fallbacks #
fn (mut r Registry) register_fallbacks(entries []FallbackEntry)
fn (Registry) get #
fn (r &Registry) get(id string) ?Item
get returns the registered class for id, or none if unregistered.
fn (Registry) max_stack_size #
fn (r &Registry) max_stack_size(id string) int
max_stack_size returns the stack size for id, falling back to 64 for unregistered items.
fn (Registry) consume_result #
fn (r &Registry) consume_result(id string, meta int) ?ConsumeResult
fn (Registry) use_result #
fn (r &Registry) use_result(id string, meta int) ?UseResult
fn (Registry) use_on_block_result #
fn (r &Registry) use_on_block_result(id string, block_name string, meta int) ?UseOnBlockResult
fn (Registry) use_on_entity_result #
fn (r &Registry) use_on_entity_result(id string, meta int) ?UseOnEntityResult
fn (Registry) cooldown_ticks #
fn (r &Registry) cooldown_ticks(id string) ?int
fn (Registry) len #
fn (r &Registry) len() int
len is the number of registered item classes.
struct SalmonItem #
struct SalmonItem {
FoodItem
}
SalmonItem is the class for 'minecraft:salmon'.
struct SandItem #
struct SandItem {
BlockItem
}
SandItem is the block-item for 'minecraft:sand'.
struct SandstoneItem #
struct SandstoneItem {
BlockItem
}
SandstoneItem is the block-item for 'minecraft:sandstone'.
struct SimpleItem #
struct SimpleItem {
pub:
id string
stack_max int = 64
}
SimpleItem is the base class for items that carry no special behaviour (dyes, sticks, string, ...). Concrete simple items embed it and fill in their identity; anything unregistered behaves like a default SimpleItem.
fn (SimpleItem) identifier #
fn (i SimpleItem) identifier() string
fn (SimpleItem) max_stack_size #
fn (i SimpleItem) max_stack_size() int
fn (SimpleItem) attack_damage #
fn (i SimpleItem) attack_damage() f32
fn (SimpleItem) nutrition #
fn (i SimpleItem) nutrition() int
fn (SimpleItem) saturation #
fn (i SimpleItem) saturation() f32
fn (SimpleItem) block_runtime_id #
fn (i SimpleItem) block_runtime_id() int
fn (SimpleItem) durability #
fn (i SimpleItem) durability() int
fn (SimpleItem) mining_speed #
fn (i SimpleItem) mining_speed() f32
fn (SimpleItem) armor_points #
fn (i SimpleItem) armor_points() int
struct SmoothBasaltItem #
struct SmoothBasaltItem {
BlockItem
}
SmoothBasaltItem is the block-item for 'minecraft:smooth_basalt'.
struct SnowItem #
struct SnowItem {
BlockItem
}
SnowItem is the block-item for 'minecraft:snow'.
struct SoulSandItem #
struct SoulSandItem {
BlockItem
}
SoulSandItem is the block-item for 'minecraft:soul_sand'.
struct SoulSoilItem #
struct SoulSoilItem {
BlockItem
}
SoulSoilItem is the block-item for 'minecraft:soul_soil'.
struct StickItem #
struct StickItem {
SimpleItem
}
StickItem is the class for 'minecraft:stick'.
struct StoneItem #
struct StoneItem {
BlockItem
}
StoneItem is the class for 'minecraft:stone'.
struct SweetBerriesItem #
struct SweetBerriesItem {
FoodItem
}
SweetBerriesItem is the class for 'minecraft:sweet_berries'.
struct ToolItem #
struct ToolItem {
pub:
id string
tier ToolTier
tool_type ToolType
damage f32
max_durability int
speed f32
}
ToolItem is the class for every tier x type combination (e.g. tier .diamond, tool_type .pickaxe -> 'minecraft:diamond_pickaxe'). One parametrized struct instead of 30 near-identical classes, since nothing about a tool's behaviour is unique per material - it's entirely tier+type data (see ITEMS_BLOCKS.md open question 1).
fn (ToolItem) identifier #
fn (i ToolItem) identifier() string
fn (ToolItem) max_stack_size #
fn (i ToolItem) max_stack_size() int
fn (ToolItem) attack_damage #
fn (i ToolItem) attack_damage() f32
fn (ToolItem) nutrition #
fn (i ToolItem) nutrition() int
fn (ToolItem) saturation #
fn (i ToolItem) saturation() f32
fn (ToolItem) block_runtime_id #
fn (i ToolItem) block_runtime_id() int
fn (ToolItem) durability #
fn (i ToolItem) durability() int
fn (ToolItem) mining_speed #
fn (i ToolItem) mining_speed() f32
fn (ToolItem) armor_points #
fn (i ToolItem) armor_points() int
struct TuffItem #
struct TuffItem {
BlockItem
}
TuffItem is the block-item for 'minecraft:tuff'.
struct UseOnBlockResult #
struct UseOnBlockResult {
pub:
sound string
state_key string
state_delta int
}
UseOnBlockResult describes what a UsableOnBlockItem does when used on a qualifying block: which int block-state to advance and by how much, plus an optional sound.
struct UseOnEntityResult #
struct UseOnEntityResult {
pub:
sound string
}
UseOnEntityResult describes what a UsableOnEntityItem does when used on an entity.
struct UseResult #
struct UseResult {
pub:
sound string
}
UseResult describes what happens when a UseableItem is used. sound is broadcast at the user's position if non empty; empty means no sound.
struct WearableComponent #
struct WearableComponent {
pub:
slot string
protection int
}
WearableComponent makes a custom item equippable as armor. Slot is a vanilla slot string like 'slot.armor.head', 'slot.armor.chest', 'slot.armor.legs', 'slot.armor.feet'.
struct WheatItem #
struct WheatItem {
SimpleItem
}
WheatItem is the class for raw 'minecraft:wheat'.
fn (WheatItem) use_on_block_result #
fn (i WheatItem) use_on_block_result(block_name string, meta int) ?UseOnBlockResult
- Constants
- fn book_pages_from_nbt
- fn combat_progression_items
- fn container_items
- fn damage_item
- fn decorative_items
- fn farming_items
- fn new_andesite_item
- fn new_apple
- fn new_armor_item
- fn new_baked_potato
- fn new_bedrock_item
- fn new_beef
- fn new_beetroot
- fn new_beetroot_soup
- fn new_blue_ice_item
- fn new_bone_meal_item
- fn new_bread
- fn new_cake
- fn new_calcite_item
- fn new_carrot
- fn new_chicken
- fn new_clay_item
- fn new_coal
- fn new_coal_block_item
- fn new_coal_ore_item
- fn new_cobbled_deepslate_item
- fn new_cobblestone_item
- fn new_cod
- fn new_compass_item
- fn new_cooked_beef
- fn new_cooked_chicken
- fn new_cooked_cod
- fn new_cooked_mutton
- fn new_cooked_porkchop
- fn new_cooked_salmon
- fn new_cookie
- fn new_copper_block_item
- fn new_copper_ingot
- fn new_copper_ore_item
- fn new_custom_registry
- fn new_diamond
- fn new_diamond_block_item
- fn new_diamond_ore_item
- fn new_diorite_item
- fn new_dirt_item
- fn new_dried_kelp
- fn new_dripstone_block_item
- fn new_emerald
- fn new_emerald_block_item
- fn new_emerald_ore_item
- fn new_end_bricks_item
- fn new_end_stone_item
- fn new_glow_berries
- fn new_glowstone_item
- fn new_goat_horn_item
- fn new_gold_block_item
- fn new_gold_ingot
- fn new_gold_ore_item
- fn new_golden_apple
- fn new_golden_carrot
- fn new_granite_item
- fn new_grass_block_item
- fn new_gravel_item
- fn new_honey_bottle
- fn new_ice_item
- fn new_iron_block_item
- fn new_iron_ingot
- fn new_iron_ore_item
- fn new_lapis_block_item
- fn new_lapis_lazuli
- fn new_lapis_ore_item
- fn new_lodestone_compass_item
- fn new_magma_block_item
- fn new_melon_slice
- fn new_mossy_cobblestone_item
- fn new_mushroom_stew
- fn new_mutton
- fn new_netherrack_item
- fn new_obsidian_item
- fn new_packed_ice_item
- fn new_poisonous_potato
- fn new_polished_andesite_item
- fn new_polished_diorite_item
- fn new_polished_granite_item
- fn new_porkchop
- fn new_potato
- fn new_pumpkin_pie
- fn new_purpur_block_item
- fn new_rabbit_stew
- fn new_raw_copper
- fn new_raw_gold
- fn new_raw_iron
- fn new_recovery_compass_item
- fn new_red_sand_item
- fn new_redstone
- fn new_redstone_block_item
- fn new_redstone_ore_item
- fn new_registry
- fn new_salmon
- fn new_sand_item
- fn new_sandstone_item
- fn new_smooth_basalt_item
- fn new_snow_item
- fn new_soul_sand_item
- fn new_soul_soil_item
- fn new_stick
- fn new_stone_item
- fn new_sweet_berries
- fn new_tool_item
- fn new_tuff_item
- fn new_wheat
- fn potion_from_meta
- fn redstone_component_items
- fn wood_items
- fn writable_book_nbt
- fn written_book_nbt
- fn ArmorSlot.from
- fn ArmorTier.from
- fn ToolTier.from
- fn ToolType.from
- interface ConsumableItem
- interface CooldownItem
- interface Item
- interface UsableOnBlockItem
- interface UsableOnEntityItem
- interface UseableItem
- enum ArmorSlot
- enum ArmorTier
- enum ToolTier
- enum ToolType
- struct AndesiteItem
- struct AppleItem
- struct ArmorItem
- struct BakedPotatoItem
- struct BedrockItem
- struct BeefItem
- struct BeetrootItem
- struct BeetrootSoupItem
- struct BlockItem
- struct BlueIceItem
- struct BoneMealItem
- struct BreadItem
- struct CakeItem
- struct CalciteItem
- struct CarrotItem
- struct ChickenItem
- struct ClayItem
- struct CoalBlockItem
- struct CoalItem
- struct CoalOreItem
- struct CobbledDeepslateItem
- struct CobblestoneItem
- struct CodItem
- struct CompassItem
- struct ConsumeResult
- struct CookedBeefItem
- struct CookedChickenItem
- struct CookedCodItem
- struct CookedMuttonItem
- struct CookedPorkchopItem
- struct CookedSalmonItem
- struct CookieItem
- struct CooldownComponent
- struct CopperBlockItem
- struct CopperIngotItem
- struct CopperOreItem
- struct CustomItemClass
- struct CustomItemDefinition
- struct CustomRegistry
- struct DamageResult
- struct DiamondBlockItem
- struct DiamondItem
- struct DiamondOreItem
- struct DiggerSpeed
- struct DioriteItem
- struct DirtItem
- struct DriedKelpItem
- struct DripstoneBlockItem
- struct DurabilityComponent
- struct DurabilityItem
- struct EmeraldBlockItem
- struct EmeraldItem
- struct EmeraldOreItem
- struct EnchantableComponent
- struct EndBricksItem
- struct EndStoneItem
- struct FallbackEntry
- struct FoodComponent
- struct FoodItem
- struct GlowBerriesItem
- struct GlowstoneItem
- struct GoatHornItem
- struct GoldBlockItem
- struct GoldIngotItem
- struct GoldOreItem
- struct GoldenAppleItem
- struct GoldenCarrotItem
- struct GraniteItem
- struct GrassBlockItem
- struct GravelItem
- struct HoneyBottleItem
- struct IceItem
- struct IronBlockItem
- struct IronIngotItem
- struct IronOreItem
- struct LapisBlockItem
- struct LapisLazuliItem
- struct LapisOreItem
- struct LodestoneCompassItem
- struct MagmaBlockItem
- struct MelonSliceItem
- struct MossyCobblestoneItem
- struct MushroomStewItem
- struct MuttonItem
- struct NetherrackItem
- struct ObsidianItem
- struct PackedIceItem
- struct PoisonousPotatoItem
- struct PolishedAndesiteItem
- struct PolishedDioriteItem
- struct PolishedGraniteItem
- struct PorkchopItem
- struct PotatoItem
- struct PotionItem
- struct PotionType
- struct PumpkinPieItem
- struct PurpurBlockItem
- struct RabbitStewItem
- struct RawCopperItem
- struct RawGoldItem
- struct RawIronItem
- struct RecoveryCompassItem
- struct RedSandItem
- struct RedstoneBlockItem
- struct RedstoneItem
- struct RedstoneOreItem
- struct Registry
- struct SalmonItem
- struct SandItem
- struct SandstoneItem
- struct SimpleItem
- struct SmoothBasaltItem
- struct SnowItem
- struct SoulSandItem
- struct SoulSoilItem
- struct StickItem
- struct StoneItem
- struct SweetBerriesItem
- struct ToolItem
- struct TuffItem
- struct UseOnBlockResult
- struct UseOnEntityResult
- struct UseResult
- struct WearableComponent
- struct WheatItem