Fabric API

Fabric API

152M Downloads

[1.21.9] Possible race condition in package handling causes no items to show up in inventory GUI when using an `ExtendedScreenHandlerType`

Closed this issue · 3 comments

commented

While porting my mod to 1.21.9, I found out that playerScreenHandler¹ is not yet correctly set during handling of the initial InventoryS2CPacket² in onInventory(InventoryS2CPacket) ³ if an ExtendedScreenHandlerType⁴ type is used. I think that OpenScreenPayload ⁵ (Handled in ClientNetworking⁶) is handled after the vanilla InventoryS2CPacket² packet.

This causes the inventory to be blank and all PropertyDelegate⁷ values are at the default state. If any slot or

button is clicked a new InventoryS2CPacket² is send which will then populate all slots.

When using the vanilla ScreenHandlerType⁸ which is handled with OpenScreenS2CPacket⁹ there is no problem.

(See attached Video and git tree which runs on 1.21.9 and contains this bug: https://github.com/JDDev0/EnergizedPower/tree/19b36315f9c354e5816bfa92ab8e36881ee08a18)

[1] net.minecraft.entity.player.PlayerEntity.playerScreenHandler
[2] net.minecraft.network.packet.s2c.play.InventoryS2CPacket
[3] net.minecraft.client.network.ClientPlayNetworkHandler.onInventory(InventoryS2CPacket)
[4] net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType
[5] net.fabricmc.fabric.impl.screenhandler.Networking.OpenScreenPayload
[6] net.fabricmc.fabric.impl.screenhandler.client.ClientNetworking
[7] net.minecraft.screen.PropertyDelegate
[8] net.minecraft.screen.ScreenHandlerType
[9] net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket

commented

I'm using those versions:

minecraft_version=1.21.9
yarn_mappings=1.21.9+build.1
loader_version=0.17.2
loom_version=1.11-SNAPSHOT

# Fabric API
fabric_version=0.133.14+1.21.9
commented

Without looking at the code, this is almost certainly the same issue as the one found in NeoForge's network implementation: neoforged/NeoForge#2666

commented

Without looking at the code, this is almost certainly the same issue as the one found in NeoForge's network implementation: neoforged/NeoForge#2666

Honestly the fact I experienced this with both Fabric(25w36b) and NeoForge(1.21.9-pre1) just made me think it was an issue with my mod, especially given my other mod (which uses vanilla's screen handlers) didn't have the issue 😅