Jump to content

Enginecrafter77

Members
  • Posts

    2
  • Joined

  • Last visited

Enginecrafter77's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Well, after these clues you gave me, I did a quick search and this thread popped up, in which the guy is trying to solve pretty much the same issue, albeit without thinking about bytecode manipulation at all. I think I will have to think up a better way of doing this after all. Anyways, thanks for your time. EDIT: For whoever is interested in researching this further, I discovered wumple-util has already done this (using IContainerListener). You can look at it here.
  2. At first, let me explain why I want to do this. I want to implement food spoilage mechanics in my mod. In theory, I could have used the Item#onUpdate method, but as far as I am aware, this method gets invoked only when the item is carried by some entity. After a while, I came up with an idea, where all ItemStacks having their item instance of ItemFood would be registered in some sort of registry which would be iterated on every world tick (using TickEvent.WorldTickEvent) and have those stacks updated (possibly calling onUpdate with entity parameter null, I don't know yet). So, to my problem. To achieve this, I need to modify the bytecode of the ItemStack class (at very least the constructor) to broadcast a custom defined event across forge event bus (this event would be used to register the stack to the tick handler, but this is irrelevant now). I have studied some ASM and java bytecode for last few days, but I can't see how I would register that class loader. I have also read something about coremods, but all these posts were written for 1.6 versions and the moderators were never too much satisfied with the coremod approach. So, to conclude; Is there any way Forge has those ASM injecting routines handled? If so, can you give me an exaple how to register such class visitor into the forge's framework? Or, if possible, is there a way better approach than that I am suggesting? Many thanks for all your time in advance.
×
×
  • Create New...

Important Information

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