Skip to content

Commit

Permalink
Fix tooltip rendering bug
Browse files Browse the repository at this point in the history
  • Loading branch information
KabanFriends committed Jun 28, 2024
1 parent ceec704 commit 7fddb68
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.github.kabanfriends.craftgr.mixin;

import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.List;

// The purpose of this Mixin is to fix a client bug where the
// batch text rendering in tooltips are never correctly flushed.
@Mixin(GuiGraphics.class)
public abstract class MixinGuiGraphics {

@Inject(method = "renderTooltipInternal", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;popPose()V",shift = At.Shift.AFTER))
public void craftgr$fixTooltip(Font font, List<ClientTooltipComponent> tooltips, int mouseX, int mouseY, ClientTooltipPositioner positioner, CallbackInfo ci) {
invokeFlushIfUnmanaged();
}

@Invoker("flushIfUnmanaged")
public abstract void invokeFlushIfUnmanaged();
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,8 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY) {

RenderSystem.enableScissor(scissorX, (CraftGR.MC.getWindow().getHeight() - scissorY - scissorH), scissorW, scissorH);

//Debugging code
/*
poseStack.pushPose();
poseStack.last().pose().setIdentity();
RenderUtil.fill(poseStack, 0, 0, CraftGR.MC.getWindow().getWidth(), CraftGR.MC.getWindow().getHeight(), 0x8F00FF00, 0.6f);
poseStack.popPose();
*/
// Uncomment to debug
//io.github.kabanfriends.craftgr.util.RenderUtil.fill(poseStack, 0, 0, CraftGR.MC.getWindow().getWidth(), CraftGR.MC.getWindow().getHeight(), 0x8F00FF00, 0.6f);

poseStack.pushPose();
poseStack.scale(2, 2, 2);
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/resources/craftgr-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_21",
"mixins": [
"MixinAccessorAbstractSelectionList",
"MixinGuiGraphics",
"MixinMinecraft",
"MixinOptionEntry",
"MixinOptionsSubScreen",
Expand All @@ -12,7 +13,6 @@
"MixinSoundOptionsScreen",
"MixinTitleScreen"
],
"client": [],
"server": [],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 7fddb68

Please sign in to comment.