5
\$\begingroup\$

I'm making my first foray into Minecraft modding on Ubuntu using Minecraft Forge. I'm finding it a little hard to get started as many of the tutorials seem to refer to older versions of Minecraft (e.g. that use the BaseMod base class, which now appears to be deprecated).

I've created a simple block type:

package net.minecraft.block;

import net.minecraft.block.*;
import net.minecraft.block.material.*;

public class RolyBlock extends Block {
    public RolyBlock(int par1, Material par2Material) {
        super(par1, par2Material);
    }
}

and added the following static initialiser to the Block class:

public static final Block rolyBlock = new RolyBlock(174, Material.rock)
                                      .setHardness(1.5F)
                                      .setResistance(10)
                                      .setStepSound(soundStoneFootstep)
                                      .setUnlocalizedName("rolyBlock")
                                      .setCreativeTab(CreativeTabs.tabBlock)          
                                      .setTextureName("roly_block");

I created a 256x256 PNG file called roly_block and placed it in Forge's MCP folder, in the same location as the other textures. However, when I start Minecraft (v. 1.6.5) via Eclipse, it is unable to locate the texture:

2014-03-14 11:38:34 [SEVERE] [Minecraft-Client] Using missing texture,
unable to load: minecraft:textures/blocks/roly_block.png

I suspect this is because I put the texture in the directory

forge/mcp/temp/src/minecraft/assets/minecraft/textures

(where I found the other textures) where this temp folder is presumably a decompiled version of the Minecraft 1.6.5 .jar file. I can't actually remember how I ended up with this folder, though.

My question is: how do I add a new texture to my Eclipse mod development environment? Must I rebuild a .jar each time, and if so how? Or can I have Minecraft load textures from a directory?

(I'm a complete Minecraft newbie, so there are many things about the configuration/dev environment for Minecraft that are confusing me. For example if I run recompile.py from Forge's MCP folder, I get a swathe of errors relating to IconRegister not being found.)

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

The String you pass to setTextureName() has a special format which isn't very well documented. If you just pass it a filename such as roly_block, it internally gets changed like so.

No mod is specified, so it assumes it's a default Minecraft file, and as you're calling it from a Block class, it knows you're talking about a Block texture and all textures are .png so it becomes:

"minecraft:textures/blocks/roly_block.png"

Which is then evaluated to the following file:

assets\minecraft\textures\blocks\roly_block.png

What you should use is the lower case Forge Mod ID followed by a colon, let's assume that's rolymod, you'd pass it the string:

"rolymod:roly_block"

Then in the same way, this will be evaluated to the file:

assets\rolymod\textures\blocks\roly_block.png

This makes it much easier to keep your assets separated from the defaults as well as other mods. You shouldn't need to rebuild your mod jar to test it either.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks. I got it working in the end (finally figured out the location of the 'assets' folder), but forgot to come back and answer my own question. So, I'll accept yours. \$\endgroup\$
    – user43380
    Jun 20, 2014 at 21:24

You must log in to answer this question.