minnymin3 Posted December 13, 2012 Posted December 13, 2012 I want to give a player certain abilities when a specific item is in the hotbar but cannot figure out how to detect when an item is in the hotbar... Any suggestions? Quote
jammas615 Posted December 14, 2012 Posted December 14, 2012 A quick look at EntityPlayer and InventoryPlayer showed a few things. You could iterate over the mainInventory of the player which is in InventoryPlayer. Further you could only iterate over the items in mainInventory that correspond to hotbar slots and then getItem() on it and perform your checks. Have a read: http://jd.minecraftforge.net/net/minecraft/entity/player/EntityPlayer.html http://jd.minecraftforge.net/net/minecraft/entity/player/InventoryPlayer.html http://jd.minecraftforge.net/net/minecraft/item/ItemStack.html Quote If I helped you, thank me. If I didn't, let me know.
super_aardvark Posted December 14, 2012 Posted December 14, 2012 FYI the hot bar comprises indices 0-8 of mainInventory. Quote
minnymin3 Posted December 15, 2012 Author Posted December 15, 2012 Ok... I feel bad asking but what method should i use to fire the if statement? Quote
jammas615 Posted December 15, 2012 Posted December 15, 2012 Well. Use the field mainInventory in InventoryPlayer and iterate over only indexes 0 to 8 as super_aardvark has said. Upon each iteration you could check to see if that item is equal to the one you want. Quote If I helped you, thank me. If I didn't, let me know.
vdvman1 Posted December 16, 2012 Posted December 16, 2012 You would probably need to use a tick handler to call the if statement every tick Quote
Recommended Posts
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.