Skip to content

Commit

Permalink
Merge pull request #158 from MATRIX-feather/1.21
Browse files Browse the repository at this point in the history
Minecraft 1.21
  • Loading branch information
tr7zw authored Jun 14, 2024
2 parents 0f60972 + 6137b28 commit 5b65193
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 16 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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
5 changes: 4 additions & 1 deletion settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
9 changes: 6 additions & 3 deletions src/main/java/dev/tr7zw/skinlayers/api/Mesh.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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++) {
Expand All @@ -133,19 +181,32 @@ 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
}
}

// other cubes
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion versions/mainProject
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.20.6-fabric
1.21-fabric

0 comments on commit 5b65193

Please sign in to comment.