forked from virt-mirrors/Sit
new ModMenu UI
This commit is contained in:
parent
c8f86a2aaa
commit
457a8d10d3
5 changed files with 271 additions and 179 deletions
32
src/main/java/one/oth3r/sit/screen/ClickableImageWidget.java
Normal file
32
src/main/java/one/oth3r/sit/screen/ClickableImageWidget.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package one.oth3r.sit.screen;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.tooltip.Tooltip;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ClickableImageWidget extends ButtonWidget {
|
||||
private final Identifier image;
|
||||
|
||||
public ClickableImageWidget(int x, int y, int width, int height, Tooltip tooltip, Identifier image, ButtonWidget.PressAction onPress) {
|
||||
super(x, y, width, height, Text.empty(), onPress, Supplier::get);
|
||||
this.image = image;
|
||||
this.setTooltip(tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
context.setShaderColor(1.0f, 1.0f, 1.0f, this.alpha);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableDepthTest();
|
||||
context.drawTexture(image, this.getX(), this.getY(), 0.0f, 0.0f, this.getWidth(), this.getHeight(), this.getWidth(), this.getHeight());
|
||||
context.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue