Skip to content

Commit de24c65

Browse files
committed
Beta 2.2.5.2528.0
-Fixed 1.21.6-7 rendering problems
1 parent 78df3ba commit de24c65

11 files changed

Lines changed: 54 additions & 17 deletions

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
org.gradle.jvmargs=-Xmx3072M
22

33
archives_base_name=FactoryAPI
4-
mod_version=2.2.5.2527.0
4+
mod_version=2.2.5.2528.0
55
mod_id=factory_api
66
mod_name=Factory API
77
mod_description=An API that is the basis for mods like Legacy4J, Factocrafty and Better Furnaces Reforged, that work on different mod loaders.

src/main/java/wily/factoryapi/base/client/AdvancedTextWidget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class AdvancedTextWidget extends SimpleLayoutRenderable implements GuiEve
2323
private int[] heightPerLine = new int[0];
2424
private int lineSpacing = 12;
2525
private boolean centered = false;
26-
private int color = 0xFFFFFF;
26+
private int color = 0xFFFFFFFF;
2727
private boolean shadow = true;
2828
private boolean multipleHeights = true;
2929

src/main/java/wily/factoryapi/base/client/FactoryGuiGraphics.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ default void blitTiledSprite(/*? >=1.21.2 {*/ /*/^? if <1.21.6 {^/Function<Resou
141141
/*context().blit(function,tile,i,j,Math.min(n,p),Math.min(o,q),l,m,p,q,k);*/
142142
}
143143

144+
//? if <1.21.6 {
145+
144146
void setColor(int color, boolean changeBlend);
145147

146148
void setColor(float r, float g, float b, float a, boolean changeBlend);
@@ -164,6 +166,8 @@ default void clearColor(){
164166
clearColor(false);
165167
}
166168

169+
//?}
170+
167171
//? if >=1.21.2 {
168172
/*void setBlitColor(int color);
169173

src/main/java/wily/factoryapi/base/client/UIAccessor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,21 @@ default Renderable createModifiableRenderable(String name, Renderable renderable
210210
if (getElements().get(name+".index") instanceof Bearer<?> b) b.secureCast(Integer.class).set(i1);
211211
FactoryGuiMatrixStack.of(guiGraphics.pose()).pushPose();
212212
int color = getInteger(name+".renderColor", 0xFFFFFFFF);
213+
//? if <1.21.6 {
213214
FactoryScreenUtil.enableBlend();
214215
FactoryGuiGraphics.of(guiGraphics).setColor(color);
216+
//?} else
217+
/*FactoryGuiGraphics.of(guiGraphics).setBlitColor(color);*/
215218
FactoryGuiMatrixStack.of(guiGraphics.pose()).translate(getDouble(name + ".translateX", 0), getDouble(name + ".translateY", 0), getDouble(name + ".translateZ", 0));
216219
FactoryGuiMatrixStack.of(guiGraphics.pose()).scale(getFloat(name + ".scaleX", 1), getFloat(name + ".scaleY", 1), getFloat(name + ".scaleZ", 1));
217220
renderable.render(guiGraphics, i, j, f);
218221
FactoryGuiMatrixStack.of(guiGraphics.pose()).popPose();
219222
FactoryScreenUtil.disableBlend();
223+
//? if <1.21.6 {
220224
FactoryGuiGraphics.of(guiGraphics).clearColor();
225+
//?} else
226+
/*FactoryGuiGraphics.of(guiGraphics).clearBlitColor();*/
227+
221228
}
222229
};
223230
}

