All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.parzivail.util.client.screen.LocalTextureToggleButtonWidget Maven / Gradle / Ivy

package com.parzivail.util.client.screen;

import I;
import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.class_2561;
import net.minecraft.class_2960;
import net.minecraft.class_332;
import net.minecraft.class_4185;

@Environment(value = EnvType.CLIENT)
public class LocalTextureToggleButtonWidget extends class_4185
{
	private final class_2960 source;
	private final int u;
	private final int v;
	private final int textureWidth;
	private final int textureHeight;
	private final int hoveredU;
	private final int hoveredV;
	private final int pressedU;
	private final int pressedV;

	private boolean pressed;

	public LocalTextureToggleButtonWidget(class_2960 source, int x, int y, int width, int height, int u, int v, class_4185.class_4241 pressAction)
	{
		this(source, x, y, width, height, u, v, u, v, u, v, pressAction);
	}

	public LocalTextureToggleButtonWidget(class_2960 source, int x, int y, int width, int height, int u, int v, int hoveredU, int hoveredV, int pressedU, int pressedV, class_4185.class_4241 pressAction)
	{
		this(source, x, y, width, height, u, v, hoveredU, hoveredV, pressedU, pressedV, 256, 256, pressAction);
	}

	public LocalTextureToggleButtonWidget(class_2960 source, int x, int y, int width, int height, int u, int v, int hoveredU, int hoveredV, int pressedU, int pressedV, int textureWidth, int textureHeight, class_4185.class_4241 pressAction)
	{
		this(source, x, y, width, height, u, v, hoveredU, hoveredV, pressedU, pressedV, textureWidth, textureHeight, pressAction, class_2561.method_43473());
	}

	public LocalTextureToggleButtonWidget(class_2960 source, int x, int y, int width, int height, int u, int v, int hoveredU, int hoveredV, int pressedU, int pressedV, int textureWidth, int textureHeight, class_4185.class_4241 pressAction, class_2561 text)
	{
		super(x, y, width, height, text, pressAction, field_40754);
		this.source = source;
		this.textureWidth = textureWidth;
		this.textureHeight = textureHeight;
		this.u = u;
		this.v = v;
		this.hoveredU = hoveredU;
		this.hoveredV = hoveredV;
		this.pressedU = pressedU;
		this.pressedV = pressedV;
	}

	public void setPressed(boolean pressed)
	{
		this.pressed = pressed;
	}

	public boolean isPressed()
	{
		return pressed;
	}

	@Override
	public void method_48579(class_332 context, int mouseX, int mouseY, float delta)
	{
		var tU = this.u;
		var tV = this.v;

		if (isPressed())
		{
			tU = this.pressedU;
			tV = this.pressedV;
		}
		else if (this.method_49606())
		{
			tU = this.hoveredU;
			tV = this.hoveredV;
		}

		RenderSystem.enableDepthTest();
		context.method_25290(source, this.method_46426(), this.method_46427(), tU, tV, this.field_22758, this.field_22759, this.textureWidth, this.textureHeight);

		var oldTexture = RenderSystem.getShaderTexture(0);
		//		if (this.hovered)
		//			this.renderTooltip(matrices, mouseX, mouseY);
		RenderSystem.setShaderTexture(0, oldTexture);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy