Reputation: 11
I am coding my first Minecraft mod and I can' get my item to load the texture. I am very new to coding Minecraft mods and I am a bit confused. Here is the code for the base item:
package com.danielroberts.firstmod.item;
import com.danielroberts.firstmod.reference.Reference;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class item1 extends Item
{
public item1()
{
super();
}
@Override
public String getUnlocalizedName()
{
return String.format("item.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocilizedName(super.getUnlocalizedName()));
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
return String.format("item.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocilizedName(super.getUnlocalizedName()));
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
}
protected String getUnwrappedUnlocilizedName(String unlocilizedName)
{
return unlocilizedName.substring(unlocilizedName.indexOf(".") + 1);
}
}
And this is the code of the actual item:
package com.danielroberts.firstmod.item;
public class ItemDiamondtwo extends item1
{
public ItemDiamondtwo()
{
super();
this.setUnlocalizedName("doubleDiamond");
this.setMaxStackSize(64);
}
}
Upvotes: 1
Views: 1436
Reputation: 1
With this setup I would say you need to place the texture at assets/$Modid/textures/items/doubleDiamond.png Note Uppercase and Lowercase matter!!! so if the name of the file is doublediamond.png It would not work
I know this because I have this setup to :p
Upvotes: 0
Reputation: 326
One thing I can say is that to register a texture for an item you'll want to call the setTextureName(modId+":"+itemName) function.
i.e. setTexture("firstmod:doublediamond");
which will make it look for: "assets/firstmod/textures/items/doublediamond.png" upon init.
Upvotes: 1