Posted October 17, 201411 yr Hi everyone. So, I am a bit stumped on a problem here. I can't seem to figure out how to display the side icons on my machine in a GUI. The icons work fine when in the world, but when as an ItemBlock in a GUI, the top and bottom icons are fine, as they are constant, but the front, back, left and right don't get displayed, instead, they default to the "blockIcon" IIcon, which I use as the back icon. How can I set the side each icon goes on when my machine is an ItemBlock? Thanks. I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.
October 17, 201411 yr Hi Show code? The easiest way is generally to reassign your 'direction' so that metadata ==0 gives you the desired orientation in the inventory. -TGG
October 18, 201411 yr Author There really isn't any code you couldn't have already guessed I have. but anyway... //Side id - Relative -ForgeDirection public IIcon sideBottom; //Side 0 - Bottom -DOWN public IIcon sideTop; //Side 1 - Top -UP public IIcon sideFrontOn, sideFrontOff; //Side 2 - Front -NORTH public IIcon blockIcon; //Side 3 - Back -SOUTH public IIcon sideLeft; //Side 4 - Left -WEST public IIcon sideRight; //Side 5 - Right -EAST @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { if (side == 0 || side == 1) { if (side == 0) return this.sideBottom; if (side == 1) return this.sideTop; } else if (tileMachine != null) { if (meta == 0 || meta == 1) { if (this.tileMachine.isActive) return side == 2 ? this.sideFrontOn : this.blockIcon; else return side == 2 ? this.sideFrontOff : this.blockIcon; } if (meta == 2 || meta == 3) { if (this.tileMachine.isActive) return side == 5 ? this.sideFrontOn : this.blockIcon; else return side == 5 ? this.sideFrontOff : this.blockIcon; } if (meta == 4 || meta == 5) { if (this.tileMachine.isActive) return side == 3 ? this.sideFrontOn : this.blockIcon; else return side == 3 ? this.sideFrontOff : this.blockIcon; } if (meta == 6 || meta == 7) { if (this.tileMachine.isActive) return side == 4 ? this.sideFrontOn : this.blockIcon; else return side == 4 ? this.sideFrontOff : this.blockIcon; } } return blockIcon; } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister icon) { this.sideBottom = icon.registerIcon(modid + ":" + this.getUnlocalizedName().substring(5) + "_Bottom"); this.sideTop = icon.registerIcon(modid + ":" + this.getUnlocalizedName().substring(5) + "_Top"); this.sideFrontOn = icon.registerIcon(modid + ":" + this.getUnlocalizedName().substring(5) + "_Front_on"); this.sideFrontOff = icon.registerIcon(modid + ":" + this.getUnlocalizedName().substring(5) + "_Front_off"); this.sideLeft = icon.registerIcon(modid + ":" + this.getUnlocalizedName().substring(5) + "_Left"); this.sideRight = icon.registerIcon(modid + ":" + this.getUnlocalizedName().substring(5) + "_Right"); this.blockIcon = icon.registerIcon(modid + ":" + this.getUnlocalizedName().substring(5) + "_Back"); } I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.
October 19, 201411 yr Hi I am extremely suspicious of this line } else if (tileMachine != null) { Where is tileMachine stored? I think you have a likely "all machines will face the same way" bug there. About your original question: > they default to the "blockIcon" IIcon, which I use as the back icon That's probably because your tileMachine is null and it drops through to your final statement. You need to handle the null case properly. Or better yet, fix the tileMachine bug, eg use meta instead. -TGG
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.