| @SideOnly(Side.CLIENT) |
| public class BouttonSpell extends GuiButton |
| { |
| |
| public BouttonSpell(int par1, int par2, int par3, int par4, int par5, String par6Str) |
| { |
| super(par1, par2, par3, par4, par5, par6Str); |
| |
| } |
| |
| public static ResourceLocation buttonTextures; |
| private int textureIndex; |
| |
| public BouttonSpell setTextureIndex(int index) |
| { |
| textureIndex = index; |
| return this; |
| } |
| |
| public void drawButton(Minecraft par1Minecraft, int par2, int par3) |
| { |
| if(this.drawButton) |
| { |
| |
| if(textureIndex == 0) |
| { |
| buttonTextures = new ResourceLocation("coespell:textures/item/0.png"); |
| |
| } |
| else if(textureIndex == 1) |
| { |
| buttonTextures = new ResourceLocation("coespell:textures/item/1.png"); |
| |
| } |
| |
| else if(textureIndex == 2) |
| { |
| buttonTextures = new ResourceLocation("coespell:textures/item/2.png"); |
| |
| } |
| |
| FontRenderer fontrenderer = par1Minecraft.fontRenderer; |
| par1Minecraft.getTextureManager().bindTexture(buttonTextures); |
| GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); |
| this.field_82253_i = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; |
| int k = this.getHoverState(this.field_82253_i); |
| this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height); |
| this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height); |
| this.mouseDragged(par1Minecraft, par2, par3); |
| int l = 14737632; |
| |
| if(!this.enabled) |
| { |
| l = -6250336; |
| } |
| else if(this.field_82253_i) |
| { |
| l = 16777120; |
| } |
| |
| this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); |
| } |
| } |
| } |
voici ma classe de bouton custom