tutorial:items
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:items [2024/10/27 14:34] – [Make your item become fuel, or compostable] missing semicolon solidblock | tutorial:items [2024/10/27 14:45] (current) – [Item components] solidblock | ||
---|---|---|---|
Line 204: | Line 204: | ||
===== Item components ===== | ===== Item components ===== | ||
- | Sometimes you may need to add some default components for the item, such as max stack size or fire durability. This can be done by calling '' | + | Sometimes you may need to add some default components for the item, such as max stack size or fire durability. This can be done by calling '' |
In this example, the item will be unbreakable by default, while hiding tooltips about it. | In this example, the item will be unbreakable by default, while hiding tooltips about it. | ||
< | < | ||
- | public static final CustomItem CUSTOM_ITEM = new CustomItem(new class_1792.class_1793().component(DataComponentTypes.UNBREAKABLE, | + | |
+ | | ||
+ | .component(DataComponentTypes.UNBREAKABLE, | ||
+ | // For versions since 1.21.2: | ||
+ | public static final Item CUSTOM_ITEM = register(" | ||
+ | | ||
</ | </ | ||
- | Specifically, | + | Specifically, |
< | < | ||
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 CustomItem CUSTOM_ITEM = new CustomItem(new class_1792.class_1793().maxCount(16)); | + | |
+ | // For versions below 1.21.2: | ||
+ | | ||
+ | // For versions since 1.21.2: | ||
+ | public static final Item CUSTOM_ITEM = register(" | ||
[...] | [...] | ||
} | } | ||
Line 237: | Line 246: | ||
</ | </ | ||
- | In practice, when you have many items to register, as registering quantities of items may be effort-consuming and messy, you can consider placing | + | However, in practice, when you have many items to register, as registering quantities of items may be effort-consuming and messy, you can consider placing |
In versions below 1.21.2, you need to use Fabric API's '' | In versions below 1.21.2, you need to use Fabric API's '' |
tutorial/items.1730039656.txt.gz · Last modified: 2024/10/27 14:34 by solidblock