public static interface ItemStack.Builder extends DataBuilder<ItemStack>
Modifier and Type | Method and Description |
---|---|
<V> ItemStack.Builder |
add(Key<? extends BaseValue<V>> key,
V value)
|
default ItemStack.Builder |
apply(Predicate<ItemStack.Builder> predicate,
Consumer<ItemStack.Builder> consumer) |
ItemStack |
build()
Builds an instance of an ItemStack.
|
ItemStack.Builder |
from(ItemStack value)
Resets this builder to the values of the given built object.
|
ItemStack.Builder |
fromBlockSnapshot(BlockSnapshot blockSnapshot)
Attempts to reconstruct a
BlockSnapshot including all data
and TileEntity related data if necessary for creating an
ItemStack representation. |
default ItemStack.Builder |
fromBlockState(BlockState blockState)
Sets the data to recreate a
BlockState in a held ItemStack
state. |
ItemStack.Builder |
fromContainer(DataView container)
Attempts to reconstruct the builder with all of the data from
DataSerializable.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 the
ItemStackSnapshot
for all the values and data it may contain. |
ItemType |
getCurrentItem() |
ItemStack.Builder |
itemData(DataManipulator<?,?> itemData)
Sets the
DataManipulator to add to the ItemStack . |
ItemStack.Builder |
itemData(ImmutableDataManipulator<?,?> itemData)
Sets the
ImmutableDataManipulator to add to the
ItemStack . |
ItemStack.Builder |
itemType(ItemType itemType)
Sets the
ItemType of the item stack. |
default <E> ItemStack.Builder |
keyValue(Key<? extends BaseValue<E>> key,
E value)
Deprecated.
As of API 7 due to being a duplicate method.
Accomplishes the same thing as
add(Key, Object) , so is
not needed alongside that, expected for removal in API 8 or 9.
Use add(Key, Object) instead |
ItemStack.Builder |
quantity(int quantity)
Sets the quantity of the item stack.
|
ItemStack.Builder |
remove(Class<? extends DataManipulator<?,?>> manipulatorClass) |
build, reset
ItemStack.Builder from(ItemStack value)
ResettableBuilder
from
in interface DataBuilder<ItemStack>
from
in interface ResettableBuilder<ItemStack,DataBuilder<ItemStack>>
value
- The built objectItemStack.Builder itemType(ItemType itemType)
ItemType
of the item stack.itemType
- The type of itemItemType getCurrentItem()
ItemStack.Builder quantity(int quantity) throws IllegalArgumentException
quantity
- The quantity of the item stackIllegalArgumentException
- If the quantity is outside the
allowed bounds@Deprecated default <E> ItemStack.Builder keyValue(Key<? extends BaseValue<E>> key, E value)
add(Key, Object)
, so is
not needed alongside that, expected for removal in API 8 or 9.
Use add(Key, Object)
insteadKey
and related Object
value to apply to the
resulting ItemStack
. Note that the resulting
ItemStack
may not actually accept the provided Key
for various reasons due to support or simply that the value itself
is not supported. Offering custom data is not supported through this,
use itemData(DataManipulator)
instead.E
- The type of valuekey
- The key to identify the value withvalue
- The value to applyItemStack.Builder itemData(DataManipulator<?,?> itemData) throws IllegalArgumentException
DataManipulator
to add to the ItemStack
.itemData
- The item data to setIllegalArgumentException
- If the item data is incompatible
with the itemItemStack.Builder itemData(ImmutableDataManipulator<?,?> itemData) throws IllegalArgumentException
ImmutableDataManipulator
to add to the
ItemStack
.itemData
- The item data to setIllegalArgumentException
- If the item data is incompatible<V> ItemStack.Builder add(Key<? extends BaseValue<V>> key, V value) throws IllegalArgumentException
Key
and related Object
value to apply to the
resulting ItemStack
. Note that the resulting
ItemStack
may not actually accept the provided Key
for various reasons due to support or simply that the value itself
is not supported. Offering custom data is not supported through this,
use itemData(DataManipulator)
instead.V
- The type of the valuekey
- The key to assign the value withvalue
- The value to assign with the keyIllegalArgumentException
- If the item data is incompatibleItemStack.Builder fromItemStack(ItemStack itemStack)
itemStack
- The item stack to copydefault ItemStack.Builder fromBlockState(BlockState blockState)
BlockState
in a held ItemStack
state.blockState
- The block state to useItemStack.Builder fromContainer(DataView container)
DataSerializable.toContainer()
including all custom data.container
- The container to translatedefault ItemStack.Builder fromSnapshot(ItemStackSnapshot snapshot)
ItemStackSnapshot
for all the values and data it may contain.snapshot
- The snapshotItemStack.Builder fromBlockSnapshot(BlockSnapshot blockSnapshot)
BlockSnapshot
including all data
and TileEntity
related data if necessary for creating an
ItemStack
representation.blockSnapshot
- The snapshot to useItemStack.Builder remove(Class<? extends DataManipulator<?,?>> manipulatorClass)
default ItemStack.Builder apply(Predicate<ItemStack.Builder> predicate, Consumer<ItemStack.Builder> consumer)
ItemStack build() throws IllegalStateException
IllegalStateException
- If the item stack is not completed