tutorial:items
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:items [2022/12/11 21:24] – Remove item group haykam | tutorial:items [2024/04/20 08:05] (current) – [Creating an Item class] ryhon | ||
---|---|---|---|
Line 7: | Line 7: | ||
==== Registering an Item ==== | ==== Registering an Item ==== | ||
- | First, create an instance of <yarn class_1792> | + | First, create an instance of '' |
< | < | ||
Line 13: | Line 13: | ||
// an instance of our new item | // an instance of our new item | ||
+ | // for versions below 1.20.4 | ||
public static final class_1792 CUSTOM_ITEM = new class_1792(new FabricItemSettings()); | public static final class_1792 CUSTOM_ITEM = new class_1792(new FabricItemSettings()); | ||
+ | // for versions since 1.20.5 | ||
+ | public static final class_1792 CUSTOM_ITEM = new class_1792(new class_1792.class_1793()); | ||
[...] | [...] | ||
} | } | ||
</ | </ | ||
- | You'll use the vanilla registry system for registering new content. The basic syntax is ''< | + | You'll use the vanilla registry system for registering new content. The basic syntax is ''< |
< | < | ||
Line 24: | Line 27: | ||
// an instance of our new item | // an instance of our new item | ||
- | public static final class_1792 CUSTOM_ITEM = new class_1792(new | + | public static final class_1792 CUSTOM_ITEM = new class_1792(new |
@Override | @Override | ||
Line 32: | Line 35: | ||
} | } | ||
</ | </ | ||
- | Your new item has now been added to Minecraft. Run the run config | + | Your new item has now been added to Minecraft. Run the run config |
{{: | {{: | ||
Line 43: | Line 46: | ||
public static final class_1792 CUSTOM_ITEM = | public static final class_1792 CUSTOM_ITEM = | ||
class_2378.method_10230(class_7923.field_41178, | class_2378.method_10230(class_7923.field_41178, | ||
- | new class_1792(new | + | new class_1792(new |
@Override | @Override | ||
Line 101: | Line 104: | ||
@Override | @Override | ||
- | public class_1271< | + | public class_1271< |
- | | + | |
- | return class_1271.method_22427(playerEntity.method_5998(hand)); | + | return class_1271.method_22427(user.method_5998(hand)); |
} | } | ||
} | } | ||
Line 113: | Line 116: | ||
// an instance of our new item | // an instance of our new item | ||
- | public static final CustomItem CUSTOM_ITEM = new CustomItem(new | + | public static final CustomItem CUSTOM_ITEM = new CustomItem(new |
[...] | [...] | ||
} | } | ||
Line 121: | Line 124: | ||
==== 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 '' | + | For this you would use '' |
< | < | ||
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 | + | public static final CustomItem CUSTOM_ITEM = new CustomItem(new |
[...] | [...] | ||
} | } |
tutorial/items.txt · Last modified: 2024/04/20 08:05 by ryhon