Jump to content

anonymous2

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by anonymous2

  1. 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.
  2. Thus, I should check player inventory periodically and compute the difference?
  3. I'm writing a client side mod. I would like to run codes when a player pickup an item. I have tested the following net.minecraftforge.event.entity.player.EntityItemPickupEvent net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent both not work when I connect to a server, but work on singleplayer. I suppose these 2 functions are logical server stuff, how can I run codes when a player pickup an item? Moreover, what is the difference between above 2 class? Because I don't know how Minecraft internal works, I have 2 assumptions. I failed to find the correct event to handle the event in the library. Minecraft server doesn't have a mechanism to notice client when a player pickup an item. Instead the server sends packets to client: The EntityItem disappear, update player inventory (picked up an item).
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.