Fabricators-of-Create / Porting-Lib

A collection of utilities for porting mods from Forge to Fabric.
Other
125 stars 34 forks source link

fix EntityInteractCallback not reaching server if canceled on client #139

Closed PssbleTrngle closed 6 days ago

PssbleTrngle commented 1 month ago

This is a proposed fix for #135

This changes the cancelation of the injected method to happen after the ServerboundInteractPacket has been send to the server instead of before. This means that returning a non-null InteractionResult on client now still triggers the EntityInteractCallback on the server too instead of omitting it.

I have also added an example callback to the test mod to check if this actually solves the issue, I have left it in, but can also remove it again if you want to.

AlphaMode commented 1 month ago

I believe not sending the packet is intentional, but I would have to double check the forge patch

PssbleTrngle commented 1 month ago

I very much believe it is not intentional or should at least not be, because it leads to the following problem: 1) When adding a custom interaction using the callback, the developer can either return null on client side, causing the event to be propagated to the server (were it usually is meant to be because most of the logic is happening there). 2) Doing this will cause the client not to display the correct interaction animation (none at all) 3) it will also not only be the only way to get the EntityInteractCallback to run on server-side, but also still run the default interaction logic on client side, since that is now not cancelled in any way

IThundxr commented 6 days ago

Fixed by https://github.com/Fabricators-of-Create/Porting-Lib/commit/b3c731b00ee19d97a642fac1f3d0ea86d22bf774