src/main/java/wily/factoryapi/base/client/UIDefinitionManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static void parseTextElements(UIDefinition uiDefinition, String elementName, Dyn
342342
static void parseDrawStringElements(UIDefinition uiDefinition, Function<UIAccessor, UIAccessor> accessorFunction, String elementName, Dynamic<?> element) {
343343
parseTextElements(uiDefinition, elementName, element);
344344
parseTranslationElements(uiDefinition, elementName, element);
345-
uiDefinition.getDefinitions().add(UIDefinition.createAfterInit(elementName, a -> accessorFunction.apply(a).addRenderable(elementName, (a.createModifiableRenderable(elementName, (guiGraphics, i, j, f) -> a.getElement(elementName + ".component", Component.class).ifPresent(c -> guiGraphics.drawString(Minecraft.getInstance().font, c, a.getInteger(elementName + ".x", 0), a.getInteger(elementName + ".y", 0), a.getInteger(elementName + ".color", 0xFFFFFF), a.getBoolean(elementName + ".shadow", true))))))));
345+
uiDefinition.getDefinitions().add(UIDefinition.createAfterInit(elementName, a -> accessorFunction.apply(a).addRenderable(elementName, (a.createModifiableRenderable(elementName, (guiGraphics, i, j, f) -> a.getElement(elementName + ".component", Component.class).ifPresent(c -> guiGraphics.drawString(Minecraft.getInstance().font, c, a.getInteger(elementName + ".x", 0), a.getInteger(elementName + ".y", 0), a.getInteger(elementName + ".color", 0xFFFFFFFF), a.getBoolean(elementName + ".shadow", true))))))));
346346
}
347347

348348
static void parseDrawMultilineStringElements(UIDefinition uiDefinition, Function<UIAccessor, UIAccessor> accessorFunction, String elementName, Dynamic<?> element) {
@@ -353,7 +353,7 @@ static void parseDrawMultilineStringElements(UIDefinition uiDefinition, Function
353353
a.getElement(elementName+".component", Component.class).ifPresent(c-> {
354354
int lineSpacing = a.getInteger(elementName+".lineSpacing", 12);
355355
int width = a.getInteger(elementName+".width", 0);
356-
AdvancedTextWidget advancedTextWidget = a.putLayoutElement(elementName, accessorFunction.apply(a).addChild(elementName, new AdvancedTextWidget(a).lineSpacing(lineSpacing).withLines(c,width).withColor(a.getInteger(elementName + ".color", 0xFFFFFF)).withShadow(a.getBoolean(elementName + ".shadow", true)).centered(a.getBoolean(elementName + ".centered", false))), i-> {}, i->{});
356+
AdvancedTextWidget advancedTextWidget = a.putLayoutElement(elementName, accessorFunction.apply(a).addChild(elementName, new AdvancedTextWidget(a).lineSpacing(lineSpacing).withLines(c,width).withColor(a.getInteger(elementName + ".color", 0xFFFFFFFF)).withShadow(a.getBoolean(elementName + ".shadow", true)).centered(a.getBoolean(elementName + ".centered", false))), i-> {}, i->{});
357357
a.putStaticElement(elementName+".linesCount", advancedTextWidget.getLines().size());
358358
});
359359
}));

