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.Builderapply(Predicate<ItemStack.Builder> predicate, Consumer<ItemStack.Builder> consumer) default ItemStack.BuilderattributeModifier(Supplier<? extends AttributeType> attributeType, AttributeModifier modifier, DefaultedRegistryReference<? extends EquipmentType> equipmentType) Adds anAttributeModifierto this item stack.attributeModifier(AttributeType attributeType, AttributeModifier modifier, EquipmentType equipmentType) Adds anAttributeModifierto this item stack.build()Builds an instance of an ItemStack.fromBlockSnapshot(BlockSnapshot blockSnapshot) Attempts to reconstruct aBlockSnapshotincluding all data andBlockEntityrelated data if necessary for creating anItemStackrepresentation.default ItemStack.BuilderfromBlockState(Supplier<? extends BlockState> blockState) Sets the data to recreate aBlockStatein a heldItemStackstate.fromBlockState(BlockState blockState) Sets the data to recreate aBlockStatein a heldItemStackstate.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.BuilderfromSnapshot(ItemStackSnapshot snapshot) Reconstructs this builder to use theItemStackSnapshotfor all the values and data it may contain.default ItemStack.BuilderSets theItemTypeof the item stack.Sets theItemTypeof the item stack.quantity(int quantity) Sets the quantity of the item stack.
-
Method Details
-
itemType
Sets theItemTypeof the item stack.- Parameters:
itemType- The type of item- Returns:
- This builder, for chaining
-
itemType
Sets theItemTypeof 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 anAttributeModifierto this item stack.- Parameters:
attributeType- The Attribute type.modifier- The Attribute modifier.equipmentType- The equipment type thisAttributeModifierwill apply to.- Returns:
- This builder, for chaining
-
attributeModifier
ItemStack.Builder attributeModifier(AttributeType attributeType, AttributeModifier modifier, EquipmentType equipmentType) Adds anAttributeModifierto this item stack.- Parameters:
attributeType- The Attribute type.modifier- The Attribute modifier.equipmentType- The equipment type thisAttributeModifierwill apply to.- Returns:
- This builder, for chaining
-
fromBlockState
Sets the data to recreate aBlockStatein a heldItemStackstate.- Parameters:
blockState- The block state to use- Returns:
- This builder, for chaining
-
fromBlockState
Sets the data to recreate aBlockStatein a heldItemStackstate.- 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 theItemStackSnapshotfor all the values and data it may contain.- Parameters:
snapshot- The snapshot- Returns:
- This builder, for chaining
-
fromBlockSnapshot
Attempts to reconstruct aBlockSnapshotincluding all data andBlockEntityrelated data if necessary for creating anItemStackrepresentation.- 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:
buildin interfaceAbstractBuilder<ItemStack>- Returns:
- A new instance of an ItemStack
- Throws:
IllegalStateException- If the item stack is not completed
-