Interface ItemStack.Builder
-
- All Superinterfaces:
Buildable.Builder<ItemStack>
,Builder<ItemStack,ItemStack.Builder>
,CopyableBuilder<ItemStack,ItemStack.Builder>
,DataHolderBuilder<ItemStack,ItemStack.Builder>
,DataHolderBuilder.Mutable<ItemStack,ItemStack.Builder>
,ResettableBuilder<ItemStack,ItemStack.Builder>
- Enclosing interface:
- ItemStack
public static interface ItemStack.Builder extends DataHolderBuilder.Mutable<ItemStack,ItemStack.Builder>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolderBuilder
DataHolderBuilder.Immutable<H extends DataHolder.Immutable<H>,B extends DataHolderBuilder.Immutable<H,B>>, DataHolderBuilder.Mutable<H extends DataHolder.Mutable,B extends DataHolderBuilder.Mutable<H,B>>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ItemStack.Builder
apply(Predicate<ItemStack.Builder> predicate, Consumer<ItemStack.Builder> consumer)
default ItemStack.Builder
attributeModifier(Supplier<? extends AttributeType> attributeType, AttributeModifier modifier, DefaultedRegistryReference<? extends EquipmentType> equipmentType)
Adds anAttributeModifier
to this item stack.ItemStack.Builder
attributeModifier(AttributeType attributeType, AttributeModifier modifier, EquipmentType equipmentType)
Adds anAttributeModifier
to this item stack.ItemStack
build()
Builds an instance of an ItemStack.ItemType
currentItem()
ItemStack.Builder
fromBlockSnapshot(BlockSnapshot blockSnapshot)
Attempts to reconstruct aBlockSnapshot
including all data andBlockEntity
related data if necessary for creating anItemStack
representation.default ItemStack.Builder
fromBlockState(Supplier<? extends BlockState> blockState)
Sets the data to recreate aBlockState
in a heldItemStack
state.ItemStack.Builder
fromBlockState(BlockState blockState)
Sets the data to recreate aBlockState
in a heldItemStack
state.ItemStack.Builder
fromContainer(DataView container)
Attempts to reconstruct the builder with all of the data fromDataSerializable.toContainer()
including all custom data.ItemStack.Builder
fromItemStack(ItemStack itemStack)
Sets all the settings in this builder from the item stack blueprint.default ItemStack.Builder
fromSnapshot(ItemStackSnapshot snapshot)
Reconstructs this builder to use theItemStackSnapshot
for all the values and data it may contain.default ItemStack.Builder
itemType(Supplier<? extends ItemType> itemType)
Sets theItemType
of the item stack.ItemStack.Builder
itemType(ItemType itemType)
Sets theItemType
of the item stack.ItemStack.Builder
quantity(int quantity)
Sets the quantity of the item stack.
-
-
-
Method Detail
-
itemType
ItemStack.Builder itemType(ItemType itemType)
Sets theItemType
of the item stack.- Parameters:
itemType
- The type of item- Returns:
- This builder, for chaining
-
itemType
default ItemStack.Builder itemType(Supplier<? extends ItemType> itemType)
Sets theItemType
of the item stack.- Parameters:
itemType
- The type of item- Returns:
- This builder, for chaining
-
currentItem
ItemType currentItem()
-
quantity
ItemStack.Builder quantity(int quantity) throws IllegalArgumentException
Sets the quantity of the item stack.- Parameters:
quantity
- The quantity of the item stack- Returns:
- This builder, for chaining
- Throws:
IllegalArgumentException
- If the quantity is outside the allowed bounds
-
fromItemStack
ItemStack.Builder fromItemStack(ItemStack itemStack)
Sets all the settings in this builder from the item stack blueprint.- Parameters:
itemStack
- The item stack to copy- Returns:
- This builder, for chaining
-
attributeModifier
default ItemStack.Builder attributeModifier(Supplier<? extends AttributeType> attributeType, AttributeModifier modifier, DefaultedRegistryReference<? extends EquipmentType> equipmentType)
Adds anAttributeModifier
to this item stack.- Parameters:
attributeType
- The Attribute type.modifier
- The Attribute modifier.equipmentType
- The equipment type thisAttributeModifier
will apply to.- Returns:
- This builder, for chaining
-
attributeModifier
ItemStack.Builder attributeModifier(AttributeType attributeType, AttributeModifier modifier, EquipmentType equipmentType)
Adds anAttributeModifier
to this item stack.- Parameters:
attributeType
- The Attribute type.modifier
- The Attribute modifier.equipmentType
- The equipment type thisAttributeModifier
will apply to.- Returns:
- This builder, for chaining
-
fromBlockState
ItemStack.Builder fromBlockState(BlockState blockState)
Sets the data to recreate aBlockState
in a heldItemStack
state.- Parameters:
blockState
- The block state to use- Returns:
- This builder, for chaining
-
fromBlockState
default ItemStack.Builder fromBlockState(Supplier<? extends BlockState> blockState)
Sets the data to recreate aBlockState
in a heldItemStack
state.- Parameters:
blockState
- The block state to use- Returns:
- This builder, for chaining
-
fromContainer
ItemStack.Builder fromContainer(DataView container)
Attempts to reconstruct the builder with all of the data fromDataSerializable.toContainer()
including all custom data.- Parameters:
container
- The container to translate- Returns:
- This builder, for chaining
-
fromSnapshot
default ItemStack.Builder fromSnapshot(ItemStackSnapshot snapshot)
Reconstructs this builder to use theItemStackSnapshot
for all the values and data it may contain.- Parameters:
snapshot
- The snapshot- Returns:
- This builder, for chaining
-
fromBlockSnapshot
ItemStack.Builder fromBlockSnapshot(BlockSnapshot blockSnapshot)
Attempts to reconstruct aBlockSnapshot
including all data andBlockEntity
related data if necessary for creating anItemStack
representation.- Parameters:
blockSnapshot
- The snapshot to use- Returns:
- This builder, for chaining
-
apply
default ItemStack.Builder apply(Predicate<ItemStack.Builder> predicate, Consumer<ItemStack.Builder> consumer)
-
build
ItemStack build() throws IllegalStateException
Builds an instance of an ItemStack.- Specified by:
build
in interfaceBuildable.Builder<ItemStack>
- Returns:
- A new instance of an ItemStack
- Throws:
IllegalStateException
- If the item stack is not completed
-
-