Textures for Items and Blocks - 1.8
Huge changes for textures in the 1.8 update. Now since everything is rendered with a JSON file, texture creation can get extremely tedious and boring.
Moving on, first thing you'll wanna do is add this List declaration to your main mod file:
public static List<Item> namesList = new ArrayList<Item>();
What this does is create a list of items for the game to texture. Next, you'll wanna do is add this method to your init() method:
if (event.getSide() == Side.CLIENT)
{
RenderItem render = Minecraft.getMinecraft().getRenderItem();
for (Item names : namesList)
render.getItemModelMesher().register(names, 0, new ModelResourceLocation("MODID:" + names.getUnlocalizedName().substring(names.getUnlocalizedName().indexOf(".") + 1), "inventory"));
}
This actually renders texture.
To register an item to be textured, add this line of code to your item's constructor:
ModFile.namesList.add(this);
That's all for getting them to render, however you'll need a JSON file to view any texture. You can borrow JSONs from the minecraft source, you can get a generator at this link, or you can copy the code below:
{
"parent": "builtin/generated",
"textures": {
"layer0": "modid:items/tutItem"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}
Each value does what it says, but make sure you fiddle with it a bit to see what each does for yourself. In the 3rd line, replace tutItem with the unlocalized name of whatever item you're making this for. You need to make one of these files for EACH item/block you're texturing. Super annoying. After you're done, place this file in assets\modid\models\item or assets\modid\models\block.
To convert these to blocks, change the type of the list you made and use this skeleton for your standard blocks.
{
"parent": "block/cube_all",
"textures": {
"all": "modid:blocks/tutblock"
}
}
Look in the minecraft source for how to make different models of blocks!
Moving on, first thing you'll wanna do is add this List declaration to your main mod file:
public static List<Item> namesList = new ArrayList<Item>();
What this does is create a list of items for the game to texture. Next, you'll wanna do is add this method to your init() method:
if (event.getSide() == Side.CLIENT)
{
RenderItem render = Minecraft.getMinecraft().getRenderItem();
for (Item names : namesList)
render.getItemModelMesher().register(names, 0, new ModelResourceLocation("MODID:" + names.getUnlocalizedName().substring(names.getUnlocalizedName().indexOf(".") + 1), "inventory"));
}
This actually renders texture.
To register an item to be textured, add this line of code to your item's constructor:
ModFile.namesList.add(this);
That's all for getting them to render, however you'll need a JSON file to view any texture. You can borrow JSONs from the minecraft source, you can get a generator at this link, or you can copy the code below:
{
"parent": "builtin/generated",
"textures": {
"layer0": "modid:items/tutItem"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}
Each value does what it says, but make sure you fiddle with it a bit to see what each does for yourself. In the 3rd line, replace tutItem with the unlocalized name of whatever item you're making this for. You need to make one of these files for EACH item/block you're texturing. Super annoying. After you're done, place this file in assets\modid\models\item or assets\modid\models\block.
To convert these to blocks, change the type of the list you made and use this skeleton for your standard blocks.
{
"parent": "block/cube_all",
"textures": {
"all": "modid:blocks/tutblock"
}
}
Look in the minecraft source for how to make different models of blocks!
Textures for Items and Blocks - 1.7.10
Textures have changed quite a since 1.4.7. Now, blocks and items get there textures declared separately. If you're upgrading from forge 1.4.7, go here to split your images easily.
To declare a texture for an item, add this to your YourIBase or item class:
@Override
public void registerIcons(IIconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon("modid" + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
}
and to add one for blocks:
@Override
public void registerIcons(IIconRegister iconRegister)
{
blockIcon = iconRegister.registerIcon("modid" + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
}
Don't change anything except for "modid." The way new textures are found is by giving Minecraft a folder name, in this case modid. However, this folder is inside a folder you need to create and name mods. Inside your modidfolder, make a folder called textures. And inside textures, make to folders called items and blocks.
Your texture path should look like this:
assets/modid/textures/items
which means your package in eclipse should look like
assets.modid.textures.items
and for blocks:
assets/modid/textures/blocks
Inside those folders you put single textures for your items and blocks, as in a 16x16, 32x32, 64x64 or 128x128 image. MinecraftForge can now handle anything up to 1024x without optifine or mcpatcher, so HD textures are nice and easy now. But on to explaining the code.
Like I mentioned before, "modid" is the folder inside mods that contains your textures. The second half of that after the colon is how the game will get the items name to work, so you must name your .png file the same as what it's called in the code. So for my example in the items section, for myFirstItem, I would name the png that corresponds to that item myFirstItem as well.
So the correct texture for myFirstItem would have the name myFirstItem.png and be placed in assets/modid/textures/items.
Hope this kinda explains it. If you need more help, feel free to drop on by the "Getting Help" section. Now on to recipes.
To declare a texture for an item, add this to your YourIBase or item class:
@Override
public void registerIcons(IIconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon("modid" + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
}
and to add one for blocks:
@Override
public void registerIcons(IIconRegister iconRegister)
{
blockIcon = iconRegister.registerIcon("modid" + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
}
Don't change anything except for "modid." The way new textures are found is by giving Minecraft a folder name, in this case modid. However, this folder is inside a folder you need to create and name mods. Inside your modidfolder, make a folder called textures. And inside textures, make to folders called items and blocks.
Your texture path should look like this:
assets/modid/textures/items
which means your package in eclipse should look like
assets.modid.textures.items
and for blocks:
assets/modid/textures/blocks
Inside those folders you put single textures for your items and blocks, as in a 16x16, 32x32, 64x64 or 128x128 image. MinecraftForge can now handle anything up to 1024x without optifine or mcpatcher, so HD textures are nice and easy now. But on to explaining the code.
Like I mentioned before, "modid" is the folder inside mods that contains your textures. The second half of that after the colon is how the game will get the items name to work, so you must name your .png file the same as what it's called in the code. So for my example in the items section, for myFirstItem, I would name the png that corresponds to that item myFirstItem as well.
So the correct texture for myFirstItem would have the name myFirstItem.png and be placed in assets/modid/textures/items.
Hope this kinda explains it. If you need more help, feel free to drop on by the "Getting Help" section. Now on to recipes.