First, do not use IInventory. Use capabilities via IItemHandler.
Second, look into the methods you are using. The maximum index those methods can read is 255. So, whenever index 256 rolls around, the lowest eight bits are kept making index 256 act as index 0 when reloaded and repeats for every 256 values (this is also known as a narrowing primitive conversion as referenced by $5.1.3 of the JLS). This is not to mention the load method bitwise ANDs the resulting byte received making the limit even more guaranteed.