/
DrawableResource.java
70 lines (57 loc) · 2.07 KB
/
DrawableResource.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
64
65
66
67
68
69
70
package mezz.jei.gui;
import mezz.jei.api.gui.IDrawableStatic;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.config.GuiUtils;
public class DrawableResource implements IDrawableStatic {
private final ResourceLocation resourceLocation;
private final int u;
private final int v;
private final int width;
private final int height;
private final int paddingTop;
private final int paddingBottom;
private final int paddingLeft;
private final int paddingRight;
public DrawableResource(ResourceLocation resourceLocation, int u, int v, int width, int height) {
this(resourceLocation, u, v, width, height, 0, 0, 0, 0);
}
public DrawableResource(ResourceLocation resourceLocation, int u, int v, int width, int height, int paddingTop, int paddingBottom, int paddingLeft, int paddingRight) {
this.resourceLocation = resourceLocation;
this.u = u;
this.v = v;
this.width = width;
this.height = height;
this.paddingTop = paddingTop;
this.paddingBottom = paddingBottom;
this.paddingLeft = paddingLeft;
this.paddingRight = paddingRight;
}
@Override
public int getWidth() {
return width + paddingLeft + paddingRight;
}
@Override
public int getHeight() {
return height + paddingTop + paddingBottom;
}
@Override
public void draw(Minecraft minecraft) {
draw(minecraft, 0, 0);
}
@Override
public void draw(Minecraft minecraft, int xOffset, int yOffset) {
draw(minecraft, xOffset, yOffset, 0, 0, 0, 0);
}
@Override
public void draw(Minecraft minecraft, int xOffset, int yOffset, int maskTop, int maskBottom, int maskLeft, int maskRight) {
minecraft.getTextureManager().bindTexture(this.resourceLocation);
int x = xOffset + this.paddingLeft + maskLeft;
int y = yOffset + this.paddingTop + maskTop;
int u = this.u + maskLeft;
int v = this.v + maskTop;
int width = this.width - maskRight - maskLeft;
int height = this.height - maskBottom - maskTop;
GuiUtils.drawTexturedModalRect(x, y, u, v, width, height, 0);
}
}