- 22
- 0
Доброго времени суток. Появилась проблема, Создал два класса GuiButton и GuiScreen. Но GuiButton отображается позади и пнгешка его перекрывает, подскажите что делать. Заранее спасибо)
GuiScreen:
public class GuiHandler extends MPGui
{
public GuiHandler(String text) {
this.ids = ArrayFromString(text);
}
int scaledWidth;
int scaledHeight;
protected static final RenderItem ritem;
List<String> ids;
int x = 203;
static {
ritem = new RenderItem();
}
@Override
public void drawScreen(final int x, final int y, final float ticks) {
super.drawScreen(x, y, ticks);
final int guiX = super.width / 2 - 250;
final int guiY = super.height / 2 - 140;
super.mc.renderEngine.bindTexture(new ResourceLocation("dailyrewards", "textures/gui/RewardsBackground.png"));
//GL11.glColor4d(1.0D, 1.0D, 1.0D, Math.min(Math.min(0.5D, 1.0D), 1.0D));
this.drawCompleteImage(guiX, guiY, 500, 250);
GL11.glPushMatrix();
GL11.glEnable(3089);
GL11.glDisable(3089);
GL11.glPopMatrix();
text();
this.buttonList.clear();
for (String id : ids) {
int tx = this.x + 65;
drawItem(tx, 175, ticks, Integer.parseInt(id));
this.x = tx;
}
this.x = 205;
}
public void text() {
drawScaledString("\u0415\u0436\u0435\u0434\u043D\u0435\u0432\u043D\u044B\u0435\u0020\u043D\u0430\u0433\u0440\u0430\u0434\u044B", super.width / 2, super.height / 2 - 115, 2.0F, TextPosition.CENTER);
}
public void drawItem(final int x, final int y, final float ticks, int id) {
renderItemEnable(x-9, y-10, 50, 50);
button(x - 12, y + 45, id);
ItemStack stack = new ItemStack(Item.getItemById(id));
GL11.glPushMatrix();
GL11.glTranslatef(x, y, 1.5F);
GL11.glScalef(2.0F, 2.0F, 1.5F);
itemRender.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.getTextureManager(), stack, 0, 0);
GL11.glDisable(2896);
GL11.glPopMatrix();
}
public static void renderItemEnable(int xCoord, int yCoord, int i, int j) {
int w = i + 4;
int h = j + 4;
int x = xCoord - 2;
int y = yCoord - 2;
Tessellator tessellator = Tessellator.instance;
ResourceLocation skin = new ResourceLocation("dailyrewards", "textures/gui/ItemBackground.png");
Minecraft.getMinecraft().getTextureManager().bindTexture(skin);
GL11.glEnable(3042);
GL11.glColor4d(1.0D, 1.0D, 1.0D, Math.min(Math.min(0.5D, 1.0D), 1.0D));
tessellator.startDrawingQuads();
byte zLevel = 0;
tessellator.addVertexWithUV((x + 0), (y + h), zLevel, 0.0D, 1.0D);
tessellator.addVertexWithUV((x + w), (y + h), zLevel, 1.0D, 1.0D);
tessellator.addVertexWithUV((x + w), (y + 0), zLevel, 1.0D, 0.0D);
tessellator.addVertexWithUV((x + 0), (y + 0), zLevel, 0.0D, 0.0D);
tessellator.draw();
GL11.glDisable(3042);
}
public void button(int x, int y, int id) {
Button butt1 = new Button(3, x, y, 55, 20, "\u041F\u043E\u043B\u0443\u0447\u0438\u0442\u044C", id);
this.buttonList.add(butt1);
}
public List<String> ArrayFromString(String text) {
return Arrays.asList(text.split(", "));
}
GuiButton:
public class Button extends GuiButton {
protected final ResourceLocation buttonTextures = new ResourceLocation("dailyrewards", "textures/gui/widgets.png");
public Button(int p_i1020_1_, int p_i1020_2_, int p_i1020_3_, String p_i1020_4_, int item) {
this(p_i1020_1_, p_i1020_2_, p_i1020_3_, 200, 20, p_i1020_4_, item);
}
private int item;
public Button(int id, int x, int y, int w, int h, String s, int item) {
super(id, x, y, w, h, s);
this.width = 200;
this.height = 20;
this.enabled = true;
this.visible = true;
this.id = id;
this.xPosition = x;
this.yPosition = y;
this.width = w;
this.height = h;
this.displayString = s;
this.item = item;
}
public void drawButton(Minecraft mc, int p_146112_2_, int p_146112_3_) {
if (this.visible) {
FontRenderer fontrenderer = mc.fontRenderer;
mc.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = (p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height);
int k = getHoverState(this.field_146123_n);
GL11.glEnable(3042);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(770, 771);
drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
mouseDragged(mc, p_146112_2_, p_146112_3_);
int l = 14737632;
if (this.packedFGColour != 0) {
l = this.packedFGColour;
} else if (!this.enabled) {
l = 10526880;
} else if (this.field_146123_n) {
l = 16777120;
}
drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 7) / 2, l);
}
}
public void mouseReleased(int par1, int par2) {
(new Thread((Runnable)new SendToServer(item))).start();
}
}
}