tutorial:crops
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:crops [2024/08/26 12:35] – solidblock | tutorial:crops [2025/04/01 12:05] (current) – fix typo solidblock | ||
---|---|---|---|
Line 55: | Line 55: | ||
===== Registering your Crop and Seed Item ===== | ===== Registering your Crop and Seed Item ===== | ||
- | Now we need to register our crop and the item to use for our seed. The seed model and class (including the static '' | + | Now we need to register our crop and the item to use for our seed. The seed model and class (including the static '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
+ | // For versions before 1.21.2: | ||
public static final CropBlock CUSTOM_CROP = register(" | public static final CropBlock CUSTOM_CROP = register(" | ||
+ | | ||
+ | // For version 1.21.2 and later: | ||
+ | public static final Block CUSTOM_CROP = register(" | ||
</ | </ | ||
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
+ | // For version before 1.21.2: | ||
public static final Item CUSTOM_SEEDS = register(" | public static final Item CUSTOM_SEEDS = register(" | ||
+ | | ||
+ | // For version 1.21.2 and later: | ||
+ | public static final Item CUSTOM_SEEDS = register(" | ||
+ | </ | ||
+ | |||
+ | > In the [[blocks]] tutorial, we wrote the '' | ||
+ | > <code java TutorialBlocks.java> | ||
+ | // ... | ||
+ | public static final Block CUSTOM_CROP = registerBlockOnly(" | ||
+ | | ||
+ | // ... | ||
+ | | ||
+ | private static Block registerBlockOnly(String path, Function< | ||
+ | final Identifier identifier = Identifier.of(" | ||
+ | final RegistryKey< | ||
+ | |||
+ | return Blocks.register(registryKey, | ||
+ | } | ||
</ | </ | ||
- | You also probably want the '' | + | You also probably want the '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 92: | Line 115: | ||
</ | </ | ||
- | Lastly you will want to create a blockstate | + | Lastly you will want to create a blockstates definition |
<code JavaScript src/ | <code JavaScript src/ | ||
Line 124: | Line 147: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | > The seeds item also need a corresponding item model and item models definition (for version 1.21.4 an later), which will not be explained in length here. | ||
+ | |||
+ | ===== Loot Table ===== | ||
+ | The block also needs a loot table, or it will drop nothing when mined. However, you can directly imitate vanillas. For example, copy vanilla' | ||
===== Crop Block Finished! ===== | ===== Crop Block Finished! ===== | ||
- | If you completed all parts of this tutorial correctly, you should now have a working crop! Your crop will be usable with bone meal and can only be placed on farmland with your seed item. You can also add some loot tables, or other interesting funcionalities for the crops! | + | If you completed all parts of this tutorial correctly, you should now have a working crop! Your crop will be usable with bone meal and can only be placed on farmland with your seed item. You can also add other interesting funcionalities for the crops! |
tutorial/crops.1724675707.txt.gz · Last modified: 2024/08/26 12:35 by solidblock