Posted July 9, 201510 yr 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!!
July 9, 201510 yr onItemRightClick replaces whatever item was clicked with the stack that is returned - return the new stack that you want instead of the original one. http://i.imgur.com/NdrFdld.png[/img]
July 9, 201510 yr 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!!
July 9, 201510 yr Author I FIXED IT, it took ur advice cool alias, I kept trying yay! Im serious don't look at it!!
July 9, 201510 yr Edit: Congrats 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. http://i.imgur.com/NdrFdld.png[/img]
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.