Skip to content

[1.21.1-] Mod breaks PoseStack when chat is empty or hidden #28

Description

@decce6

Description

@Inject(method = "render", at = @At("HEAD"))
private void onRenderStart(GuiGraphics context, int currentTick, int mouseX, int mouseY, boolean focused, CallbackInfo ci) {
float displacement = calculateDisplacement();
context.pose().pushPose();
context.pose().translate(0f, displacement, 0f);
}
@Inject(method = "render", at = @At("TAIL"))
private void onRenderEnd(GuiGraphics context, int currentTick, int mouseX, int mouseY, boolean focused, CallbackInfo ci) {
context.pose().popPose();
}

Here onRenderEnd injects into the TAIL of the method, and thus will not run when the chat is empty or hidden (see image below.)

Steps to Reproduce

  1. Install the mod on 1.20.1 or 1.21.1
  2. Run the game with -Dmixin.debug.export=true
  3. Decompile the generated net.minecraft.client.gui.components.ChatComponent class
  4. Observe that onRenderEnd and onRenderStart do not match
Image

Possible Solution

TAIL should be replace with RETURN. Alternatively, WrapMethod may be used. This makes sure the pop call is always run even when some mods call CallbackInfo#cancel in the middle of the method.

Related Issues

Possibly related to #24 and #25

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions