User Tools

Site Tools


tutorial:items

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:items [2019/07/21 15:02]
jamieswhiteshirt [Creating an Item class] itemGroup -> group
tutorial:items [2019/08/13 14:48] (current)
i509vcb Add section showing how to set maximum stack size on custom item
Line 103: Line 103:
 </​code>​ </​code>​
 If you did everything correctly, using the item should now play a sound. If you did everything correctly, using the item should now play a sound.
 +
 +==== What if I want to change the stack size of my item? ====
 +
 +For this you would use ''​maxCount(int size)''​ inside ItemSettings to specify the max stack size. Note that if your item is damageable you cannot specify a maximum stack size or the game will throw a RuntimeException.
 +<code java [enable_line_numbers="​true"​]>​
 +public class ExampleMod implements ModInitializer
 +{
 +    // an instance of our new item, where the maximum stack size is 16
 +    public static final FabricItem FABRIC_ITEM = new FabricItem(new Item.Settings().group(ItemGroup.MISC).maxCount(16));​
 +    [...]
 +}
 +</​code>​
 +==== Next Steps ====
 +[[tutorial:​itemgroup|Add your item to your own ItemGroup]].
tutorial/items.1563721323.txt.gz · Last modified: 2019/07/21 15:02 by jamieswhiteshirt