Your code prints both "Hey" and "Hey 2" because after you print "Hey", count is increased and also the second statement is true. For what you want to do you can try with something like this:
private String[] array = {"Hey", "Hey 2"};
private int count = 0;
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
if (!worldIn.isRemote()) {
playerIn.sendMessage(new StringTextComponent(array[count]));
count++;
return new ActionResult<>(ActionResultType.SUCCESS, playerIn.getHeldItem(handIn));
}
return new ActionResult<>(ActionResultType.SUCCESS, playerIn.getHeldItem(handIn));
}
If you want to make it loop between the Strings you can use an if statement to reset count.
Well, i already told you but i try to explain better. The image you were trying to render on the screen has dimension 256x256, but with this line:
minecraft.ingameGUI.blit(posX, posY, 0, 0, 32, 32);
you cut only a 32x32 portion from the original image, starting from the upper left corner (x: 0, y: 0), and as a result you only render on the screen that little portion of the image.
Well, actually there is nothing wrong with your code, in the sense that it does exactly what you told it to do...and so it just draws a 32x32 portion of the icons texture at screen position 16-16. But it seems you actually need to render only text right? So you need to use the FontRenderer, and possibly it's drawString method