Skip to content

Commit

Permalink
Merge pull request #548 from refinedmods/fix/GH-543/tooltiprender
Browse files Browse the repository at this point in the history
fix: tooltip rendering order
  • Loading branch information
raoulvdberge authored Jun 9, 2024
2 parents 51af76e + 8969d3b commit cad4df8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Side button tooltip rendering issue with ModernUI.

## [2.0.0-milestone.3.8] - 2024-06-08

### Removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public abstract class AbstractBaseScreen<T extends AbstractContainerMenu> extend
private final List<Rect2i> exclusionZones = new ArrayList<>();
private int sideButtonY;

@Nullable
private List<ClientTooltipComponent> deferredTooltip;

protected AbstractBaseScreen(final T menu, final Inventory playerInventory, final Component text) {
super(menu, playerInventory, text);
this.playerInventory = playerInventory;
Expand Down Expand Up @@ -189,9 +192,17 @@ protected void renderTooltip(final GuiGraphics graphics, final int x, final int
return;
}
}
if (deferredTooltip != null) {
Platform.INSTANCE.renderTooltip(graphics, deferredTooltip, x, y);
deferredTooltip = null;
}
super.renderTooltip(graphics, x, y);
}

public void setDeferredTooltip(@Nullable final List<ClientTooltipComponent> deferredTooltip) {
this.deferredTooltip = deferredTooltip;
}

private List<ClientTooltipComponent> getUpgradeTooltip(final ItemStack carried, final UpgradeSlot upgradeSlot) {
if (!carried.isEmpty() || upgradeSlot.hasItem()) {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage2.platform.common.support.widget;

import com.refinedmods.refinedstorage2.platform.common.Platform;
import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseScreen;
import com.refinedmods.refinedstorage2.platform.common.support.TextureIds;
import com.refinedmods.refinedstorage2.platform.common.support.tooltip.HelpClientTooltipComponent;
import com.refinedmods.refinedstorage2.platform.common.support.tooltip.SmallTextClientTooltipComponent;
Expand All @@ -11,8 +11,10 @@

import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
Expand Down Expand Up @@ -66,7 +68,10 @@ public void renderWidget(final GuiGraphics graphics, final int mouseX, final int
graphics.blit(getTextureIdentifier(), getX(), getY(), 238, 54, WIDTH, HEIGHT);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.disableBlend();
Platform.INSTANCE.renderTooltip(graphics, buildTooltip(), mouseX, mouseY);
final Screen screen = Minecraft.getInstance().screen;
if (screen instanceof AbstractBaseScreen<?> baseScreen) {
baseScreen.setDeferredTooltip(buildTooltip());
}
}
if (warning != null) {
renderWarning(graphics);
Expand Down

0 comments on commit cad4df8

Please sign in to comment.