|
24 | 24 | package me.shedaniel.rei.impl.client.gui.widget;
|
25 | 25 |
|
26 | 26 | import com.mojang.blaze3d.systems.RenderSystem;
|
| 27 | +import me.shedaniel.math.Color; |
27 | 28 | import me.shedaniel.rei.api.common.util.EntryStacks;
|
| 29 | +import me.shedaniel.rei.impl.client.config.ConfigManagerImpl; |
28 | 30 | import me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListSearchManager;
|
29 | 31 | import net.minecraft.client.Minecraft;
|
30 | 32 | import net.minecraft.client.gui.GuiGraphics;
|
31 | 33 | import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
| 34 | +import net.minecraft.client.renderer.RenderType; |
32 | 35 | import net.minecraft.world.inventory.Slot;
|
33 | 36 |
|
34 | 37 | public class EntryHighlighter {
|
35 | 38 | public static void render(GuiGraphics graphics) {
|
| 39 | + float dimOpacity = (float) ConfigManagerImpl.getInstance().getConfig().functionality.inventoryHighlightingDarkenOpacity; |
| 40 | + float opacity = (float) ConfigManagerImpl.getInstance().getConfig().functionality.inventoryHighlightingOpacity; |
| 41 | + int dimColor = Color.ofRGBA(20 / 255F, 20 / 255F, 20 / 255F, dimOpacity).getColor(); |
| 42 | + int borderColor = Color.ofRGBA(0x5f / 255F, 0xff / 255F, 0x3b / 255F, opacity).getColor(); |
| 43 | + int color = Color.ofRGBA(0x5f / 255F, 0xff / 255F, 0x3b / 255F, opacity * 0x34 / 255F).getColor(); |
36 | 44 | RenderSystem.disableDepthTest();
|
37 | 45 | RenderSystem.colorMask(true, true, true, false);
|
38 | 46 | if (Minecraft.getInstance().screen instanceof AbstractContainerScreen<?> containerScreen) {
|
39 | 47 | int x = containerScreen.leftPos, y = containerScreen.topPos;
|
40 | 48 | for (Slot slot : containerScreen.getMenu().slots) {
|
41 | 49 | if (!slot.hasItem() || !EntryListSearchManager.INSTANCE.matches(EntryStacks.of(slot.getItem()))) {
|
42 |
| - graphics.pose().pushPose(); |
43 |
| - graphics.pose().translate(0, 0, 500f); |
44 |
| - graphics.fillGradient(x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, 0xdc202020, 0xdc202020); |
45 |
| - graphics.pose().popPose(); |
| 50 | + graphics.fillGradient(RenderType.guiOverlay(), x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, dimColor, dimColor, 0); |
46 | 51 | } else {
|
47 | 52 | graphics.pose().pushPose();
|
48 | 53 | graphics.pose().translate(0, 0, 200f);
|
49 |
| - graphics.fillGradient(x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, 0x345fff3b, 0x345fff3b); |
50 |
| - |
51 |
| - graphics.fillGradient(x + slot.x - 1, y + slot.y - 1, x + slot.x, y + slot.y + 16 + 1, 0xff5fff3b, 0xff5fff3b); |
52 |
| - graphics.fillGradient(x + slot.x + 16, y + slot.y - 1, x + slot.x + 16 + 1, y + slot.y + 16 + 1, 0xff5fff3b, 0xff5fff3b); |
53 |
| - graphics.fillGradient(x + slot.x - 1, y + slot.y - 1, x + slot.x + 16, y + slot.y, 0xff5fff3b, 0xff5fff3b); |
54 |
| - graphics.fillGradient(x + slot.x - 1, y + slot.y + 16, x + slot.x + 16, y + slot.y + 16 + 1, 0xff5fff3b, 0xff5fff3b); |
| 54 | + graphics.fillGradient(x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, color, color); |
| 55 | + |
| 56 | + graphics.fillGradient(x + slot.x - 1, y + slot.y - 1, x + slot.x, y + slot.y + 16 + 1, borderColor, borderColor); |
| 57 | + graphics.fillGradient(x + slot.x + 16, y + slot.y - 1, x + slot.x + 16 + 1, y + slot.y + 16 + 1, borderColor, borderColor); |
| 58 | + graphics.fillGradient(x + slot.x - 1, y + slot.y - 1, x + slot.x + 16, y + slot.y, borderColor, borderColor); |
| 59 | + graphics.fillGradient(x + slot.x - 1, y + slot.y + 16, x + slot.x + 16, y + slot.y + 16 + 1, borderColor, borderColor); |
55 | 60 |
|
56 | 61 | graphics.pose().popPose();
|
57 | 62 | }
|
|
0 commit comments