How to cancel workbench composition event?
I’ll cancel “CraftItemEvent.Craft” After the event, it can still be synthesized in the workbench of other mods.
What should I do?
example:
The original workbench has been cancelled to synthesize items.
The worktable of craftsman soul has not been canceled.
Sadly sponge and mods arnt always 100% compatibile (especially when it comes to inventories due to the horrible mc code). You can sometime ask the developer of the mod to add support for Sponge if you describe the issue like you have hear.
Another option is for you to check for the mod itself and cancel the event (if you can - and its not done on the client).
Other then that, you will just need to tell your users that its got a issue with that mod
In the development of Forge, composite events cannot be canceled.
Is there no other way?
Some custom forge events are still cancelable as it depends on the implementation from the plugin author, the event wouldnt be a built in forge event, those have 100% compatibility with Sponge.
Like i said before, when it comes to inventory code, compatibility with mods is week. Here is more detail on why.
Minecraft inventory code is hot garbage (and thats putting it nicely). It seems to be a rushed mess that if you really think about it makes logical sense but by the time you have worked out the logic behind it, you could have made your own that works much better.
So this is what forge developers do, they make there own inventory code that suits the mod. This is great as it means they have full control over there own inventory and not limited to the Minecraft inventory API … But it means compatibility between two unknown mods (aka the mods don’t deliberately talk to one and another) just isn’t a thing.
Another option for fixing the issue is using Sponge Mixins to hook into the mod and attempt to cancel spawning of the item in the slot before it happens.
Have you got a link to this mod? Ill see if I can find out a way
Hello, my source code has not been released.
private static boolean ss;
I just want to simply cancel the formula of “diamond”. When < SS > is < true >, the synthesis event will be cancelled, and when < false >, the synthesis event will not be cancelled.
Here is an example of an error, because forge’s composite event cannot be cancelled.
Yes im well aware of what your trying to do, however what im saying is that the sponge crafted event does not fire for mod specific inventories. So there is no way of just cancelling the event and making it work for both Vanilla and Mod unless you do one of the following.
-
Get the mod developer to check for Sponge, if it is there then fire the sponge craft event and check for if it was cancelled
-
Hope that the mod in question has its own event that you can cancel, if it does then listen on that event too
-
Use Sponge Mixins to hyjack the stacktrace before the mod show the item to then cancel the stacktrace if you were originally going to cancel the event.