/
RecipeWidget.java
63 lines (47 loc) · 1.67 KB
/
RecipeWidget.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package mezz.jei.gui;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
public class RecipeWidget {
@Nonnull
private final IRecipeCategory recipeCategory;
private final GuiItemStacks guiItemStacks;
private final GuiFluidTanks guiFluidTanks;
private IRecipeWrapper recipeWrapper;
private int posX;
private int posY;
public RecipeWidget(@Nonnull IRecipeCategory recipeCategory) {
this.recipeCategory = recipeCategory;
this.guiItemStacks = new GuiItemStacks();
this.guiFluidTanks = new GuiFluidTanks();
this.recipeCategory.init(guiItemStacks, guiFluidTanks);
}
public void setPosition(int posX, int posY) {
this.posX = posX;
this.posY = posY;
}
public void setRecipe(@Nonnull IRecipeWrapper recipeWrapper, @Nonnull Focus focus) {
this.recipeWrapper = recipeWrapper;
guiItemStacks.clear();
guiItemStacks.setFocus(focus);
recipeCategory.setRecipe(guiItemStacks, guiFluidTanks, recipeWrapper);
}
public void draw(@Nonnull Minecraft minecraft, int mouseX, int mouseY) {
if (recipeWrapper == null) {
return;
}
GL11.glPushMatrix();
GL11.glTranslatef(posX, posY, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
recipeCategory.getBackground().draw(minecraft);
recipeWrapper.drawInfo(minecraft);
guiItemStacks.draw(minecraft, mouseX - posX, mouseY - posY);
GL11.glPopMatrix();
}
public Focus getFocusUnderMouse(int mouseX, int mouseY) {
return guiItemStacks.getFocusUnderMouse(mouseX - posX, mouseY - posY);
}
}