This is a client side mod. I would like to fire an event when a player inventory update
First I create an event handler class
Second I initialize a private field cache = InventoryPlayer(Minecraft.getMinecraft().player) in the class
I create a method onPlayerTickEvent(PlayerTickEvent event)
Every times onPlayerTickEvent fire, I use areItemStacksEqualUsingNBTShareTag and getStackInSlot to find differences between cache and Minecraft.getMinecraft().player.inventory
If there one or more of the 41 slots are different, post an event
Finally use copyInventory to copy Minecraft.getMinecraft().player.inventory to cache, and ready for the next PlayerTickEvent
BTW, I don't know what PlayerTickEvent actually mean. I only know about TickEvent fire every game loop.
This works when I throw an item using Q, pickup an item, items drop on death. But not work when I use my mouse to pickup itemstack in my inventory and placing a block.
I probably misused a lot functions, I'm new to Modding. Any solution? And give me advises on how to use forgeAPI correctly.