Hello MC Forums community, I, being a resourceful man, have updated almost every part of my W.I.P. mod to 1.5.1. Almost. There is only one thing left to do, and it has stumped both me and our other members beyond compare. "What is this all mighty obstacle?" You may ask. " Why would a so called "resourceful" man need to post on the MC Forums asking for my help?" The answer is simple, my dear Watson, I lied about being resourceful and need help on getting both Metadata and Side Textures to play nicely along with each other.
Not only have I sifted through 10 pages of Mod Development and Mod Discussions, I searched through the Forge Development Forums, endless Google search pages, and of course the Minecraft source code itself. I found plenty of ways to update metadata, and even more ways to update different sided textures, but nothing on how to put two and two together.
O' wise and benevolent community, I pray that you bestow upon me your wisdom of coding, and as an offering, I bring forth some of my source!
Main Mod File (only a little bit of it, the parts that correspond with the question)
asphalt = (new blockAsphalt(500,Material.rock)).setHardness(1.5F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("asphalt").setCreativeTab(tabclass3blocks);
GameRegistry.registerBlock(asphalt, itemAsphaltDecals.class, "Asphalt");
LanguageRegistry.addName(new ItemStack(asphalt,1,0), "Asphalt");
LanguageRegistry.addName(new ItemStack(asphalt,1,1), "Asphalt Yellow Line");
LanguageRegistry.addName(new ItemStack(asphalt,1,2), "Asphalt Yellow Line Two");
LanguageRegistry.addName(new ItemStack(asphalt,1,3), "Asphalt White Line");
LanguageRegistry.addName(new ItemStack(asphalt,1,4), "Asphalt White Line Two");
LanguageRegistry.addName(new ItemStack(asphalt,1,5), "Asphalt White Line Right");
LanguageRegistry.addName(new ItemStack(asphalt,1,6), "Asphalt White Line Right Two");
LanguageRegistry.addName(new ItemStack(asphalt,1,7), "Asphalt White Line Left");
LanguageRegistry.addName(new ItemStack(asphalt,1,8), "Asphalt White Line Left Two");
Item Decals File (for loading the metadatas)
package herz.class3.item;
import herz.class3.Class3;
import java.util.List;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.*;
public class itemAsphaltDecals extends ItemBlock
{
public itemAsphaltDecals(int par1)
{
super(par1);
this.setMaxDamage(0); //Stops bad things from happening
this.setHasSubtypes(true); //Tells it that it has metadata versions
}
@SideOnly(Side.CLIENT)
public Icon getIconFromDamage(int par1) //Gets the texture
{
return Class3.asphalt.getBlockTextureFromSideAndMetadata(1, par1);
}
public int getMetadata(int par1) //Returns the metadata value
{
return par1;
}
public String getItemNameIS(ItemStack is) //Get's the item incode name from an itemstack
{
String[] types = {"asphalt","asphaltlineyellow","asphaltlineyellowtwo","asphaltlinewhite","asphaltlinewhitetwo","asphaltlinewhiteright","asphaltlinewhiterighttwo","asphaltlinewhiteleft","asphaltlinewhitelefttwo"};
return "asphalt" + types[is.getItemDamage()];
}
}
Main Block File (tried putting an icon array in, but it still didn't solve it)
package herz.class3.block;
import herz.class3.common.ClientProxy;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.*;
public class blockAsphalt extends Block
{
private Icon[][] iconBuffer;
public blockAsphalt(int ID, Material material)
{
super(ID, material); //The ID and material
}
public int damageDropped(int i) //Tells it what block it drops and also for creative mode pick block
{
return i;
}
@SideOnly(Side.CLIENT)
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) //Adds the metadata blocks to the creative inventory
{
for (int var4 = 0; var4 < 9; ++var4)
{
par3List.add(new ItemStack(par1, 1, var4));
}
}
@Override
public void func_94332_a(IconRegister par1IconRegister)
{
iconBuffer = new Icon[9][6];
iconBuffer[0][0] = par1IconRegister.func_94245_a("Class3:Asphalt"); // bottom
iconBuffer[0][1] = par1IconRegister.func_94245_a("Class3:Asphalt"); // top
iconBuffer[0][2] = par1IconRegister.func_94245_a("Class3:Asphalt"); // north
iconBuffer[0][3] = par1IconRegister.func_94245_a("Class3:Asphalt"); // east
iconBuffer[0][4] = par1IconRegister.func_94245_a("Class3:Asphalt"); // south
iconBuffer[0][5] = par1IconRegister.func_94245_a("Class3:Asphalt"); // west
iconBuffer[1][0] = par1IconRegister.func_94245_a("Class3:Asphalt"); // bottom
iconBuffer[1][1] = par1IconRegister.func_94245_a("Class3:YellowLine1"); // top
iconBuffer[1][2] = par1IconRegister.func_94245_a("Class3:Asphalt"); // north
iconBuffer[1][3] = par1IconRegister.func_94245_a("Class3:Asphalt"); // east
iconBuffer[1][4] = par1IconRegister.func_94245_a("Class3:Asphalt"); // south
iconBuffer[1][5] = par1IconRegister.func_94245_a("Class3:Asphalt"); // west
iconBuffer[2][0] = par1IconRegister.func_94245_a("Class3:Asphalt"); // bottom
iconBuffer[2][1] = par1IconRegister.func_94245_a("Class3:YellowLine2"); // top
iconBuffer[2][2] = par1IconRegister.func_94245_a("Class3:Asphalt"); // north
iconBuffer[2][3] = par1IconRegister.func_94245_a("Class3:Asphalt"); // east
iconBuffer[2][4] = par1IconRegister.func_94245_a("Class3:Asphalt"); // south
iconBuffer[2][5] = par1IconRegister.func_94245_a("Class3:Asphalt"); // west
iconBuffer[3][0] = par1IconRegister.func_94245_a("Class3:Asphalt"); // bottom
iconBuffer[3][1] = par1IconRegister.func_94245_a("Class3:WhiteCorner1"); // top
iconBuffer[3][2] = par1IconRegister.func_94245_a("Class3:Asphalt"); // north
iconBuffer[3][3] = par1IconRegister.func_94245_a("Class3:Asphalt"); // east
iconBuffer[3][4] = par1IconRegister.func_94245_a("Class3:Asphalt"); // south
iconBuffer[3][5] = par1IconRegister.func_94245_a("Class3:Asphalt"); // west
iconBuffer[4][0] = par1IconRegister.func_94245_a("Class3:Asphalt"); // bottom
iconBuffer[4][1] = par1IconRegister.func_94245_a("Class3:WhiteCorner2"); // top
iconBuffer[4][2] = par1IconRegister.func_94245_a("Class3:Asphalt"); // north
iconBuffer[4][3] = par1IconRegister.func_94245_a("Class3:Asphalt"); // east
iconBuffer[4][4] = par1IconRegister.func_94245_a("Class3:Asphalt"); // south
iconBuffer[4][5] = par1IconRegister.func_94245_a("Class3:Asphalt"); // west
iconBuffer[5][0] = par1IconRegister.func_94245_a("Class3:Asphalt"); // bottom
iconBuffer[5][1] = par1IconRegister.func_94245_a("Class3:WhiteCorner3"); // top
iconBuffer[5][2] = par1IconRegister.func_94245_a("Class3:Asphalt"); // north
iconBuffer[5][3] = par1IconRegister.func_94245_a("Class3:Asphalt"); // east
iconBuffer[5][4] = par1IconRegister.func_94245_a("Class3:Asphalt"); // south
iconBuffer[5][5] = par1IconRegister.func_94245_a("Class3:Asphalt"); // west
iconBuffer[6][0] = par1IconRegister.func_94245_a("Class3:Asphalt"); // bottom
iconBuffer[6][1] = par1IconRegister.func_94245_a("Class3:WhiteCorner4"); // top
iconBuffer[6][2] = par1IconRegister.func_94245_a("Class3:Asphalt"); // north
iconBuffer[6][3] = par1IconRegister.func_94245_a("Class3:Asphalt"); // east
iconBuffer[6][4] = par1IconRegister.func_94245_a("Class3:Asphalt"); // south
iconBuffer[6][5] = par1IconRegister.func_94245_a("Class3:Asphalt"); // west
iconBuffer[7][0] = par1IconRegister.func_94245_a("Class3:Asphalt"); // bottom
iconBuffer[7][1] = par1IconRegister.func_94245_a("Class3:WhiteLine1"); // top
iconBuffer[7][2] = par1IconRegister.func_94245_a("Class3:Asphalt"); // north
iconBuffer[7][3] = par1IconRegister.func_94245_a("Class3:Asphalt"); // east
iconBuffer[7][4] = par1IconRegister.func_94245_a("Class3:Asphalt"); // south
iconBuffer[7][5] = par1IconRegister.func_94245_a("Class3:Asphalt"); // west
iconBuffer[8][0] = par1IconRegister.func_94245_a("Class3:Asphalt"); // bottom
iconBuffer[8][1] = par1IconRegister.func_94245_a("Class3:WhiteLine2"); // top
iconBuffer[8][2] = par1IconRegister.func_94245_a("Class3:Asphalt"); // north
iconBuffer[8][3] = par1IconRegister.func_94245_a("Class3:Asphalt"); // east
iconBuffer[8][4] = par1IconRegister.func_94245_a("Class3:Asphalt"); // south
iconBuffer[8][5] = par1IconRegister.func_94245_a("Class3:Asphalt"); // west
}
}
If you happen to already know of a tutorial for this, just point me in the right direction. I thank you for your time.
I see you've done your research, but there should be something in the Furnace block source code relating to this (I believe Furnaces use metadata for direction).
Thanks for the advice, but it seems I forgot to check out the BlockLog file (Derp). Anyway, I'm still working on it and getting a little closer, I am still accepting any advice anyone is willing to throw out there, though.
I think I found the answer, works with some of our mods blocks, but not others. Looking further into it.
Just added this code into the main block class.
public Icon getBlockTextureFromSideAndMetadata(int side, int meta)
{
if (meta < 10) return iconBuffer[meta][side]; //this check is to prevent an exception if the meta is higher than 9
return iconBuffer[0][0];
}
Not only have I sifted through 10 pages of Mod Development and Mod Discussions, I searched through the Forge Development Forums, endless Google search pages, and of course the Minecraft source code itself. I found plenty of ways to update metadata, and even more ways to update different sided textures, but nothing on how to put two and two together.
O' wise and benevolent community, I pray that you bestow upon me your wisdom of coding, and as an offering, I bring forth some of my source!
Main Mod File (only a little bit of it, the parts that correspond with the question)
Item Decals File (for loading the metadatas)
Main Block File (tried putting an icon array in, but it still didn't solve it)
If you happen to already know of a tutorial for this, just point me in the right direction. I thank you for your time.
Just added this code into the main block class.