Jump to content

Recommended Posts

Posted

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 :)

Posted

Basically what i need to do - the current stack + another one.

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 :)

Posted

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 :)

Posted

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.

Posted

So its not possible then...

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 :)

Posted

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 :)

Posted

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.

Posted

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 :)

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.