Broken ContainerScreen / CharacterComponent's interaction targets out of sync #4838
Labels
Multiplayer
Affects aspects not visible in Singleplayer mode only
Topic: UI/UX
Requests, Issues and Changes related to screens, artwork, sound and overall user experience
Type: Bug
Issues reporting and PRs fixing problems
Problem
In a multiplayer scenario the
ContainerScreen
is not working properly for remote clients.This behavior is non-deterministic.
✔️ Sometimes the interaction works as intended, i.e., the container screen shows both the player inventory and the inventory of the interaction target
❌ Sometimes the inventory of the interaction target cannot be displayed correctly. Often, the container screen briefly flickers with the correct amount of inventory cells (although without content) before it vanishes. The screen does not update afterwards.
Peek.2021-08-08.23-07.mp4
Clues
Found with https://github.com/MovingBlocks/Terasology/releases/tag/v5.1.1 but likely present before.
Such a broken screen can just be closed by hitting ESC. Upon re-interaction with the same target the screen shows up correctly.
For container screens such as chests the correct behavior can be forced by hitting the respective block once before interacting with it.
The
ContainerScreen
uses theCharacterComponent#predictedInteractionTarget
to show the inventory of the interaction target.Terasology/engine/src/main/java/org/terasology/engine/logic/characters/CharacterComponent.java
Lines 43 to 51 in f57b15f
In a multiplayer scenario, there can be different entities associated with the same block (position).
The source of truth is the authority system, but clients may have local placeholder entities.
In the
EntityAwareWorldProvider
we destroy such placeholder entities for block entities.Terasology/engine/src/main/java/org/terasology/engine/world/internal/EntityAwareWorldProvider.java
Lines 398 to 406 in f57b15f
Even though the binding in the container screen is re-evaluated with every tick it seems the predicted interaction target is never updated on the
CharacterComponent
to adjust for the destroyed entity/use the actual entity that was interacted with.Attempts
The
CharacterComponent
offers another interaction target, theauthorizedInteractionTarget
. Although clients shall not modify it, they are allowed to read it.Terasology/engine/src/main/java/org/terasology/engine/logic/characters/CharacterComponent.java
Lines 27 to 32 in f57b15f
Not knowing about the implementation details we attempted to use the authorized target, if present, and only use the predicted target as fallback. Unfortunately, that did not help, and we could still observe the faulty behavior quite frequently.
The text was updated successfully, but these errors were encountered: