Skip to content

Commit 14f264e

Browse files
authored
1.21.5 (#63)
Removes support for label backgrounds until we get it working again.
1 parent d49b1a5 commit 14f264e

File tree

16 files changed

+158
-398
lines changed

16 files changed

+158
-398
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "fabric-loom" version "1.8-SNAPSHOT"
2+
id "fabric-loom" version "1.10-SNAPSHOT"
33
// id "org.ajoberstar.grgit" version "3.1.1"
44
}
55

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/win/baruna/blockmeter/ModConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class ModConfig implements ConfigData {
1313
@ConfigEntry.Gui.Tooltip(count = 3)
1414
public boolean sendBoxes = true;
1515
public boolean showBoxesWhenDisabled = false;
16+
@ConfigEntry.Gui.Excluded
1617
public boolean backgroundForLabels = true;
1718

1819
@ConfigEntry.BoundedDiscrete(max=200, min = 7)

src/main/java/win/baruna/blockmeter/gui/OptionsGui.java

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
import me.shedaniel.math.Color;
55
import net.minecraft.client.MinecraftClient;
66
import net.minecraft.client.font.TextRenderer;
7-
import net.minecraft.client.gl.ShaderProgramKey;
8-
import net.minecraft.client.gl.ShaderProgramKeys;
7+
//import net.minecraft.client.gl.ShaderProgramKey;
8+
//import net.minecraft.client.gl.ShaderProgramKeys;
99
import net.minecraft.client.gui.DrawContext;
10+
import net.minecraft.client.gui.screen.ButtonTextures;
1011
import net.minecraft.client.gui.screen.Screen;
1112
import net.minecraft.client.gui.widget.ButtonWidget;
1213
import net.minecraft.client.render.*;
1314
import net.minecraft.client.util.NarratorManager;
1415
import net.minecraft.text.MutableText;
1516
import net.minecraft.text.Text;
1617
import net.minecraft.util.DyeColor;
18+
import net.minecraft.util.Identifier;
1719
import win.baruna.blockmeter.BlockMeterClient;
1820
import win.baruna.blockmeter.ModConfig;
1921
import win.baruna.blockmeter.measurebox.ClientMeasureBox;
@@ -36,14 +38,14 @@ protected void init() {
3638
final int colorIndex = i * 4 + j;
3739
this.addDrawableChild(new ColorButton(this.width / 2 - 44 + j * 22,
3840
this.height / 2 - 88 + i * 22, 20, 20, null,
39-
Color.ofOpaque(DyeColor.byId(colorIndex)
41+
Color.ofOpaque(DyeColor.byIndex(colorIndex)
4042
.getMapColor().color), config.colorIndex == colorIndex, false,
4143
button -> {
4244
ClientMeasureBox.setColorIndex(colorIndex);
4345

4446
final ClientMeasureBox currentBox = BlockMeterClient.getInstance().getCurrentBox();
4547
if (currentBox != null)
46-
currentBox.setColor(DyeColor.byId(colorIndex));
48+
currentBox.setColor(DyeColor.byIndex(colorIndex));
4749
MinecraftClient.getInstance().setScreen(null);
4850
}));
4951
}
@@ -107,6 +109,9 @@ class ColorButton extends ButtonWidget {
107109
boolean selected;
108110
boolean texture;
109111
MutableText text;
112+
private static final ButtonTextures TEXTURES = new ButtonTextures(
113+
Identifier.ofVanilla("widget/button"), Identifier.ofVanilla("widget/button_disabled"), Identifier.ofVanilla("widget/button_highlighted")
114+
);
110115

111116
@Override
112117
public void onPress() {
@@ -136,23 +141,28 @@ public void onPress() {
136141
@Override
137142
public void renderWidget(DrawContext context, final int int_1, final int int_2, final float float_1) {
138143

139-
Tessellator tessellator = Tessellator.getInstance();
140-
var bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
141-
RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
142-
143-
int r = this.color.getRed();
144-
int g = this.color.getGreen();
145-
int b = this.color.getBlue();
146-
int a = texture ? 102 : 255;
147-
bufferBuilder.vertex(this.x - (texture ? 1 : 0), this.y - (texture ? 1 : 0), 0f)
148-
.color(r, g, b, a);
149-
bufferBuilder.vertex(this.x - (texture ? 1 : 0), this.y + this.height + (texture ? 1 : 0), 0f)
150-
.color(r, g, b, a);
151-
bufferBuilder.vertex(this.x + this.width + (texture ? 1 : 0), this.y + this.height + (texture ? 1 : 0), 0f)
152-
.color(r, g, b, a);
153-
bufferBuilder.vertex(this.x + this.width + (texture ? 1 : 0), this.y - (texture ? 1 : 0), 0f)
154-
.color(r, g, b, a);
155-
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
144+
context.drawGuiTexture(
145+
RenderLayer::getGuiTextured,
146+
TEXTURES.get(this.active, this.isSelected()),
147+
x, y, width, height, color.getColor()
148+
);
149+
// Tessellator tessellator = Tessellator.getInstance();
150+
// var bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
151+
// RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
152+
//
153+
// int r = this.color.getRed();
154+
// int g = this.color.getGreen();
155+
// int b = this.color.getBlue();
156+
// int a = texture ? 102 : 255;
157+
// bufferBuilder.vertex(this.x - (texture ? 1 : 0), this.y - (texture ? 1 : 0), 0f)
158+
// .color(r, g, b, a);
159+
// bufferBuilder.vertex(this.x - (texture ? 1 : 0), this.y + this.height + (texture ? 1 : 0), 0f)
160+
// .color(r, g, b, a);
161+
// bufferBuilder.vertex(this.x + this.width + (texture ? 1 : 0), this.y + this.height + (texture ? 1 : 0), 0f)
162+
// .color(r, g, b, a);
163+
// bufferBuilder.vertex(this.x + this.width + (texture ? 1 : 0), this.y - (texture ? 1 : 0), 0f)
164+
// .color(r, g, b, a);
165+
// BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
156166

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

0 commit comments

Comments
 (0)