- 201
- 6
- 32
Java:
public class RPGButton extends GuiButton {
int h = 0, w = 0;
public ResourceLocation img = new ResourceLocation(Leviathan.MOD_ID + (":textures/gui/Knopka.png"));
private String text;
private float scalledX = 1,scalledY = 1,zLevel = 1;
private boolean drawText;
public static RPGButton Instance;
public RPGButton(int id, int x, int y, String text)
{
super(id, x, y, text);
}
public RPGButton(int id, int x, int y, int width, int height, String text)
{
super(id, x, y, width, height, text);
}
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks)
{
FontRenderer fontrenderer = mc.fontRenderer;
mc.getTextureManager().bindTexture(img);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
if (this.hovered)
mc.getTextureManager().bindTexture(img);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
draw();
this.mouseDragged(mc, mouseX, mouseY);
int j = 14737632;
if (packedFGColour != 0)
{
j = packedFGColour;
}
else if (!this.enabled)
{
j = 10526880;
}
else if(this.hovered){
j = 16777120;
}
if(drawText)
this.drawCenteredString(fontrenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, j);
}
public void changeText(String text){
this.text = text;
}
public void changeScalledX(float x){
scalledX = x;
}
public void changeScalledY(float y){
scalledY = y;
}
public void changeZLevel(float z){
zLevel = z;
}
public boolean compareString(String text){
return this.text.equals(text);
}
public void setDrawText(boolean set){
drawText = set;
}
private void draw(){
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos(x, y + h, 0).tex(0,1).endVertex();
bufferbuilder.pos(x + w, y + h, 0).tex(1, 1).endVertex();
bufferbuilder.pos(x + w, y, 0).tex(1,0).endVertex();
bufferbuilder.pos(x, y, 0).tex(0,0).endVertex();
tessellator.draw();
}
}
вот код, своя кнопка в Minecraft. Использую ее, но текстура кнопки не устанавливается.
Что не так с кодом?