Posted August 26, 201411 yr I'm trying to select a hotbar slot with a certain item in it by first grabbing the inventory and scanning through the list of items to find a match. If I find a match, I want to select this slot but this is where I'm stuck. I can't find any method in the Inventory or Player API that let's me do that. Is this possible or did I overlook something?
August 26, 201411 yr Author Neither this: player.inventory.currentItem = 0; Nor this: player.inventory.changeCurrentItem(0); Appears to be working...
August 26, 201411 yr I take it you want to destroy the current item as you're trying to set it to null? Isn't it more efficient to call the following instead of messing around with changeCurrentItem? YourcurrentEntityPlayerObject.destroyCurrentEquippedItem(); or YourcurrentEntityPlayerObject.inventory.getCurrentItem() it returns an itemstack. Otherwise you have to append '.getItem()' behind it. Furthermore you can swap items with YourcurrentEntityPlayerObject.inventory.setInventorySlotContents(current item, new itemstack of item you want to place there);
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.