Hello, I wanted to learn mod creation, as I know a bit of java, and I found a series of videos that I found good and quite recent, so I started to watch them.
The tutorial (here episode 1) shows how to create simple mods and add blocks, items, etc.
I followed the tutorial step by step, making literally everything he did, so I don't do any mistakes, but a problem happened.
Basically, when I added the textures I wanted into my sub folders of the "src/main" folder, exactly like the guy did, the "src/generated" folder that IntelliJ IDEA should create was created, but the sub-folder with for example, the .json files for the different items and blocks I created weren't created by IntelliJ IDEA, so the game worked... but my blocks and items had no texture at all.
I started looking into the console by doing runData and looking at the errors, I found several things.
First, when simply launching runData task, I got this error : Process 'command 'C:\Users\gueno\.jdks\corretto-1.8.0_292\bin\java.exe'' finished with non-zero exit value 1
I got a bit more into it by launching the debug panel and found that one thing caused several errors and stopped the program from processing : java.lang.Throwable:printStackTrace:644]: Caused by: java.lang.IllegalStateException: Model at tutorial:block/silver_block does not exist
Basically, "silver_block" is the first block that I added in my code, so I believe it started looking at my code and found this first, causing an error with textures but not with the game, so I believe it just launched the game without textures and didn't generate any sub-folders in "src/generated"
The guy posted his code on GitHub, so I did 2 things :
1, I took some of his files, without the folder with all generated sub-folders in src/generated, and tested. It showed the same error message, but at least created a ".cache" sub folder. The game launched as well, just the textures were missing.
2, I took all his files (so, with his generated folder and its sub-folders with the .json files and else) and launched the game, and every single texture was in the game.
The only thing that is wrong is that my IntelliJ IDEA doesn't manage to generate sub folders due to it (I think) not finding my textures.
I saw some people in the comment section of the guy having the same problem, but YouTube comments aren't the best way to fix a problem and no solution was found.
Here is the code of the ModItemModelProvider class :
package net.silentchaos512.tutorial.data.client;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.client.model.generators.ItemModelBuilder;
import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.silentchaos512.tutorial.TutorialMod;
public class ModItemModelProvider extends ItemModelProvider {
public ModItemModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) {
super(generator, TutorialMod.MOD_ID, existingFileHelper);
}
@Override
protected void registerModels() {
withExistingParent("silver_block", modLoc("block/silver_block"));
withExistingParent("silver_ore", modLoc("block/silver_ore"));
ModelFile itemGenerated = getExistingFile(mcLoc("item/generated"));
builder(itemGenerated, "silver_ingot");
}
private ItemModelBuilder builder(ModelFile itemGenerated, String name) {
return getBuilder(name).parent(itemGenerated).texture("layer0", "item/" + name);
}
}
Here is the code of the ModBlocks class :
package net.silentchaos512.tutorial.setup;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.RegistryObject;
import java.util.function.Supplier;
public class ModBlocks {
public static final RegistryObject<Block> SILVER_ORE = register("silver_ore", () ->
new Block(AbstractBlock.Properties.of(Material.STONE)
.strength(3, 10)
.harvestLevel(2)
.harvestTool(ToolType.PICKAXE)
.requiresCorrectToolForDrops()
.sound(SoundType.STONE)));
public static final RegistryObject<Block> SILVER_BLOCK = register("silver_block", () ->
new Block(AbstractBlock.Properties.of(Material.METAL)
.strength(3, 10)
.sound(SoundType.METAL)));
static void register() {}
private static <T extends Block> RegistryObject<T> registerNoItem(String name, Supplier<T> block) {
return Registration.BLOCKS.register(name, block);
}
private static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block) {
RegistryObject<T> ret = registerNoItem(name, block);
Registration.ITEMS.register(name, () -> new BlockItem(ret.get(), new Item.Properties().tab(ItemGroup.TAB_BUILDING_BLOCKS)));
return ret;
}
}
And here is the code of the ModItems class :
package net.silentchaos512.tutorial.setup;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.fml.RegistryObject;
public class ModItems {
public static final RegistryObject<Item> SILVER_INGOT = Registration.ITEMS.register("silver_ingot", () ->
new Item(new Item.Properties().tab(ItemGroup.TAB_MATERIALS)));
static void register() {}
}
What can I do ?
Any help is appreciated !
(PS : I'm a bit new to IntelliJ IDEA, so if you need me to show some things in the software, please be explicit so that I can understand).
Edit : I'm using JDK version 15.