tutorial:items
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:items [2022/07/23 18:06] – Corrected parentheses in maxCount example. darthjake | tutorial:items [2022/10/22 11:52] – solidblock | ||
---|---|---|---|
Line 4: | Line 4: | ||
Adding a basic item is one of the first steps in modding. You're going to need to create an ''< | Adding a basic item is one of the first steps in modding. You're going to need to create an ''< | ||
+ | |||
==== Registering an Item ==== | ==== Registering an Item ==== | ||
- | First, create an instance of <yarn class_1792> | + | First, create an instance of <yarn class_1792> |
< | < | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
Line 15: | Line 17: | ||
} | } | ||
</ | </ | ||
+ | |||
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 ''< | ||
+ | |||
< | < | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
Line 28: | Line 32: | ||
} | } | ||
</ | </ | ||
- | Your new item has now been added to Minecraft. Run the '' | + | Your new item has now been added to Minecraft. Run the run config ``Minecraft Client`` or '' |
{{: | {{: | ||
+ | |||
+ | For simplicity, you can simplify your code as following: | ||
+ | < | ||
+ | public class ExampleMod implements ModInitializer { | ||
+ | |||
+ | // an instance of our new item | ||
+ | public static final class_1792 CUSTOM_ITEM = | ||
+ | class_2378.method_10230(class_2378.field_11142, | ||
+ | new class_1792(new FabricItemSettings().method_7892(class_1761.field_7932))); | ||
+ | |||
+ | @Override | ||
+ | public void onInitialize() { | ||
+ | } | ||
+ | } | ||
+ | </ | ||
==== Adding Item textures ==== | ==== Adding Item textures ==== | ||
- | Registering a texture for an item requires an item model .json file and a texture image. You're going to need to add these to your resource directory. The direct path of each is: | + | Registering a texture for an item requires an item model json file and a texture image. You're going to need to add these to your resource directory. The direct path of each is: |
Item model: .../ | Item model: .../ |
tutorial/items.txt · Last modified: 2024/04/20 08:05 by ryhon