Jump to content

[1.7.10] Item onRightClick returning the same thing


KakesRevenge

Recommended Posts

Hey,

Im trying to make an item and when you right click it you will get another item (same one) and this:

 

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
        player.inventory.addItemStackToInventory(new ItemStack(this));
        return stack ;
    }

 

i know why but is there any way to solve it ?

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

I did that here :

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
        player.inventory.addItemStackToInventory(new ItemStack(this));
        return stack ;
    }

 

or i dont understand you

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

You don't understand java and/or ItemStack.

 

A method that returns object (ItemStack) can't suddenly return two stacks.

What exacly do you need to do?

 

Right now:

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { // When player right-clicks
        player.inventory.addItemStackToInventory(new ItemStack(this)); //add to player's first free or stackable slot a new ItemStack of this item
        return stack ; // return the stack you have right-clicked with
    }

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

WHAT is not possible? I don't think anyone in this thread actually understood what you want to happen.

 

I want just add the same item when the item is right clicked no matter what. Idealy the onItemRightClick would be void.

I just dont know how to deal with the return statement.

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

I just tried this:

 

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){
if (!world.isRemote){
	player.inventory.addItemStackToInventory(new ItemStack(SirenMod.FireExtinguisherItem, 1));
	player.inventoryContainer.detectAndSendChanges();
}
return stack;		
}

 

and it worked fine for me.

Link to comment
Share on other sites

Wow cool i just dont understand the detectAndSendChanges thing but thank you very much :)

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

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.