Fixed sodium light bug
This commit is contained in:
@@ -5,7 +5,6 @@ import java.util.function.Consumer;
|
|||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
import org.saturnclient.ui.SaturnUi;
|
import org.saturnclient.ui.SaturnUi;
|
||||||
import org.saturnclient.ui.SaturnWidget;
|
import org.saturnclient.ui.SaturnWidget;
|
||||||
@@ -42,10 +41,6 @@ public class SaturnButton extends SaturnWidget {
|
|||||||
|
|
||||||
if (background) {
|
if (background) {
|
||||||
RenderSystem.setShaderTexture(0, Textures.BUTTON);
|
RenderSystem.setShaderTexture(0, Textures.BUTTON);
|
||||||
RenderSystem.texParameter(
|
|
||||||
GL11.GL_TEXTURE_2D,
|
|
||||||
GL11.GL_TEXTURE_MIN_FILTER,
|
|
||||||
GL11.GL_LINEAR_MIPMAP_LINEAR);
|
|
||||||
|
|
||||||
SaturnUi.drawHighResGuiTexture(
|
SaturnUi.drawHighResGuiTexture(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -5,8 +5,13 @@ import net.minecraft.client.gui.DrawContext;
|
|||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
import org.saturnclient.ui.SaturnUi;
|
||||||
|
import org.saturnclient.ui.SaturnWidget;
|
||||||
|
import org.saturnclient.ui.Textures;
|
||||||
|
|
||||||
public class SaturnImageButton extends SaturnButton {
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
public class SaturnImageButton extends SaturnWidget {
|
||||||
|
|
||||||
public Identifier sprite;
|
public Identifier sprite;
|
||||||
public int imageWidth;
|
public int imageWidth;
|
||||||
@@ -14,12 +19,10 @@ public class SaturnImageButton extends SaturnButton {
|
|||||||
public Consumer<SaturnImageButton> onPress;
|
public Consumer<SaturnImageButton> onPress;
|
||||||
|
|
||||||
public SaturnImageButton(
|
public SaturnImageButton(
|
||||||
Identifier sprite,
|
Identifier sprite,
|
||||||
int imageWidth,
|
int imageWidth,
|
||||||
int imageHeight,
|
int imageHeight,
|
||||||
Consumer<SaturnImageButton> onPress
|
Consumer<SaturnImageButton> onPress) {
|
||||||
) {
|
|
||||||
super("", _o -> {});
|
|
||||||
this.sprite = sprite;
|
this.sprite = sprite;
|
||||||
this.imageWidth = imageWidth;
|
this.imageWidth = imageWidth;
|
||||||
this.imageHeight = imageHeight;
|
this.imageHeight = imageHeight;
|
||||||
@@ -27,11 +30,10 @@ public class SaturnImageButton extends SaturnButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SaturnImageButton(
|
public SaturnImageButton(
|
||||||
Identifier sprite,
|
Identifier sprite,
|
||||||
int imageWidth,
|
int imageWidth,
|
||||||
int imageHeight,
|
int imageHeight,
|
||||||
Runnable onPress
|
Runnable onPress) {
|
||||||
) {
|
|
||||||
this(sprite, imageWidth, imageHeight, _o -> {
|
this(sprite, imageWidth, imageHeight, _o -> {
|
||||||
onPress.run();
|
onPress.run();
|
||||||
});
|
});
|
||||||
@@ -39,39 +41,50 @@ public class SaturnImageButton extends SaturnButton {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(
|
public void render(
|
||||||
DrawContext context,
|
DrawContext context,
|
||||||
boolean hovering,
|
boolean hovering,
|
||||||
int mouseX,
|
int mouseX,
|
||||||
int mouseY
|
int mouseY) {
|
||||||
) {
|
int hoverColor = ((int) (alpha * 255) << 24) |
|
||||||
super.render(context, hovering, mouseX, mouseY);
|
(SaturnClient.COLOR.value & 0x00FFFFFF);
|
||||||
|
RenderSystem.setShaderTexture(0, Textures.BUTTON);
|
||||||
|
|
||||||
int hoverColor =
|
SaturnUi.drawHighResGuiTexture(
|
||||||
((int) (alpha * 255) << 24) |
|
context,
|
||||||
(SaturnClient.COLOR.value & 0x00FFFFFF);
|
Textures.BUTTON,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
this.width,
|
||||||
|
this.height,
|
||||||
|
SaturnClient.getWhite(this.alpha));
|
||||||
|
|
||||||
|
if (hovering) {
|
||||||
|
SaturnUi.drawHighResGuiTexture(
|
||||||
|
context,
|
||||||
|
Textures.BUTTON_BORDER,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
this.width,
|
||||||
|
this.height,
|
||||||
|
hoverColor);
|
||||||
|
}
|
||||||
|
|
||||||
context.drawTexture(
|
context.drawTexture(
|
||||||
RenderLayer::getGuiTextured,
|
RenderLayer::getGuiTextured,
|
||||||
sprite,
|
sprite,
|
||||||
((width - imageWidth) / 2),
|
((width - imageWidth) / 2),
|
||||||
((height - imageHeight) / 2),
|
((height - imageHeight) / 2),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
imageWidth,
|
imageWidth,
|
||||||
imageHeight,
|
imageHeight,
|
||||||
imageWidth,
|
imageWidth,
|
||||||
imageHeight,
|
imageHeight,
|
||||||
hovering ? hoverColor : SaturnClient.getWhite(alpha)
|
hovering ? hoverColor : SaturnClient.getWhite(alpha));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void click(int mouseX, int mouseY) {
|
public void click(int mouseX, int mouseY) {
|
||||||
this.onPress.accept(this);
|
this.onPress.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SaturnImageButton setBackground(boolean background) {
|
|
||||||
this.background = background;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user