diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 8f2b15f..63a5e23 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -447,3 +447,59 @@ jobs: name: ${{github.ref_name}}-1.20.6 - Fabric files: 'versions/1.20.6-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar' game-versions: 1.20.6 + - name: Publish-1.21-fabric-Curseforge + uses: Kir-Antipov/mc-publish@v3.3.0 + with: + curseforge-id: 521480 + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + loaders: fabric + name: ${{github.ref_name}}-1.21 - Fabric + files: 'versions/1.21-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar' + game-versions: 1.21 + - name: Publish-1.21-fabric-Modrinth + uses: Kir-Antipov/mc-publish@v3.3.0 + with: + modrinth-id: zV5r3pPn + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + loaders: fabric + name: ${{github.ref_name}}-1.21 - Fabric + files: 'versions/1.21-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar' + game-versions: 1.21 + - name: Publish-1.21-forge-Curseforge + uses: Kir-Antipov/mc-publish@v3.3.0 + with: + curseforge-id: 521480 + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + loaders: forge + name: ${{github.ref_name}}-1.21 - Forge + version-type: beta + files: 'versions/1.21-forge/build/libs/!(*-@(dev|sources|javadoc|all)).jar' + game-versions: 1.21 + - name: Publish-1.21-forge-Modrinth + uses: Kir-Antipov/mc-publish@v3.3.0 + with: + modrinth-id: zV5r3pPn + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + loaders: forge + name: ${{github.ref_name}}-1.21 - Forge + files: 'versions/1.21-forge/build/libs/!(*-@(dev|sources|javadoc|all)).jar' + game-versions: 1.21 + - name: Publish-1.21-neoforge-Curseforge + uses: Kir-Antipov/mc-publish@v3.3.0 + with: + curseforge-id: 521480 + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + loaders: neoforge + name: ${{github.ref_name}}-1.21 - NeoForge + version-type: beta + files: 'versions/1.21-neoforge/build/libs/!(*-@(dev|sources|javadoc|all)).jar' + game-versions: 1.21 + - name: Publish-1.21-neoforge-Modrinth + uses: Kir-Antipov/mc-publish@v3.3.0 + with: + modrinth-id: zV5r3pPn + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + loaders: neoforge + name: ${{github.ref_name}}-1.21 - NeoForge + files: 'versions/1.21-neoforge/build/libs/!(*-@(dev|sources|javadoc|all)).jar' + game-versions: 1.21 diff --git a/settings.json b/settings.json index f483c2a..927f873 100644 --- a/settings.json +++ b/settings.json @@ -22,6 +22,9 @@ "1.20.4-fabric", "1.20.6-forge", "1.20.6-neoforge", - "1.20.6-fabric" + "1.20.6-fabric", + "1.21-fabric", + "1.21-forge", + "1.21-neoforge" ] } diff --git a/src/main/java/dev/tr7zw/skinlayers/api/Mesh.java b/src/main/java/dev/tr7zw/skinlayers/api/Mesh.java index 32db474..cc1fb11 100644 --- a/src/main/java/dev/tr7zw/skinlayers/api/Mesh.java +++ b/src/main/java/dev/tr7zw/skinlayers/api/Mesh.java @@ -28,7 +28,7 @@ public void setPosition(float x, float y, float z) { @Override public void render(ModelPart vanillaModel, PoseStack poseStack, VertexConsumer vertexConsumer, int light, - int overlay, float red, float green, float blue, float alpha) { + int overlay, int color) { } @Override @@ -52,11 +52,14 @@ public void copyFrom(ModelPart modelPart) { }; public default void render(PoseStack poseStack, VertexConsumer vertexConsumer, int light, int overlay) { - render(null, poseStack, vertexConsumer, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F); + render(null, poseStack, vertexConsumer, light, overlay, 0xFFFFFFFF); } + /** + * @param color The color, in ARGB format + */ public void render(ModelPart vanillaModel, PoseStack poseStack, VertexConsumer vertexConsumer, int light, - int overlay, float red, float green, float blue, float alpha); + int overlay, int color); public void setPosition(float x, float y, float z); diff --git a/src/main/java/dev/tr7zw/skinlayers/render/CustomizableModelPart.java b/src/main/java/dev/tr7zw/skinlayers/render/CustomizableModelPart.java index bec2675..1fb0106 100644 --- a/src/main/java/dev/tr7zw/skinlayers/render/CustomizableModelPart.java +++ b/src/main/java/dev/tr7zw/skinlayers/render/CustomizableModelPart.java @@ -76,15 +76,52 @@ public void render(PoseStack poseStack, VertexConsumer vertexConsumer, int i, in render(null, poseStack, vertexConsumer, i, j, 1.0F, 1.0F, 1.0F, 1.0F); } + private int convertFloatColorToInteger(float color) { + return color > 1F ? 255 : Math.round(color * 255F); + } + + /** + * Kept for some mod (like ETF) shadowing the old render method to call + */ + @Deprecated(forRemoval = true) public void render(ModelPart vanillaModel, PoseStack poseStack, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) { + var color = (convertFloatColorToInteger(alpha) & 0xFF) << 24 | (convertFloatColorToInteger(red) & 0xFF) << 16 + | (convertFloatColorToInteger(green) & 0xFF) << 8 | convertFloatColorToInteger(blue) & 0xFF; + + render(vanillaModel, poseStack, vertexConsumer, light, overlay, color); + } + + /** + * @param color Color, in ARGB format + */ + public void render(ModelPart vanillaModel, PoseStack poseStack, VertexConsumer vertexConsumer, int light, + int overlay, int color) { if (!this.visible) return; poseStack.pushPose(); translateAndRotate(poseStack); - compile(vanillaModel, poseStack.last(), vertexConsumer, light, overlay, red, green, blue, alpha); - for (ModelPart modelPart : this.children.values()) - modelPart.render(poseStack, vertexConsumer, light, overlay, red, green, blue, alpha); + compile(vanillaModel, poseStack.last(), vertexConsumer, light, overlay, color); + + // spotless:off + //#if MC < 12100 + //$$ float r,g,b,a; + //$$ a = ((color >> 24) & 0xFF) / 255F; + //$$ r = ((color >> 16) & 0xFF) / 255F; + //$$ g = ((color >> 8) & 0xFF) / 255F; + //$$ b = (color & 0xFF) / 255F; + //#endif + //spotless:on + + for (ModelPart modelPart : this.children.values()) { + // spotless:off + //#if MC >= 12100 + modelPart.render(poseStack, vertexConsumer, light, overlay, color); + //#else + //$$ modelPart.render(poseStack, vertexConsumer, light, overlay, r, g, b, a); + //#endif + //spotless:on + } poseStack.popPose(); } @@ -109,11 +146,22 @@ public void translateAndRotate(PoseStack poseStack) { private Vector4f vector4f[] = new Vector4f[] { new Vector4f(), new Vector4f(), new Vector4f(), new Vector4f() }; private void compile(ModelPart vanillaModel, PoseStack.Pose pose, VertexConsumer vertexConsumer, int light, - int overlay, float red, float green, float blue, float alpha) { + int overlay, int color) { MeshTransformer transformer = SkinLayersAPI.getMeshTransformerProvider().prepareTransformer(vanillaModel); // compacted Cubes Matrix4f matrix4f = pose.pose(); Matrix3f matrix3f = pose.normal(); + + // spotless:off + //#if MC < 12100 + //$$ float red,green,blue,alpha; + //$$ alpha = ((color >> 24) & 0xFF) / 255F; + //$$ red = ((color >> 16) & 0xFF) / 255F; + //$$ green = ((color >> 8) & 0xFF) / 255F; + //$$ blue = (color & 0xFF) / 255F; + //#endif + //spotless:on + for (int id = 0; id < polygonData.length; id += polyDataSize) { Vector3f vector3f = new Vector3f(polygonData[id + 0], polygonData[id + 1], polygonData[id + 2]); for (int o = 0; o < 4; o++) { @@ -133,10 +181,21 @@ private void compile(ModelPart vanillaModel, PoseStack.Pose pose, VertexConsumer //$$ for (int o = 0; o < 4; o++) { //$$ vector4f[o].transform(matrix4f); //#endif - //spotless:on - vertexConsumer.vertex(vector4f[o].x(), vector4f[o].y(), vector4f[o].z(), red, green, blue, alpha, - polygonData[id + 3 + (o * 5) + 3], polygonData[id + 3 + (o * 5) + 4], overlay, light, - vector3f.x(), vector3f.y(), vector3f.z()); + //#if MC >= 12100 + vertexConsumer.addVertex(vector4f[o].x(), vector4f[o].y(), vector4f[o].z()); + vertexConsumer.setColor(color); + vertexConsumer.setUv(polygonData[id + 3 + (o * 5) + 3], polygonData[id + 3 + (o * 5) + 4]); + vertexConsumer.setOverlay(overlay); + vertexConsumer.setLight(light); + vertexConsumer.setNormal(vector3f.x(), vector3f.y(), vector3f.z()); + //#else + //$$ vertexConsumer.vertex(vector4f[o].x(), vector4f[o].y(), vector4f[o].z(), + //$$ red, green, blue, alpha, + //$$ polygonData[id + 3 + (o * 5) + 3], polygonData[id + 3 + (o * 5) + 4], + //$$ overlay, light, + //$$ vector3f.x(), vector3f.y(), vector3f.z()); + //#endif + //spotless:on } } @@ -144,8 +203,10 @@ private void compile(ModelPart vanillaModel, PoseStack.Pose pose, VertexConsumer for (Cube cube : this.cubes) { transformer.transform(cube); // spotless:off - //#if MC >= 11700 - cube.compile(pose, vertexConsumer, light, overlay, red, green, blue, alpha); + //#if MC >= 12100 + cube.compile(pose, vertexConsumer, light, overlay, color); + //#elseif MC >= 11700 + //$$ cube.compile(pose, vertexConsumer, light, overlay, red, green, blue, alpha); //#else //$$ for (ModelPart.Polygon polygon : cube.polygons) { //$$ Vector3f vector3f = polygon.normal.copy(); diff --git a/src/main/java/dev/tr7zw/skinlayers/renderlayers/CustomLayerFeatureRenderer.java b/src/main/java/dev/tr7zw/skinlayers/renderlayers/CustomLayerFeatureRenderer.java index b850a38..1fe4e29 100644 --- a/src/main/java/dev/tr7zw/skinlayers/renderlayers/CustomLayerFeatureRenderer.java +++ b/src/main/java/dev/tr7zw/skinlayers/renderlayers/CustomLayerFeatureRenderer.java @@ -137,7 +137,7 @@ public void renderLayers(AbstractClientPlayer abstractClientPlayer, PlayerSettin mesh.setPosition(x, y, 0); - mesh.render(layer.vanillaGetter.get(), matrixStack, vertices, light, overlay, 1.0f, 1.0f, 1.0f, 1.0f); + mesh.render(layer.vanillaGetter.get(), matrixStack, vertices, light, overlay, 0xFFFFFFFF); matrixStack.popPose(); } } diff --git a/versions/mainProject b/versions/mainProject index 304eaac..dfdd511 100644 --- a/versions/mainProject +++ b/versions/mainProject @@ -1 +1 @@ -1.20.6-fabric \ No newline at end of file +1.21-fabric \ No newline at end of file