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

so im making an item that consumes itself, but adds another item to the inventory. and vise versa for the added item. Problem is, if the Item is in the first hotbar slot it doesn't add the item to anywhere in the inventory.

 

Here is my method.

public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){

	if(player.isSneaking()){
		if (player.inventory.hasItem(ModItems.Riptide)){
			player.inventory.consumeInventoryItem(ModItems.Riptide);


	player.inventory.addItemStackToInventory(new ItemStack(ModItems.anklamolses));
		}
	}
	return stack;

}
}

 

Thank you all for your time.

Im serious don't look at it!!

  • Author

actually this is unrelated but my player.isSneaking is ineffective, any ideas?

 

Edit:

Ive tried doing this:

public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){

	if(player.inventory.hasItem(ModItems.Riptide)){
	player.inventory.consumeInventoryItem(ModItems.Riptide);
	}else{
		player.isSneaking();
	}


	}



	return new ItemStack(ModItems.anklamolses);
	}

}

and this

if(player.isSneaking()||player.inventory.consumeInventoryItem(ModItems.anklamolses)){

but it doesn't work, im sure im missing something big im just not sure what it is

Im serious don't look at it!!

Edit: Congrats xD I'll leave the rest of my comment anyway.

 

Well your first bit of code in your last post shouldn't even compile - you have an extra closing curly brace that ends the method before you return anything.

 

player.isSneaking() returns a boolean value - it doesn't actually do anything. The only use for it is to check if the player is sneaking or not, and for that it must be in an if statement.

 

In your last code snippet, what are you trying to do? The way it is written, the item is only consumed if the player is NOT sneaking, because if isSneaking returns true, the rest of the condition is ignored. You may want to review basic logic operators and their uses - especially the examples later on down that page may prove instructive.

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.