src/main/java/wily/factoryapi/base/client/drawable/AbstractDrawableButton.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,26 @@ public void draw(GuiGraphics graphics) {
8686
@Override
8787
public void draw(GuiGraphics graphics, int x, int y) {
8888
if (color != null)
89-
FactoryGuiGraphics.of(graphics).setColor(color.getRed() / 255F,color.getGreen() / 255F, color.getBlue() / 255F, 1F);
89+
//? if <1.21.6 {
90+
FactoryGuiGraphics.of(graphics).setColor(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1.0F);
91+
//?} else
92+
/*FactoryGuiGraphics.of(graphics).setBlitColor(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1F);*/
9093
super.draw(graphics, x, y);
91-
FactoryGuiGraphics.of(graphics).setColor(1, 1, 1, FactoryGuiGraphics.of(graphics).getColor()[3]);
94+
if (color != null)
95+
//? if <1.21.6 {
96+
FactoryGuiGraphics.of(graphics).clearColor();
97+
//?} else
98+
/*FactoryGuiGraphics.of(graphics).clearBlitColor();*/
9299
if (isSelected() || hovered && hoverSelection) {
93100
if (selection != null) selection.draw(graphics, x, y);
94101
else graphics.renderOutline(x, y, width(), height(), -1);
95102
}
96103
}
104+
97105
public ScreenRectangle getRectangle() {
98106
return FactoryScreenUtil.rect2iToRectangle(this);
99107
}
108+
100109
public boolean isSelected(){
101110
return selected == Boolean.TRUE;
102111
}

src/main/java/wily/factoryapi/mixin/base/AbstractButtonMixin.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,15 @@ public void renderString(GuiGraphics guiGraphics, Font font, int i, CallbackInfo
4444
ResourceLocation sprite = getSpriteOverride();
4545
if (sprite != null) {
4646
FactoryScreenUtil.enableBlend();
47-
FactoryGuiGraphics.of(guiGraphics).setColor(1.0f,1.0f,1.0f, alpha);
47+
//? if <1.21.6 {
48+
FactoryGuiGraphics.of(guiGraphics).setColor(1.0f, 1.0f, 1.0f, alpha);
49+
//?} else
50+
/*FactoryGuiGraphics.of(guiGraphics).setBlitColor(1.0f, 1.0f, 1.0f, alpha);*/
4851
FactoryGuiGraphics.of(guiGraphics).blitSprite(sprite, getX(), getY(), getWidth(), getHeight());
49-
FactoryGuiGraphics.of(guiGraphics).setColor(1.0f,1.0f,1.0f,1.0f);
52+
//? if <1.21.6 {
53+
FactoryGuiGraphics.of(guiGraphics).clearColor();
54+
//?} else
55+
/*FactoryGuiGraphics.of(guiGraphics).clearBlitColor();*/
5056
FactoryScreenUtil.disableBlend();
5157
}
5258
}

src/main/java/wily/factoryapi/mixin/base/GuiGraphicsMixin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ public void enableScissor(int x, int y, int xd, int yd, boolean matrixAffects) {
220220
*///?}
221221
}
222222

223+
//? if <1.21.6 {
223224
@Override
224225
public void setColor(int color, boolean changeBlend) {
225226
setColor(ColorUtil.getRed(color), ColorUtil.getGreen(color), ColorUtil.getBlue(color), ColorUtil.getAlpha(color), changeBlend);
@@ -231,13 +232,11 @@ public void setColor(float r, float g, float b, float a, boolean changeBlend) {
231232
if (a < 1) FactoryScreenUtil.enableBlend();
232233
else FactoryScreenUtil.disableBlend();
233234
}
234-
//? if <1.21.6 {
235235
//? if >=1.21.2 {
236236
/*context().flush();
237-
RenderSystem.setShaderColor(r,g,b,a);
237+
RenderSystem.setShaderColor(r, g, b, a);
238238
*///?} else {
239-
context().setColor(r,g,b,a);
240-
//?}
239+
context().setColor(r, g, b, a);
241240
//?}
242241
}
243242

@@ -249,6 +248,7 @@ public float[] getColor() {
249248
return RenderSystem.getShaderColor();
250249
//?}
251250
}
251+
//?}
252252

253253
//? if >=1.21.2 {
254254
/*@Override

src/main/java/wily/factoryapi/util/FactoryGuiElement.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public void finalizeRender(GuiGraphics graphics, UIAccessor accessor){
9191
modifiedPost.invoker.render(graphics);
9292
int color = getColor(accessor);
9393
FactoryGuiMatrixStack.of(graphics.pose()).popPose();
94+
//? if >=1.21.6 {
95+
/*if (color != -1) FactoryGuiGraphics.of(graphics).clearBlitColor();
96+
*///?} else
9497
if (color != -1) FactoryGuiGraphics.of(graphics).clearColor(true);
9598
post.invoker.render(graphics);
9699
}

src/main/java/wily/factoryapi/util/FactoryScreenUtil.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,18 @@ public static boolean isMouseOver(double mouseX, double mouseY, int posX, int po
201201
return (mouseX >= posX && mouseX < posX + sizeX && mouseY >= posY && mouseY < posY + sizeY);
202202
}
203203

204-
public static void applyOffset(GuiGraphics graphics, float x, float y, float z){
204+
public static void applyOffset(GuiGraphics graphics, float x, float y, float z) {
205205
if (x != 0 || y != 0 | z != 0) FactoryGuiMatrixStack.of(graphics.pose()).translate(x, y, z);
206206
}
207207

208-
public static void applyScale(GuiGraphics graphics, float x, float y, float z){
208+
public static void applyScale(GuiGraphics graphics, float x, float y, float z) {
209209
if (x != 1 || y != 1 || z != 1) FactoryGuiMatrixStack.of(graphics.pose()).scale(x, y, z);
210210
}
211211

212-
public static void applyColor(GuiGraphics graphics, int color){
212+
public static void applyColor(GuiGraphics graphics, int color) {
213+
//? if >=1.21.6 {
214+
/*if (color != -1) FactoryGuiGraphics.of(graphics).setBlitColor(color);
215+
*///?} else
213216
if (color != -1) FactoryGuiGraphics.of(graphics).setColor(color, true);
214217
}
215218

0 commit comments

Comments
 (0)