Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "fabric-loom" version "1.8-SNAPSHOT"
id "fabric-loom" version "1.10-SNAPSHOT"
// id "org.ajoberstar.grgit" version "3.1.1"
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
1 change: 1 addition & 0 deletions src/main/java/win/baruna/blockmeter/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ModConfig implements ConfigData {
@ConfigEntry.Gui.Tooltip(count = 3)
public boolean sendBoxes = true;
public boolean showBoxesWhenDisabled = false;
@ConfigEntry.Gui.Excluded
public boolean backgroundForLabels = true;

@ConfigEntry.BoundedDiscrete(max=200, min = 7)
Expand Down
52 changes: 31 additions & 21 deletions src/main/java/win/baruna/blockmeter/gui/OptionsGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
import me.shedaniel.math.Color;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gl.ShaderProgramKey;
import net.minecraft.client.gl.ShaderProgramKeys;
//import net.minecraft.client.gl.ShaderProgramKey;
//import net.minecraft.client.gl.ShaderProgramKeys;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ButtonTextures;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.render.*;
import net.minecraft.client.util.NarratorManager;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
import win.baruna.blockmeter.BlockMeterClient;
import win.baruna.blockmeter.ModConfig;
import win.baruna.blockmeter.measurebox.ClientMeasureBox;
Expand All @@ -36,14 +38,14 @@ protected void init() {
final int colorIndex = i * 4 + j;
this.addDrawableChild(new ColorButton(this.width / 2 - 44 + j * 22,
this.height / 2 - 88 + i * 22, 20, 20, null,
Color.ofOpaque(DyeColor.byId(colorIndex)
Color.ofOpaque(DyeColor.byIndex(colorIndex)
.getMapColor().color), config.colorIndex == colorIndex, false,
button -> {
ClientMeasureBox.setColorIndex(colorIndex);

final ClientMeasureBox currentBox = BlockMeterClient.getInstance().getCurrentBox();
if (currentBox != null)
currentBox.setColor(DyeColor.byId(colorIndex));
currentBox.setColor(DyeColor.byIndex(colorIndex));
MinecraftClient.getInstance().setScreen(null);
}));
}
Expand Down Expand Up @@ -107,6 +109,9 @@ class ColorButton extends ButtonWidget {
boolean selected;
boolean texture;
MutableText text;
private static final ButtonTextures TEXTURES = new ButtonTextures(
Identifier.ofVanilla("widget/button"), Identifier.ofVanilla("widget/button_disabled"), Identifier.ofVanilla("widget/button_highlighted")
);

@Override
public void onPress() {
Expand Down Expand Up @@ -136,23 +141,28 @@ public void onPress() {
@Override
public void renderWidget(DrawContext context, final int int_1, final int int_2, final float float_1) {

Tessellator tessellator = Tessellator.getInstance();
var bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);

int r = this.color.getRed();
int g = this.color.getGreen();
int b = this.color.getBlue();
int a = texture ? 102 : 255;
bufferBuilder.vertex(this.x - (texture ? 1 : 0), this.y - (texture ? 1 : 0), 0f)
.color(r, g, b, a);
bufferBuilder.vertex(this.x - (texture ? 1 : 0), this.y + this.height + (texture ? 1 : 0), 0f)
.color(r, g, b, a);
bufferBuilder.vertex(this.x + this.width + (texture ? 1 : 0), this.y + this.height + (texture ? 1 : 0), 0f)
.color(r, g, b, a);
bufferBuilder.vertex(this.x + this.width + (texture ? 1 : 0), this.y - (texture ? 1 : 0), 0f)
.color(r, g, b, a);
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
context.drawGuiTexture(
RenderLayer::getGuiTextured,
TEXTURES.get(this.active, this.isSelected()),
x, y, width, height, color.getColor()
);
// Tessellator tessellator = Tessellator.getInstance();
// var bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
// RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
//
// int r = this.color.getRed();
// int g = this.color.getGreen();
// int b = this.color.getBlue();
// int a = texture ? 102 : 255;
// bufferBuilder.vertex(this.x - (texture ? 1 : 0), this.y - (texture ? 1 : 0), 0f)
// .color(r, g, b, a);
// bufferBuilder.vertex(this.x - (texture ? 1 : 0), this.y + this.height + (texture ? 1 : 0), 0f)
// .color(r, g, b, a);
// bufferBuilder.vertex(this.x + this.width + (texture ? 1 : 0), this.y + this.height + (texture ? 1 : 0), 0f)
// .color(r, g, b, a);
// bufferBuilder.vertex(this.x + this.width + (texture ? 1 : 0), this.y - (texture ? 1 : 0), 0f)
// .color(r, g, b, a);
// BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

if (text != null) {
boolean dark = (0.299f * color.getRed() + 0.587f * color.getBlue() + 0.114f * color.getRed()) / 255f < 0.8f;
Expand Down
Loading