2014-04-29 10:54:20 +10:00
|
|
|
package codechicken.nei.api;
|
|
|
|
|
|
2024-08-17 23:24:27 +03:00
|
|
|
import static codechicken.lib.gui.GuiDraw.drawRect;
|
|
|
|
|
|
2023-09-25 00:35:24 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
import net.minecraft.inventory.Slot;
|
2023-09-25 00:35:24 +02:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
2025-04-24 18:48:40 +03:00
|
|
|
import codechicken.nei.NEIClientUtils;
|
2023-09-25 00:35:24 +02:00
|
|
|
import codechicken.nei.PositionedStack;
|
|
|
|
|
import codechicken.nei.guihook.GuiContainerManager;
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
public class DefaultOverlayRenderer implements IRecipeOverlayRenderer {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
public DefaultOverlayRenderer(List<PositionedStack> ai, IStackPositioner positioner) {
|
2025-01-25 21:16:28 +02:00
|
|
|
this.positioner = positioner;
|
2019-12-30 20:19:16 -08:00
|
|
|
ingreds = new ArrayList<>();
|
2022-06-24 12:32:13 +01:00
|
|
|
for (PositionedStack stack : ai) ingreds.add(stack.copy());
|
2014-04-29 10:54:20 +10:00
|
|
|
ingreds = positioner.positionStacks(ingreds);
|
|
|
|
|
}
|
2022-06-24 12:32:13 +01:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
@Override
|
2022-06-24 12:32:13 +01:00
|
|
|
public void renderOverlay(GuiContainerManager gui, Slot slot) {
|
2024-08-17 23:24:27 +03:00
|
|
|
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
2014-04-29 10:54:20 +10:00
|
|
|
GL11.glEnable(GL11.GL_BLEND);
|
|
|
|
|
GL11.glBlendFunc(770, 1);
|
2022-06-24 12:32:13 +01:00
|
|
|
|
|
|
|
|
for (PositionedStack stack : ingreds) {
|
2024-08-17 23:24:27 +03:00
|
|
|
if (stack.relx == slot.xDisplayPosition && stack.rely == slot.yDisplayPosition && !slot.getHasStack()) {
|
2014-04-29 10:54:20 +10:00
|
|
|
GuiContainerManager.drawItem(stack.relx, stack.rely, stack.item);
|
2024-08-17 23:24:27 +03:00
|
|
|
drawHover(stack.relx, stack.rely);
|
|
|
|
|
}
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
2022-06-24 12:32:13 +01:00
|
|
|
|
2024-08-17 23:24:27 +03:00
|
|
|
GL11.glPopAttrib();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void drawHover(int x, int y) {
|
2025-04-24 18:48:40 +03:00
|
|
|
NEIClientUtils.gl2DRenderContext(() -> drawRect(x, y, 16, 16, 0x66555555));
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
2022-06-24 12:32:13 +01:00
|
|
|
|
2019-12-30 20:19:16 -08:00
|
|
|
final IStackPositioner positioner;
|
2014-04-29 10:54:20 +10:00
|
|
|
ArrayList<PositionedStack> ingreds;
|
|
|
|
|
}
|