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
|
package gregtech.api.gui.widgets;
import gregtech.api.interfaces.IGuiScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import java.awt.*;
public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement {
private final GT_GuiIcon bgIcon;
private ItemStack item;
private IGuiScreen gui;
private int x0, y0, xPosition, yPosition;
private int width, height;
public GT_GuiFakeItemButton(IGuiScreen gui, int x, int y, GT_GuiIcon bgIcon) {
this.gui = gui;
this.x0 = x;
this.y0 = y;
this.bgIcon = bgIcon;
item = null;
width = 18;
height = 18;
gui.addElement(this);
}
public GT_GuiFakeItemButton setItem(ItemStack i) {
item = i;
return this;
}
public ItemStack getItem(){
return item;
}
@Override
public void onInit() {
xPosition = x0 + gui.getGuiLeft();
yPosition = y0 + gui.getGuiTop();
}
@Override
public void draw(int mouseX, int mouseY, float parTicks) {
GL11.glColor4f(1, 1, 1, 1);
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (bgIcon != null){
GT_GuiIcon.render(bgIcon, xPosition-1, yPosition-1, 18, 18,0,true);
}
if (item != null)
gui.getItemRenderer().renderItemAndEffectIntoGUI(gui.getFontRenderer(), Minecraft.getMinecraft().getTextureManager(), item, xPosition, yPosition);
GL11.glPopAttrib();
}
public Rectangle getBounds() {
return new Rectangle(x0, y0, width, height);
}
}
|