Skip to content

Commit

Permalink
Fix ItemCollectorScreen doesn't render tooltip
Browse files Browse the repository at this point in the history
Add transparency for filter slots with no item inside
  • Loading branch information
YocyCraft committed Dec 20, 2024
1 parent aedece2 commit ab69646
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dev.dubhe.anvilcraft.inventory.IFilterMenu;
import dev.dubhe.anvilcraft.network.MachineEnableFilterPacket;

import dev.dubhe.anvilcraft.util.RenderHelper;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.AbstractContainerMenu;
Expand Down Expand Up @@ -147,7 +148,7 @@ default void renderDisabledSlot(@NotNull GuiGraphics guiGraphics, @NotNull Slot
default void renderFilterItem(@NotNull GuiGraphics guiGraphics, @NotNull Slot slot, @NotNull ItemStack stack) {
int i = slot.x;
int j = slot.y;
guiGraphics.renderFakeItem(stack, i, j);
RenderHelper.renderItemWithTransparency(stack, guiGraphics.pose(), i, j, 0.52f);
guiGraphics.fill(i, j, i + 16, j + 16, 0x80ffaaaa);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ protected void renderSlotTooltip(@NotNull GuiGraphics guiGraphics, int x, int y)
guiGraphics.renderTooltip(this.font, Component.translatable("screen.anvilcraft.slot.disable.tooltip"), x, y);
}

@Override
@NotNull
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
super.render(guiGraphics, mouseX, mouseY, partialTick);
this.renderTooltip(guiGraphics, mouseX, mouseY);
}

@Override
public ItemCollectorMenu getFilterMenu() {
return this.menu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static Optional<Block> getDisplay(TagKey<Block> tag){

/**
* 根据方块配方输入,获取需要展示的工具提示
*
* @param input 方块标签或方块的配方输入
* @return 展示方块对应的工具提示。若为方块标签,还会展示具体的标签名
*/
Expand Down

0 comments on commit ab69646

Please sign in to comment.