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



×
×
  • Create New...

Important Information

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