This is the way I am attempting to check only the hotbar for the ammo, but it seems to checking for anything in the hotbar and then for the ammo in the rest of my inventory and firing from there.
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return event.result;
}
for (int i = 0; i < 9; i++)
{
if (par3EntityPlayer.inventory.getStackInSlot(i) != null)
{
if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Items.wheat_seeds) || par3EntityPlayer.inventory.hasItem(Items.pumpkin_seeds) || par3EntityPlayer.inventory.hasItem(Items.melon_seeds) || par3EntityPlayer.inventory.hasItem(DungeoneeringItems.ironNugget) || par3EntityPlayer.inventory.hasItem(DungeoneeringItems.pyriteDust))
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
}
}
}
return par1ItemStack;
}
I am guessing this bit is my main issue - if (par3EntityPlayer.inventory.getStackInSlot(i) != null) - as I'm not specifying a specific item to search for and stop on, but it wouldn't except a specific Item and I'm not sure how getStackInSlot works, if I am honest.
I only have a basic understanding of Java, so I probably look like a bit of a numpty, but making an MC mod is an attempt to get better at it.