mardiff Posted December 29, 2013 Posted December 29, 2013 Hello everyone, I have a block that should be rendered pretty much the same as furnace with different textures, except that the front side is never rendered in the inventory. Any help? @SideOnly(Side.CLIENT) /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public Icon getIcon(int par1, int par2) { return par1 == 2 ? (this.isActive ? this.furnaceIconActive : this.furnaceIconIdle) : this.furnaceIconSides; } @SideOnly(Side.CLIENT) /** * When this method is called, your block should register all the icons it needs with the given IconRegister. This * is the only chance you get to register icons. */ public void registerIcons(IconRegister par1IconRegister) { this.furnaceIconSides = par1IconRegister.registerIcon("redstonefurnace:redstone_furnace_side"); this.furnaceIconActive = par1IconRegister.registerIcon("redstonefurnace:redstone_furnace_active"); this.furnaceIconIdle = par1IconRegister.registerIcon("redstonefurnace:redstone_furnace_idle"); } Quote If you really want help, give that modder a thank you. Modders LOVE thank yous.
CJLetsGame Posted December 29, 2013 Posted December 29, 2013 side 0 and 1 are top and bottom so the sides are > 1 return par1 > 1... I also use this along with the getIcon @SideOnly(Side.CLIENT) public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4); if (par5 == 1 || par5 == 0) { //Return Top/Bottom } else { //Return Sides } } Quote
mardiff Posted December 29, 2013 Author Posted December 29, 2013 The names of the textures are misleading, the "furnaceIconSides" are really just all of the sides that aren't the front. The active and idle are the two options for side 2, which is the front. And I don't really see the point of using getBlockTexture and getIcon. Quote If you really want help, give that modder a thank you. Modders LOVE thank yous.
CJLetsGame Posted December 29, 2013 Posted December 29, 2013 Minecraft has no sense of direction. The side number is cardinal directions Up, Down, North...etc. The furnace, Im pretty sure, uses meta to determine the front. Quote
mardiff Posted December 29, 2013 Author Posted December 29, 2013 Still works the same: the front texture works when its in the world, but the entire block in the inventory is the regular side Icon. Quote If you really want help, give that modder a thank you. Modders LOVE thank yous.
CJLetsGame Posted December 29, 2013 Posted December 29, 2013 I dont even know how you managed to get it to work at all. You are trying to tell me no matter which direction you place it, the front icon shows as the actual front of the furnace AND any other furnace you place can display its own unique front face? Quote
mardiff Posted December 29, 2013 Author Posted December 29, 2013 I'll hand out the source since this is extremely frustrating. Just put the stuff in the zip in the src. http://www.mediafire.com/download/cdav6fo3h0c61cl/put+in+src.rar Quote If you really want help, give that modder a thank you. Modders LOVE thank yous.
CJLetsGame Posted December 29, 2013 Posted December 29, 2013 I got it working. Lets see if I can remember all the changes... BlockRedstoneFurnace: public Icon getIcon(int par1, int par2) { return par1 == 1 ? this.blockIcon : (par1 == 0 ? this.blockIcon : (par1 != par2 ? this.blockIcon : this.furnaceIconFront)); } To: public Icon getIcon(int par1, int par2) { if (par1 == 4 && par2 == 0) return furnaceIconFront; if (par1 == 1) return blockIcon; if (par2 == -1 || par1 == par2) return furnaceIconFront; return blockIcon; } Added: @SideOnly(Side.CLIENT) public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4); return par5 == 1 ? this.blockIcon : (par5 == 0 ? this.blockIcon : (par5 != meta ? this.blockIcon : this.furnaceIconFront)); } I believe those are all the relevant changes I made. I changed the way you registered your block but I dont think it had anything to do with this. Quote
Draco18s Posted December 29, 2013 Posted December 29, 2013 Minecraft is weird. In the inventory the furnace has a metadata of 0 (obviously: it's not placed) but that renders it 180 degrees away from where it needs to in order for the front to be the rendered face (you're actually seeing the back and right side). Even vanilla has to do a kind of a hack to get the furnace to render the right way around. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
mardiff Posted December 29, 2013 Author Posted December 29, 2013 Thanks guys, I really appreciate it. Quote If you really want help, give that modder a thank you. Modders LOVE thank yous.
DoorCloser Posted December 29, 2013 Posted December 29, 2013 Check your code on that. public YourBlock(int par1, String texture) { super(par1, Material.rock); setCreativeTab(CreativeTabs.tabBlock); } public Icon getIcon(int par1, int par2) { return par1 == 1 ? this.field_94474_b : (par1 == 0 ? this.field_94474_b : (par2 == 2 && par1 == 2 ? this.field_94475_c : (par2 == 3 && par1 == 5 ? this.field_94475_c : (par2 == 0 && par1 == 3 ? this.field_94475_c : (par2 == 1 && par1 == 4 ? this.field_94475_c : this.blockIcon))))); } Also in the end of the code put these; public void registerIcons(IconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("youriconname"); this.field_94393_a = par1IconRegister.registerIcon("youriconname"); this.field_94392_b = par1IconRegister.registerIcon("youriconname"); this.field_94474_b = par1IconRegister.registerIcon("your[top]iconname"); this.field_94475_c = par1IconRegister.registerIcon(this.blockType ? "your[front]iconname" : "your[front]iconname"); } Mess up with the sides, i dont remember which. Put this code if you want to always put your block from specified side; public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack) { int var7 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; par1World.setBlockMetadataWithNotify(par2, par3, par4, var7, 2); } AND DONT FORGET ABOUT VARIABLES IN THE BEGGINING OF CODE. IT SHOULD LOOK LIKE THIS; public class YourBlock extends Block { private boolean blockType; private Icon field_94393_a; private Icon field_94392_b; private Icon field_94474_b; private Icon field_94475_c; Quote
mardiff Posted December 29, 2013 Author Posted December 29, 2013 Umm thanks for all that stuff doorcloser, but I had all that already aside from the part that my icons are named and yours aren't... Quote If you really want help, give that modder a thank you. Modders LOVE thank yous.
ASHninja1997 Posted February 17, 2014 Posted February 17, 2014 Hello! So I am having this same problem as well....I tried the getIcon() method fix suggested by CJLetsGame. The custom furnace texture loaded correctly in the inventory. But, my problem is that when the block is placed it registers the side icons as the top and bottom icons. I double checked exactly what I was replacing and found out that the getIcon() method as used above was different then mine (different minecraft version I am assuming). Here is what my getIcon() method looks like. @SideOnly(Side.CLIENT) /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public Icon getIcon(int par1, int par2) { return par1 == 1 ? this.furnaceIconTop : (par1 == 0 ? this.furnaceIconTop : (par1 != par2 ? this.blockIcon : this.furnaceIconFront)); } Seeing that it is different.....what should I do or change in order for the top and bottom icons to register correctly. I assume that I just need to register them in the getIcon() method. But, then again this is my first time looking at this code so i am not 100% sure. Thanks before hand Quote Every day is a new day to learn. I acknowledge the hard work of original content. I will always improve in many ways. Java > c
ASHninja1997 Posted February 17, 2014 Posted February 17, 2014 Wait! I used this code and solved it if (par2 == 0 && par1 == 3) return furnaceIconFront; return par1 == 1 ? this.furnaceIconTop : (par1 == 0 ? this.furnaceIconTop : (par1 != par2 ? this.blockIcon : this.furnaceIconFront)); Quote Every day is a new day to learn. I acknowledge the hard work of original content. I will always improve in many ways. Java > c
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.