Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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

  • 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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.