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

How do I have use mulitple textures for one item such as a compass or clock. I tried searching through the tutorials in the wiki but I couldn't find anything (I might be wrong, I don't spot things easily.). I've took a look in the TextureCompass.java but I had some issue trying to find what I wanted.

 

Scenario:

I'm currently making a sword which I want to switch textures when the player right clicks.

 

Any ideas?

For that you just need to check when the player right clicks, store that state in a boolean, so when he right clicks one time, the boolean is true, and the second time it is false, then just put check for the variable if it is true in the registerIcons() function, and set a new texture based on the state of the variable.

  • Author

I seem to be getting a null somewhere, as the game crashes. I clearly don't know where the problem is or if I'm even doing it right.

        public boolean isSwitched = false;
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
	if(isSwitched){
		isSwitched = false;
	}
	else{
		isSwitched = true;
	}
	par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
                return par1ItemStack;
}
public void registerIcon(IconRegister par1IconRegister){
	if(isSwitched){
	        this.itemIcon = par1IconRegister.registerIcon("shadowRapier2");
	} else {
		this.itemIcon = par1IconRegister.registerIcon("shadowRapier1");
	}
}

public void registerIcon(IconRegister par1IconRegister){
	if(isSwitched){
	        this.itemIcon = par1IconRegister.registerIcon("shadowRapier2");
	} else {
		this.itemIcon = par1IconRegister.registerIcon("shadowRapier1");
	}
}

 

You're doing this wrong.

 

You need to register BOTH icons at the same time as the registerIcon function is called ONCE.

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.

Override public Icon getIconFromDamage(int par1)

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.

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.