Althonos Posted September 30, 2014 Posted September 30, 2014 I've created a custom door block, everything is working perfectly. Aside from the fact that, at the back side of the door, instead of loading the bottom and top textures, it loads two top textures. Also, occasionally it will be reverse, double-top on front and bot-top on back. Here's my base code for the new door block class (I copied their methods, overridden of course, and changed the values to just a new texture. Only showing the relevant code.) Reveal hidden contents @Override public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_){ if (p_149673_5_ != 1 && p_149673_5_ != 0) { int i1 = this.func_150012_g(p_149673_1_, p_149673_2_, p_149673_3_, p_149673_4_); int j1 = i1 & 3; boolean flag = (i1 & 4) != 0; boolean flag1 = false; boolean flag2 = (i1 & != 0; if (flag) { if (j1 == 0 && p_149673_5_ == 2) { flag1 = !flag1; } else if (j1 == 1 && p_149673_5_ == 5) { flag1 = !flag1; } else if (j1 == 2 && p_149673_5_ == 3) { flag1 = !flag1; } else if (j1 == 3 && p_149673_5_ == 4) { flag1 = !flag1; } } else { if (j1 == 0 && p_149673_5_ == 5) { flag1 = !flag1; } else if (j1 == 1 && p_149673_5_ == 3) { flag1 = !flag1; } else if (j1 == 2 && p_149673_5_ == 4) { flag1 = !flag1; } else if (j1 == 3 && p_149673_5_ == 2) { flag1 = !flag1; } if ((i1 & 16) != 0) { flag1 = !flag1; } } return flag2 ? iconsA[flag1?1:0] : iconsB[flag1?1:0]; } else { return iconsB[0]; } } @Override public void registerBlockIcons(IIconRegister iconRegister) { iconsA = new IIcon[2]; iconsB = new IIcon[2]; iconsA[0] = iconRegister.registerIcon(Constants.MODID + ":" + blockName + "upper"); iconsB[0] = iconRegister.registerIcon(Constants.MODID + ":" + blockName + "lower"); iconsA[1] = new IconFlipped(iconsA[0], true, false); iconsB[1] = new IconFlipped(iconsA[0], true, false); } @Override public IIcon getIcon(int side, int meta) { return iconsB[0]; } Here is some more information; Some pictures of my problem. http://postimg.org/image/ze4wvu5f5/ http://postimg.org/image/r9edkt2wf/ Quote
TheGreyGhost Posted September 30, 2014 Posted September 30, 2014 Hi At a guess, your placement code for the door is not setting the top/bottom flag correctly. System.out.println() or a breakpoint should show this up. Have you seen this? http://minecraft.gamepedia.com/Data_values#Starting_at_Minecraft_1.2_.28from_weekly_snapshot_12w06a.29 BTW your code would be a lot easier to understand if you renamed the variables, eg p_149673_2_ -> x, flag2 -> isUpperPanel, etc -TGG Quote
Althonos Posted September 30, 2014 Author Posted September 30, 2014 I found the need to rename the pre-made variables useless, since the only thing I was doing was changing the icons. If I was editing more than just that, then I would invest the time to rename the variables. For now, I will look up what you had posted. Quote
Althonos Posted September 30, 2014 Author Posted September 30, 2014 I added a few println statements to determine what values are used. I don't understand the meaning behind the order of the values, however. As per your suggestion, I renamed some variables, here's the updated code and console output: Updated Code: Reveal hidden contents @Override public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int p_149673_5_){ if (p_149673_5_ != 1 && p_149673_5_ != 0) { int meta = this.func_150012_g(blockAccess, x, y, z); int j1 = meta & 3; boolean swungAround = (meta & 4) != 0; boolean isFlipped = false; boolean isUpper = (meta & != 0; if (swungAround) { if (j1 == 0 && p_149673_5_ == 2) { isFlipped = !isFlipped; } else if (j1 == 1 && p_149673_5_ == 5) { isFlipped = !isFlipped; } else if (j1 == 2 && p_149673_5_ == 3) { isFlipped = !isFlipped; } else if (j1 == 3 && p_149673_5_ == 4) { isFlipped = !isFlipped; } } else { if (j1 == 0 && p_149673_5_ == 5) { isFlipped = !isFlipped; } else if (j1 == 1 && p_149673_5_ == 3) { isFlipped = !isFlipped; } else if (j1 == 2 && p_149673_5_ == 4) { isFlipped = !isFlipped; } else if (j1 == 3 && p_149673_5_ == 2) { isFlipped = !isFlipped; } if ((meta & 16) != 0) { isFlipped = !isFlipped; } } if (isUpper){ System.out.println("Upper"); } else { System.out.println("Lower"); } return isUpper ? iconsA[isFlipped?1:0] : iconsB[isFlipped?1:0]; } else { System.out.println("Lower"); return iconsB[0]; } } Console Output when I place a door: Reveal hidden contents [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:98]: Lower [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:98]: Lower [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:91]: Lower [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:91]: Lower [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:91]: Lower [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:91]: Lower [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:98]: Lower [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:98]: Lower [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:89]: Upper [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:89]: Upper [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:89]: Upper [23:07:22] [Client thread/INFO] [sTDOUT]: [com.zacharysturtz.BlockCustomDoor:getIcon:89]: Upper Quote
TheGreyGhost Posted September 30, 2014 Posted September 30, 2014 Hi Is there only one door? Did it render correctly? Try adding a bit more info to the println, eg if (isUpper){ System.out.println("Upper at [" + x + ", " + y + ", " + z + "] side " + p_149673_5_); } else { System.out.println("Lower at [" + x + ", " + y + ", " + z + "] side " + p_149673_5_); } p_149673_5_ is side. Ah - wait a second iconsB[1] = new IconFlipped(iconsA[0], true, false); that doesn't look right. -TGG Quote
Althonos Posted September 30, 2014 Author Posted September 30, 2014 Ah! I can't believe I made such a stupid mistake. Sorry, thanks for catching it. It works perfectly now, also, there were two reasons to me not renaming the variables; One: I didn't know what they meant (Now I do, thanks to you.) Two: I didn't see the need to at the time, but now that I think about it, my code looks so much prettier. Anyway, problem solved! Quote
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.