Jump to content

[Self Solved] Forge won't create "src/generated" sub-folders and won't load any textures.


Recommended Posts

Posted (edited)


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.

Edited by Gbasire
solved
  • Gbasire changed the title to [New to modding, 1.16] Forge won't create "src/generated" sub-folders and won't load any textures.
Posted

Here is the build.gradle :

I will downgrade to 8, thanks

buildscript {
    repositories {
        maven { url = 'https://files.minecraftforge.net/maven' }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
    }
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.0'
group = 'net.silentchaos512.tutorial' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'tutorial'

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
    mappings channel: 'official', version: '1.16.5'
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

    // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

    // Default run configurations.
    // These can be tweaked, removed, or duplicated as needed.
    runs {
        client {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            mods {
                tutorial {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            mods {
                tutorial {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            args '--mod', 'tutorial', '--all',
                    '--existing', file('src/main/resources').toString(),
                    '--existing', file('src/generated/resources').toString(),
                    '--output', file('src/generated/resources/')

            mods {
                tutorial {
                    source sourceSets.main
                }
            }
        }
    }
}

sourceSets.main.resources {
    srcDir 'src/generated/resources'
}

repositories {
    maven {
        // location of the maven that hosts JEI files
        name = "Progwml6 maven"
        url = "https://dvs1.progwml6.com/files/maven/"
    }
    maven {
        // location of a maven mirror for JEI files, as a fallback
        name = "ModMaven"
        url = "https://modmaven.k-4u.nl"
    }
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.16.5-36.1.0'

    // compile against the JEI API but do not include it at runtime
    compileOnly fg.deobf("mezz.jei:jei-1.16.3:7.+:api")
    // at runtime, use the full JEI jar
    runtimeOnly fg.deobf("mezz.jei:jei-1.16.3:7.+")
}

// Example for how to get properties into the manifest for reading by the runtime..
jar {
    manifest {
        attributes([
                "Specification-Title"     : "tutorial",
                "Specification-Vendor"    : "examplemodsareus",
                "Specification-Version"   : "1", // We are version 1 of ourselves
                "Implementation-Title"    : project.name,
                "Implementation-Version"  : "${version}",
                "Implementation-Vendor"   : "examplemodsareus",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }
}

// Example configuration to allow publishing using the maven-publish task
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
//publish.dependsOn('reobfJar')

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact jar
        }
    }
    repositories {
        maven {
            url "file:///${project.projectDir}/mcmodsrepo"
        }
    }
}

 

Posted

Ok I figured it out !

turns out I needed to run the project without the blocks texture being initiated in the ModItemModelProvider class, and putting only one sub-folder in the main folder with the silver_ore item texture to complete the runData task and allow intelliJ IDEA to create the "generate" sub-folders. Thanks :)

  • Gbasire changed the title to [Self Solved] Forge won't create "src/generated" sub-folders and won't load any textures.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • just rewatched the tutorial and my code is exactly the same as kaupenjoe's.  the item is added into the game but like i said to start it doesnt have a texture or a proper name for whatever reason.
    • yes the name is en_us.json and it is in resources -> assests -> testmod -> lang folders.  i have checked my code and am pretty confident that the code itself is correct.  i even tried loading the project in eclipse and it has the same problems, I think i will just rewatch the whole tutorial and will give an update on the situation.
    • same error, I also tried removing Valkyrian skies as well because I noticed it coming up a lot in the debug log errors
    • Hey man,    i have only been modding Minecraft for a few days but maybe I can help you. First of all make sure to follow every step of Kaupenjoe's tutorial, I found it to been very helpful and complete. The game uses the raw translation key for the item (in your case "item.testmod.alexandrite") if it can't find the correct lang file. Make sure it's name is "en_us.json" and it is saved under "ressources" -> "assets" -> "testmod".
    • whenever I try to get this item to render into the game it appears with the not texture purple and black squares and calls itself by the lang translation file path instead of the name i gave it.   { "item.testmod.alexandrite": "Alexandrite" } this is the lang json file package net.Hurst.testmod.item; import net.Hurst.testmod.TestMod; import net.minecraft.world.item.Item; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; public class ModItems { public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TestMod.MOD_ID); public static final RegistryObject<Item> ALEXANDRITE = ITEMS.register("alexandrite", () -> new Item(new Item.Properties())); public static void register(IEventBus eventBus){ ITEMS.register(eventBus); } } this is my ModItems.java file package net.Hurst.testmod; import com.mojang.logging.LogUtils; import net.Hurst.testmod.item.ModItems; import net.minecraft.world.item.CreativeModeTabs; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.slf4j.Logger; // The value here should match an entry in the META-INF/mods.toml file @Mod(TestMod.MOD_ID) public class TestMod { public static final String MOD_ID = "testmod"; private static final Logger LOGGER = LogUtils.getLogger(); public TestMod() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(this::commonSetup); ModItems.register(modEventBus); MinecraftForge.EVENT_BUS.register(this); modEventBus.addListener(this::addCreative); ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC); } private void commonSetup(final FMLCommonSetupEvent event) { } // Add the example block item to the building blocks tab private void addCreative(BuildCreativeModeTabContentsEvent event) { if(event.getTabKey() == CreativeModeTabs.INGREDIENTS){ event.accept(ModItems.ALEXANDRITE); } } // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(ServerStartingEvent event) { } // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent @Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public static class ClientModEvents { @SubscribeEvent public static void onClientSetup(FMLClientSetupEvent event) { } } } this is my TestMod.java file { "parent": "minecraft:item/generated", "textures": { "layer0": "testmod:item/generated" } } this is my model file for the item. I am using intellij 2025.1.2 with fdk 1.21 and java 21 I would appreciate the help.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.