import type { SymbolMcdocBlockItemStates } from 'sandstone/arguments/generated/dispatcher.ts' import type { Registry } from 'sandstone/arguments/generated/registry.ts' import type { LegacyOperation } from 'sandstone/arguments/generated/util/attribute.ts' import type { EquipmentSlotGroup } from 'sandstone/arguments/generated/util/slot.ts' import type { BlockEntityData } from 'sandstone/arguments/generated/world/block.ts' import type { DataComponentPatch } from 'sandstone/arguments/generated/world/component.ts' import type { Trim } from 'sandstone/arguments/generated/world/component/item.ts' import type { NBTObject } from 'sandstone/arguments/nbt.ts' import type { EnchantmentClass, NBTDouble, NBTInt, NBTIntArray, NBTShort, NonEmptyString } from 'sandstone' export type AttributeModifier = { AttributeName?: Registry['minecraft:attribute'], /** * Identifying name of the modifier, has no real effect. */ Name?: string, /** * Slot that the modifier is active in. * * Value: * * - Mainhand(`mainhand`) * - Offhand(`offhand`) * - Head(`head`) * - Chest(`chest`) * - Legs(`legs`) * - Feet(`feet`) * - Hand(`hand`) * - Armor(`armor`) * - Any(`any`) * - Body(`body`) * - Saddle(`saddle`) */ Slot?: EquipmentSlotGroup, /** * Value: * * - Additive(`0`): aka. `add_value`. Adds all of the modifiers' amounts to the current value of the attribute. * - Multiplicative(`1`): * aka. `add_multiplied_base`. Multiplies the current value of the attribute by (1 + x), * where x is the sum of the modifiers' amounts. * - Percentage(`2`): * aka. `add_multiplied_total`. For every modifier, multiplies the current value of the attribute by (1 + x), * where x is the amount of the particular modifier. * Functions the same as Operation 1 if there is only a single modifier with operation 1 or 2. * However, for multiple modifiers it will multiply the modifiers rather than adding them */ Operation?: LegacyOperation, /** * Change in the attribute. */ Amount?: (NBTDouble | number), /** * Value: * Array length range: 4 */ UUID?: NBTIntArray<{ leftExclusive: false, rightExclusive: false, min: 4, max: 4, }>, } export type BlockItem = (ItemBase & { BlockEntityTag?: BlockEntityData, /** * Blockstate that the placed block will have. */ BlockStateTag?: (S extends undefined ? SymbolMcdocBlockItemStates<'%none'> : (S extends keyof SymbolMcdocBlockItemStates ? SymbolMcdocBlockItemStates[S] : SymbolMcdocBlockItemStates<'%unknown'>)), }) export type Display = { /** * A JSON text component. */ Name?: NonEmptyString, /** * A list of JSON text components, each element being a lore line. */ Lore?: Array, } export type Enchantment = { /** * Which enchantment is being described. */ id?: (Registry['minecraft:enchantment'] | EnchantmentClass), /** * Which level the enchantment is. * * Value: * Range: 0..255 */ lvl?: NBTShort<{ min: 0, }>, } export type HideFlags = (1 | 2 | 3 | 4 | 5 | 6 | 7 | 8) export type ItemBase = (({ [Key in NonEmptyString]?: NBTObject }) & { /** * Damage that an item has. Only used for tools, armor, etc. */ Damage?: NBTInt, /** * Whether the item should be unbreakable. * Only used for tools, armor, etc. */ Unbreakable?: boolean, /** * List of the block states that can be destroyed by this item when holding it in adventure mode. */ CanDestroy?: Array, /** * List of blockstates that this block item can be placed on. */ CanPlaceOn?: Array, /** * Tag that describes the custom model an item will take. * Used by the `custom_model_data` model overrides predicate. * Has certain restrictions due to float conversion. */ CustomModelData?: NBTInt, /** * List of enchantments that are on the item. */ Enchantments?: Array, /** * Number of experience levels to add to the base level cost when repairing, combining, or renaming this item with an anvil. */ RepairCost?: NBTInt, /** * Applied to an entity that has equipped the item. */ AttributeModifiers?: Array, /** * Display settings. */ display?: Display, /** * Bitfield for which flags to hide on an item. */ HideFlags?: NBTInt, /** * Trim to apply to the item & armor when worn. */ Trim?: Trim, }) export type ItemStack = ItemStackOfComponent export type ItemStackOfComponent = (SingleItemOfComponent & { /** * Number of items in the stack. * Defaults to `1`. * * Value: * Range: 1..99 */ count?: NBTInt<{ min: 1, max: 99, }>, }) export type ItemStackTemplate = (ItemStack | Registry['minecraft:item']) export type SingleItem = SingleItemOfComponent export type SingleItemOfComponent = { /** * ID of the item. */ id: Registry['minecraft:item'], components?: T, }