IMutableItemStack
Link to imutableitemstack
A mutable ItemStack. withTag
withAmount
damageItem
etc. Changes (such as count or tag changes) will modify and return the ItemStack itself instead of a new ItemStack with the changed properties.
Importing the package
Link to importing-the-package
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import.
import crafttweaker.item.IMutableItemStack;
Getting the Instance
Link to getting-the-instance
You can get a IMutableItemStack by using IItemStack's mutable()
method. like so:
ZenScript Copy<minecraft:dirt>.mutable()
Extending the IItemStack
Link to extending-the-iitemstack
IMutableItemStack extends IItemStack and is able to call all of its methods/getters/setters as well.
ZenMethods
Link to zenmethods
Quantity
Link to quantity
Besides withAmount
, you can easily call these methods below to change the count of item.
ZenMethod | Parameter Type | Description |
---|---|---|
ZenMethod grow(count) | Parameter Type int | Description Increases the stack's count by the count provided |
ZenMethod shrink(count) | Parameter Type int | Description Decreases the stack's count by the count provided |
Damaging
Link to damaging
The method attempts to damage the stack with an optional player. Returns if the stack is damaged successfully.
boolean attemptDamageItem(int amount, @Optional IPlayer player);
Copying
Link to copying
IItemStack copy();
The copy method will returns a new immutable ItemStack with the same properties. If you are certain that the stack shouldn't be changed anymore and want to avoid unexpected item changes, you will need to use the method.