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.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.ItemStack.BuilderattributeModifier(AttributeType attributeType, AttributeModifier modifier, EquipmentType equipmentType)Adds anAttributeModifierto this item stack.ItemStackbuild()Builds an instance of an ItemStack.ItemTypecurrentItem()ItemStack.BuilderfromBlockSnapshot(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.ItemStack.BuilderfromBlockState(BlockState blockState)Sets the data to recreate aBlockStatein a heldItemStackstate.ItemStack.BuilderfromContainer(DataView container)Attempts to reconstruct the builder with all of the data fromDataSerializable.toContainer()including all custom data.ItemStack.BuilderfromItemStack(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.BuilderitemType(Supplier<? extends ItemType> itemType)Sets theItemTypeof the item stack.ItemStack.BuilderitemType(ItemType itemType)Sets theItemTypeof the item stack.ItemStack.Builderquantity(int quantity)Sets the quantity of the item stack.
-
-
-
Method Detail
-
itemType
ItemStack.Builder itemType(ItemType itemType)
Sets theItemTypeof the item stack.- Parameters:
itemType- The type of item- Returns:
- This builder, for chaining
-
itemType
default ItemStack.Builder itemType(Supplier<? extends ItemType> itemType)
Sets theItemTypeof 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 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
ItemStack.Builder fromBlockState(BlockState blockState)
Sets the data to recreate aBlockStatein a heldItemStackstate.- 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 aBlockStatein a heldItemStackstate.- 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 theItemStackSnapshotfor 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 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
ItemStack build() throws IllegalStateException
Builds an instance of an ItemStack.- Specified by:
buildin interfaceBuildable.Builder<ItemStack>- Returns:
- A new instance of an ItemStack
- Throws:
IllegalStateException- If the item stack is not completed
-
-