Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tooltip rendering order #548

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading