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
tutorial:items [2020/08/30 08:45]
siglong Fix minor error
tutorial:items [2020/09/23 08:33] (current)
ytg1234 Change Item.Settings to FabricItemSettings because it exists
Line 6: Line 6:
 ==== Registering an Item ==== ==== Registering an Item ====
  
-First, create an instance of Item. We'll store it at the top of our initializer class. The constructor takes in an Item.Settings object, which is used to set item properties such as the inventory category, durability, and stack count. ​+First, create an instance of Item. We'll store it at the top of our initializer class. The constructor takes in an ''​Item.Settings''​ (or a ''​FabricItemSettings''​) ​object, which is used to set item properties such as the inventory category, durability, and stack count. ​
 <code java [enable_line_numbers="​true"​]>​ <code java [enable_line_numbers="​true"​]>​
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
  
     // an instance of our new item     // an instance of our new item
-    public static final Item FABRIC_ITEM = new Item(new ​Item.Settings().group(ItemGroup.MISC));​+    public static final Item FABRIC_ITEM = new Item(new ​FabricItemSettings().group(ItemGroup.MISC));​
     [...]     [...]
 } }
Line 20: Line 20:
  
     // an instance of our new item     // an instance of our new item
-    public static final Item FABRIC_ITEM = new Item(new ​Item.Settings().group(ItemGroup.MISC));​+    public static final Item FABRIC_ITEM = new Item(new ​FabricItemSettings().group(ItemGroup.MISC));​
       ​       ​
     @Override     @Override
Line 94: Line 94:
  
     // an instance of our new item     // an instance of our new item
-    public static final FabricItem FABRIC_ITEM = new FabricItem(new ​Item.Settings().group(ItemGroup.MISC));​+    public static final FabricItem FABRIC_ITEM = new FabricItem(new ​FabricItemSettings().group(ItemGroup.MISC));​
     [...]     [...]
 } }
Line 102: Line 102:
 ==== What if I want to change the stack size of my item? ==== ==== 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.+For this you would use ''​maxCount(int size)''​ inside ​''​FabricItemSettings'' ​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"​]>​ <code java [enable_line_numbers="​true"​]>​
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
  
     // an instance of our new item, where the maximum stack size is 16     // 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));​+    public static final FabricItem FABRIC_ITEM = new FabricItem(new ​FabricItemSettings().group(ItemGroup.MISC).maxCount(16));​
     [...]     [...]
 } }
tutorial/items.txt · Last modified: 2020/09/23 08:33 by ytg1234