Untitled
unknown
java
3 years ago
2.0 kB
4
Indexable
Never
package com.radon.naruto_universe.client.screen.widget; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.radon.naruto_universe.NarutoUniverse; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; public class CustomButton extends Button { private static final ResourceLocation WIDGETS = new ResourceLocation(NarutoUniverse.MOD_ID, "textures/gui/widgets.png"); public CustomButton(int x, int y, int width, int height, ITextComponent component, IPressable onPress) { super(x, y, width, height, component, onPress); } @Override public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { Minecraft minecraft = Minecraft.getInstance(); // FontRenderer renderer = minecraft.font; minecraft.getTextureManager().bind(WIDGETS); RenderSystem.color4f(1.0F, 1.0F, 1.0F, this.alpha); int index = this.getYImage(this.isHovered()); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.enableDepthTest(); this.blit(matrixStack, this.x, this.y, 0, index * 15, this.width / 2, this.height); this.blit(matrixStack, this.x + this.width / 2, this.y, 200 - this.width / 2, index * 15, this.width / 2, this.height); this.renderBg(matrixStack, minecraft, mouseX, mouseY); // int color = getFGColor(); // drawCenteredString(matrixStack, renderer, this.getMessage(), this.x + this.width / 2, this.y + (this.height - 8) / 2, color | MathHelper.ceil(this.alpha * 255.0F) << 24); } @Override protected int getYImage(boolean isHovered) { return isHovered ? 1 : 0; } }