/
ShapelessIcon.java
43 lines (34 loc) · 1.12 KB
/
ShapelessIcon.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
package mezz.jei.common.gui.recipes;
import com.mojang.blaze3d.vertex.PoseStack;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.common.gui.elements.HighResolutionDrawable;
import mezz.jei.common.gui.textures.Textures;
import mezz.jei.common.util.ImmutableRect2i;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class ShapelessIcon {
private final HighResolutionDrawable icon;
private ImmutableRect2i area;
public ShapelessIcon(Textures textures) {
this.icon = textures.getShapelessIcon();
this.area = ImmutableRect2i.EMPTY;
setPosition(0, 0);
}
public IDrawable getIcon() {
return icon;
}
public void setPosition(int posX, int posY) {
this.area = new ImmutableRect2i(posX, posY, icon.getWidth(), icon.getHeight());
}
public void draw(PoseStack poseStack) {
this.icon.draw(poseStack, area.getX(), area.getY());
}
@Nullable
public List<Component> getTooltipStrings(int mouseX, int mouseY) {
if (this.area.contains(mouseX, mouseY)) {
return List.of(Component.translatable("jei.tooltip.shapeless.recipe"));
}
return null;
}
}