package info.u_team.u_team_core.gui.elements;

import com.mojang.blaze3d.vertex.PoseStack;

import info.u_team.u_team_core.util.GuiUtil;
import info.u_team.u_team_core.util.RGBA;
import info.u_team.u_team_core.util.RenderUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation;

public class ImageButton extends UButton {
	
	protected ResourceLocation image;
	
	protected RGBA imageColor;
	
	public ImageButton(int x, int y, int width, int height, ResourceLocation image) {
		this(x, y, width, height, image, EMTPY_PRESSABLE);
	}
	
	public ImageButton(int x, int y, int width, int height, ResourceLocation image, OnPress pessable) {
		this(x, y, width, height, image, pessable, EMPTY_TOOLTIP);
	}
	
	public ImageButton(int x, int y, int width, int height, ResourceLocation image, OnTooltip tooltip) {
		this(x, y, width, height, image, EMTPY_PRESSABLE, tooltip);
	}
	
	public ImageButton(int x, int y, int width, int height, ResourceLocation image, OnPress pessable, OnTooltip tooltip) {
		super(x, y, width, height, TextComponent.EMPTY, pessable, tooltip);
		this.image = image;
		imageColor = WHITE;
	}
	
	public ResourceLocation getImage() {
		return image;
	}
	
	public void setImage(ResourceLocation image) {
		this.image = image;
	}
	
	public RGBA getImageColor() {
		return imageColor;
	}
	
	public void setImageColor(RGBA imageColor) {
		this.imageColor = imageColor;
	}
	
	@Override
	public void renderForeground(PoseStack matrixStack, Minecraft minecraft, int mouseX, int mouseY, float partialTicks) {
		minecraft.getTextureManager().bindForSetup(getCurrentImage());
		
		RenderUtil.enableBlend();
		RenderUtil.defaultBlendFunc();
		GuiUtil.drawTexturedColoredQuad(matrixStack, x + 2, x + width - 2, y + 2, y + height - 2, 0, 1, 0, 1, 0, getCurrentImageColor(matrixStack, mouseX, mouseY, partialTicks));
		RenderUtil.disableBlend();
	}
	
	public ResourceLocation getCurrentImage() {
		return image;
	}
	
	public RGBA getCurrentImageColor(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
		return imageColor;
	}
}

@@ -40,16 +40,64 @@
 ments;%0A%0A
+import com.mojang.blaze3d.systems.RenderSystem;%0A
 import c
@@ -132,16 +132,16 @@
 eStack;%0A
-
 %0Aimport 
@@ -231,47 +231,38 @@
 ort 
-info.u_team.u_team_core.util.RenderUtil
+net.minecraft.client.Minecraft
 ;%0Aim
@@ -283,33 +283,45 @@
 raft.client.
-Minecraft
+renderer.GameRenderer
 ;%0Aimport net
@@ -1648,68 +1648,163 @@
 %7B%0A%09%09
-minecraft.getTextureManager().bindForSetup(getCurrentImage()
+RenderSystem.setShader(GameRenderer::getPositionTexShader);%0A%09%09RenderSystem.setShaderTexture(0, getCurrentImage());%0A%09%09RenderSystem.setShaderColor(1, 1, 1, 1
 );%0A%09
@@ -1813,20 +1813,22 @@
 %09%09Render
-Util
+System
 .enableB
@@ -1843,20 +1843,22 @@
 %09%09Render
-Util
+System
 .default
@@ -1870,16 +1870,19 @@
 Func();%0A
+%09%09%0A
 %09%09GuiUti
@@ -2046,24 +2046,27 @@
 icks));%0A
+%09%09%0A
 %09%09Render
 Util.dis
@@ -2057,20 +2057,22 @@
 %09%09Render
-Util
+System
 .disable

Fix image button