Jump to content

Recommended Posts

Posted

Hi, i got a problem. Maybe first the code:

 

public class ItemBandage extends Item {

public ItemBandage(int par1) {
	super(par1); //par1 is ID
	setCreativeTab(CreativeTabs.tabMisc);
	}

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
	if (hamrInjurys.brokenFootBoolean==true){
		--par1ItemStack.stackSize;
		hamrInjurys.brokenFootBoolean = false;
	}

	return par1ItemStack;
	}

}

 

brokenFootBoolean gets true once a certain potion of mine is activated. That is working.

So when rightclicked, --par1ItemStack.stackSize makes sure it gets removed from my inventory (it cant be stacked) And then setting brokenFootBoolean is for something else.

 

So then, the spot where the bandage was is empty. But if i rightclick again once or twice, the item returns. You could see that as eating your food, right clicking with your hand in the air, and getting it back. How can i fix that?

 

Edit, main class (RS_HAMR) :

 

In class itself:

public static Item bandage;

 

In @init :

bandage = new ItemBandage(7000).setUnlocalizedName("bandage").setMaxStackSize(1);
                LanguageRegistry.addName(bandage, "Bandage");

 

 

EDIT 2: Seems you only get it back when you rightclick a block, not the air.

Posted

Use

par3EntityPlayer.inventoryContainer.detectAndSendChanges();

after you decrease your itemstack. May help.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Posted
  On 5/10/2013 at 12:20 PM, Naitenne said:

Use

par3EntityPlayer.inventoryContainer.detectAndSendChanges();

after you decrease your itemstack. May help.

 

You mean like this? :

 

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
	if (hamrInjurys.brokenFootBoolean==true){
		--par1ItemStack.stackSize;
		par3EntityPlayer.inventoryContainer.detectAndSendChanges();
		hamrInjurys.brokenFootBoolean = false;
	}

	return par1ItemStack;
	}

 

 

Sorry, but it didnt chance anything in-game. The problem still happens.

Posted

Hmmm... That code actually worked for me when in classic mode, but not in creative... Don't know then. Sorry.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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