Interface ItemStack.Builder
- All Superinterfaces:
AbstractBuilder<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
Modifier and TypeMethodDescriptiondefault 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.attributeModifier
(AttributeType attributeType, AttributeModifier modifier, EquipmentType equipmentType) Adds anAttributeModifier
to this item stack.build()
Builds an instance of an ItemStack.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.fromBlockState
(BlockState blockState) Sets the data to recreate aBlockState
in a heldItemStack
state.fromContainer
(DataView container) Attempts to reconstruct the builder with all of the data fromDataSerializable.toContainer()
including all custom data.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
Sets theItemType
of the item stack.Sets theItemType
of the item stack.quantity
(int quantity) Sets the quantity of the item stack.
-
Method Details
-
itemType
Sets theItemType
of the item stack.- Parameters:
itemType
- The type of item- Returns:
- This builder, for chaining
-
itemType
Sets theItemType
of the item stack.- Parameters:
itemType
- The type of item- Returns:
- This builder, for chaining
-
currentItem
ItemType currentItem() -
quantity
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
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
Sets the data to recreate aBlockState
in a heldItemStack
state.- Parameters:
blockState
- The block state to use- Returns:
- This builder, for chaining
-
fromBlockState
Sets the data to recreate aBlockState
in a heldItemStack
state.- Parameters:
blockState
- The block state to use- Returns:
- This builder, for chaining
-
fromContainer
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
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
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
Builds an instance of an ItemStack.- Specified by:
build
in interfaceAbstractBuilder<ItemStack>
- Returns:
- A new instance of an ItemStack
- Throws:
IllegalStateException
- If the item stack is not completed
-