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

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

  • Author

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

  • Author

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

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.

  • Author

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

You should add the itemstack on the server side, ie: !world.isRemote. You might have to call player.inventoryContainer.detectAndSendChanges(); after you add the new itemstack for it to update to the client.

  • Author

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

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.

  • Author

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

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.