/
GuiProperties.java
112 lines (96 loc) · 2.49 KB
/
GuiProperties.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package mezz.jei.gui;
import javax.annotation.Nullable;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
public class GuiProperties {
private final Class guiClass;
private final int guiLeft;
private final int guiTop;
private final int guiXSize;
private final int guiYSize;
private final int screenWidth;
private final int screenHeight;
@Nullable
public static GuiProperties create(GuiScreen guiScreen) {
if (guiScreen instanceof RecipesGui) {
return create((RecipesGui) guiScreen);
} else if (guiScreen instanceof GuiContainer) {
return create((GuiContainer) guiScreen);
} else {
return null;
}
}
public static GuiProperties create(GuiContainer guiContainer) {
return new GuiProperties(
guiContainer.getClass(),
guiContainer.guiLeft,
guiContainer.guiTop,
guiContainer.xSize,
guiContainer.ySize,
guiContainer.width,
guiContainer.height
);
}
public static GuiProperties create(RecipesGui recipesGui) {
return new GuiProperties(
recipesGui.getClass(),
recipesGui.getGuiLeft(),
recipesGui.getGuiTop(),
recipesGui.getXSize(),
recipesGui.getYSize(),
recipesGui.width,
recipesGui.height
);
}
private GuiProperties(Class guiClass, int guiLeft, int guiTop, int guiXSize, int guiYSize, int screenWidth, int screenHeight) {
this.guiClass = guiClass;
this.guiLeft = guiLeft;
this.guiTop = guiTop;
this.guiXSize = guiXSize;
this.guiYSize = guiYSize;
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
}
public Class getGuiClass() {
return guiClass;
}
public int getGuiLeft() {
return guiLeft;
}
public int getGuiTop() {
return guiTop;
}
public int getGuiXSize() {
return guiXSize;
}
public int getGuiYSize() {
return guiYSize;
}
public int getScreenWidth() {
return screenWidth;
}
public int getScreenHeight() {
return screenHeight;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof GuiProperties)) {
return false;
}
GuiProperties other = (GuiProperties) obj;
return guiClass == other.getGuiClass() &&
guiLeft == other.getGuiLeft() &&
guiXSize == other.getGuiXSize() &&
screenWidth == other.getScreenWidth() &&
screenHeight == other.getScreenHeight();
}
@Override
public int hashCode() {
int result = guiClass.hashCode();
result = 31 * result + guiLeft;
result = 31 * result + guiXSize;
result = 31 * result + screenWidth;
result = 31 * result + screenHeight;
return result;
}
}