diff --git a/src/main/java/io/wispforest/owo/ui/core/Size.java b/src/main/java/io/wispforest/owo/ui/core/Size.java index e2fb83f1..f835825d 100644 --- a/src/main/java/io/wispforest/owo/ui/core/Size.java +++ b/src/main/java/io/wispforest/owo/ui/core/Size.java @@ -1,7 +1,6 @@ package io.wispforest.owo.ui.core; import io.wispforest.endec.Endec; -import io.wispforest.endec.StructEndec; import io.wispforest.endec.impl.StructEndecBuilder; import org.jetbrains.annotations.ApiStatus; @@ -14,7 +13,11 @@ */ public record Size(int width, int height) { - public static final Endec ENDEC = createEndec("width", "height"); + public static final Endec ENDEC =StructEndecBuilder.of( + Endec.INT.fieldOf("width", Size::width), + Endec.INT.fieldOf("height", Size::height), + Size::of + ); private static final Size ZERO = new Size(0, 0); @@ -36,12 +39,4 @@ public static Size square(int sideLength) { public static Size zero() { return ZERO; } - - public static StructEndec createEndec(String widthName, String heightName) { - return StructEndecBuilder.of( - Endec.INT.fieldOf(widthName, Size::width), - Endec.INT.fieldOf(heightName, Size::height), - Size::of - ); - } } diff --git a/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java b/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java index 651be89b..5905b898 100644 --- a/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java +++ b/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java @@ -211,7 +211,11 @@ private static void ifPresent(Identifier texture, Consumer act Endec.INT.optionalFieldOf("u", (texture) -> texture.u, 0), Endec.INT.optionalFieldOf("v", (texture) -> texture.v, 0), PatchSizing.ENDEC.flatFieldOf((texture) -> texture.patchSizing), - Size.createEndec("texture_width", "texture_height").flatFieldOf((texture) -> texture.textureSize), + StructEndecBuilder.of( + Endec.INT.fieldOf("texture_width", Size::width), + Endec.INT.fieldOf("texture_height", Size::height), + Size::of + ).flatFieldOf((texture) -> texture.textureSize), Endec.BOOLEAN.fieldOf("repeat", (texture) -> texture.repeat), NinePatchTexture::new );