hammy275 / immersive-mc

A Minecraft mod to make Minecraft more immersive!
GNU Lesser General Public License v3.0
62 stars 7 forks source link

``Item#onCraftedBy`` not called upon crafting an item #430

Closed nonamecrackers2 closed 1 week ago

nonamecrackers2 commented 1 month ago

When crafting using ImmersiveMC, the method Item#onCraftedBy is not called. While only used by maps in the vanilla game, it breaks functionality implemented by other mods that override onCraftedBy. If you want to replicate the bug, install "Cracker's Wither Storm Mod" (any version), along with ImmersiveMC of course, and try to craft the Formidibomb using a crafting table using the immersive crafting system. The Formidibomb, when hovered over in the inventory menu, should have a timer applied to it, but it does not. This is because onCraftedBy is not called. Crafting the Formidibomb using the vanilla crafting table GUI does not have this problem.

I believe to fix this issue, all you would need to do is call ItemStack#onCraftedBy in the Swap class when an item is crafted by any crafting station. This would also fix items not being counted towards being crafted in the statistics menu.

hammy275 commented 1 month ago

Thank you for catching this! Fixing this would likely also fix #219, so much appreciated :)

EDIT: Not sure why I thought this would fix #219; it doesn't get the crafting inventory. Still really good to fix, though, so thank you again

nonamecrackers2 commented 1 month ago

You're welcome, glad I could help!

hammy275 commented 2 weeks ago

Looking at this a bit more closely, I may want to do a more ideal call using ResultSlot so we get both the onCraftedBy() call and (Neo)Forge's event hooks called.

Would probably be super hack-y though, needs further investigation.

EDIT: Going to skip the event for now. If it's needed by some mod, I'll add it likely by just firing the event directly.

hammy275 commented 1 week ago

Thank you again for catching this! I'm hoping to have the next version of ImmersiveMC (1.5.0 Beta 2) out in the next few weeks, so this fix should be in that version!