bad packets

bad packets

18M Downloads

Fabric API's sendable channel sync randomly not working

qouteall opened this issue ยท 3 comments

commented

The latest version of ImmPtl added the code of rejecting vanilla clients using Fabric API functionality

https://github.com/iPortalTeam/ImmersivePortalsMod/blob/1.20.2/imm_ptl_core/src/main/java/qouteall/imm_ptl/core/network/ImmPtlNetworkConfig.java#L209

(following the doc of https://fabricmc.net/2023/09/12/1202.html)

Someone reported that it will wrongly recognize the client as not having ImmPtl when entering singleplayer world, when using bad packets mod, thus disconnecting the client. As I tested, this issue occurs randomly.

iPortalTeam/ImmersivePortalsMod#1456

commented

Are there any specific mod versions that I can look at, or does it happen on latest version?

commented

Can only reproduce it once, and that's when I didn't place a breakpoint :/.

Looks like Bad Packets' sync task is called first somehow even though Fabric API's mixin has higher priority? Even then the synced channel ids should still be there by the time the event callback is called.

https://github.com/FabricMC/fabric/blob/1fbc78fabb035f7902f21f9f1f34c13ad4d02aff/fabric-networking-api-v1/src/main/java/net/fabricmc/fabric/mixin/networking/ServerConfigurationNetworkHandlerMixin.java#L46

https://github.com/FabricMC/fabric/blob/1fbc78fabb035f7902f21f9f1f34c13ad4d02aff/fabric-networking-api-v1/src/main/java/net/fabricmc/fabric/mixin/networking/ServerConfigurationNetworkHandlerMixin.java#L88-L92

@Inject(method = "startConfiguration", at = @At("HEAD"))
private void badpackets_initPacketHandler(CallbackInfo ci) {
configurationTasks.add(badpackets_packetHandler.createCallbackTask());
configurationTasks.addAll(ServerConfigPacketHandler.CUSTOM_TASKS.values());
}

commented

Are there any specific mod versions that I can look at, or does it happen on latest version?

The latest version of ImmPtl.

Fabric API testmod has similar things https://github.com/FabricMC/fabric/blob/1.20.2/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/configuration/NetworkingConfigurationTest.java#L42

The randomness may be caused by multithreading. I guess that bad packets packet handling happens concurrently with Fabric API's (not sure). Breakpoint may interfere with it by slowing down some code.