38 lines
1.4 KiB
Java
38 lines
1.4 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.client.gui.components;
|
|
|
|
import net.minecraft.client.gui.GuiGraphics;
|
|
import net.minecraft.client.gui.components.Button;
|
|
import net.minecraft.client.gui.components.WidgetSprites;
|
|
import net.minecraft.client.renderer.RenderPipelines;
|
|
import net.minecraft.network.chat.CommonComponents;
|
|
import net.minecraft.network.chat.Component;
|
|
import net.minecraft.resources.Identifier;
|
|
|
|
public class ImageButton
|
|
extends Button {
|
|
protected final WidgetSprites sprites;
|
|
|
|
public ImageButton(int x, int y, int width, int height, WidgetSprites sprites, Button.OnPress onPress) {
|
|
this(x, y, width, height, sprites, onPress, CommonComponents.EMPTY);
|
|
}
|
|
|
|
public ImageButton(int x, int y, int width, int height, WidgetSprites sprites, Button.OnPress onPress, Component message) {
|
|
super(x, y, width, height, message, onPress, DEFAULT_NARRATION);
|
|
this.sprites = sprites;
|
|
}
|
|
|
|
public ImageButton(int width, int height, WidgetSprites sprites, Button.OnPress onPress, Component message) {
|
|
this(0, 0, width, height, sprites, onPress, message);
|
|
}
|
|
|
|
@Override
|
|
public void renderContents(GuiGraphics graphics, int mouseX, int mouseY, float a) {
|
|
Identifier sprite = this.sprites.get(this.isActive(), this.isHoveredOrFocused());
|
|
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, sprite, this.getX(), this.getY(), this.width, this.height);
|
|
}
|
|
}
|
|
|