SpongePowered / SpongeForge

A Forge mod that implements SpongeAPI
http://www.spongepowered.org/
MIT License
1.14k stars 306 forks source link

Some mods bypass all inventory events #2289

Open mmis1000 opened 6 years ago

mmis1000 commented 6 years ago

I am currently running

The Inventory Tweaks use a server side mod that calling player.openContainer.slotClick to accelerate sorting.

But for unknown reason, it turns out that this method completely bypassed the ClickEvent and InverntoryChange event handlers of sponge plugins and edited the inventory, making cancelling the inventory modify not possible at all.

hold space and left click on a item with Inventory Tweaks and its server side mod enabled, you will move the item without trigger any sponge events

And this also makes use chest as a custom gui to provide functionalities harder, as other mods may accidentally tear down the whole gui.

Even edit caused by other mods may not be recoverable, At least we should make the changes detectable. Or it will be very annoying.

Faithcaio commented 6 years ago

As this is a custom packet its probably not entering the phase for capturing inventory changes. I remember having problems with some mods (one was Tinkers Construct I think) going into infinite loops in crafting inventories when canceling the result. @gabizou

mmis1000 commented 6 years ago

We have tried change the action to be scheduled at server thread. But it seems it still not works.
Is this event can be triggered only by normal player action? or it is just another bug?
If this also should not work, is there a way to manually trigger the event from the Inventory Tweaks's side and give sponge a chance to cancel it?

phit commented 5 years ago

confirmed holding down space and clicking still bypasses any events, tested with a simple

    @Listener
    public void onEvent(ClickInventoryEvent event) {
        logger.error(event.toString());
    }

InventoryTweaks-1.63.jar spongeforge-1.12.2-2768-7.1.5-RC3513.jar

Faithcaio commented 5 years ago

Looks like the latest 1.64-dev builds of InventoryTweaks make our events fire correctly.

Still there might be other mods using custom packets to change inventory state.

phit commented 5 years ago

yes, quark for example https://github.com/SpongePowered/SpongeForge/issues/2553