6

I'm trying to teach myself java syntax and using minecraft as a platform for diving in. I'm having a problem though because none of my textures are being loaded. For that matter neither are my localizations. Here is the code for my block

package net.richbaird.testtutorial.blocks;

import cpw.mods.fml.common.registry.GameRegistry;
//import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.richbaird.testtutorial.lib.constants;

public class OrangeBlock extends Block {
    private String blockName = "orangeBlock";
    public OrangeBlock() {
        super(Material.rock);
        this.setBlockName(constants.MODID + "_" + blockName);
        this.setCreativeTab(CreativeTabs.tabBlock);
        GameRegistry.registerBlock(this,blockName);
        this.setBlockTextureName(constants.MODID + ":" + blockName);
        //LanguageRegistry.addName(this,"tutorial block");

    }

}

here is my constants class

package net.richbaird.testtutorial.lib;
public class constants {
  public static final String MODID = "testtutorial";
  public static final String MODNAME = "Test Tutorial";
  public static final String VERSION = "1.0";
}

I have my texture saved at

~/IdeaProjects/testmod/src/main/resources/assets/testtutorial/textures/blocks/orangeBlock.png

According to the log it is unable to find my texture. Here's the message I'm getting

[08:08:14] [Client thread/ERROR]: 
Using missing texture, unable to load 
testtutorial:textures/blocks/orangeBlock.png
java.io.FileNotFoundException: testtutorial:textures/blocks/orangeBlock.png

The client loads and my item shows up but with a default black and purple texture. What have I done wrong? I'm thinking it might have to do with my naming conventions, since the .lang file never gets read either, and the only way I can give my block a friendly name is with the now depreciated LanguageRegistry.addName() method

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
richbai90
  • 4,994
  • 4
  • 50
  • 85

2 Answers2

22

For those who are curious, it's a bug with intellij 14 looks like. Adding this line to the bottom of the build.gradle that comes with forge

sourceSets {
    main { output.resourcesDir = output.classesDir }
}

And running gradle setupDecompWorkspace idea --refresh-dependencies

fixed the problem.

richbai90
  • 4,994
  • 4
  • 50
  • 85
0

I recently ran into this bug after updating IntelliJ, and while richbai90's solution did fix the immediate issue, it also broke compiling the mod into a jar (the assets folder gets included twice). After some digging around, I eventually found the root of the issue: IntelliJ was delegating the build task to Gradle, which put the assets and classes in separate folders, and Forge didn't know they belong to the same mod. The solution that worked for me was to build and run using the IDE, which is in the Settings dialog under Build, Execution, Deployment | Build Tools | Gradle (the help page has more detailed instructions). On older versions of IntelliJ, this was called "Delegate IDE build/run actions to gradle" (see the help page).

yut23
  • 2,624
  • 10
  • 18