diff --git a/.github/workflows/multi_publish.yml b/.github/workflows/multi_publish.yml new file mode 100644 index 0000000000..4f5c052211 --- /dev/null +++ b/.github/workflows/multi_publish.yml @@ -0,0 +1,130 @@ +name: Publish Multiple Releases +run-name: Publish v${{ github.event.inputs.wurst_version }} build(s) from ${{ github.event.inputs.branches }} + +on: + workflow_dispatch: + inputs: + wurst_version: + description: "Wurst version (without v or -MC)" + required: true + type: string + branches: + description: "Space-separated list of branches to publish from" + required: true + type: string + announce_ports: + description: "Announce as ports on WurstForum" + required: true + type: boolean + default: false + dry_run: + description: "Dry-run mode (don't actually publish anything)" + required: false + type: boolean + default: false + +permissions: + # Needed to trigger the publish workflow. + actions: write + +jobs: + + prepare: + runs-on: ubuntu-latest + outputs: + branches: ${{ steps.set_branches.outputs.branches }} + steps: + - name: Convert branches input to JSON array + id: set_branches + run: | + branches_array=(${{ inputs.branches }}) + quoted_branches=$(printf '"%s",' "${branches_array[@]}") + JSON_ARRAY="[${quoted_branches%,}]" + echo "branches=$JSON_ARRAY" >> "$GITHUB_OUTPUT" + echo "Branches: $JSON_ARRAY" >> "$GITHUB_STEP_SUMMARY" + + publish_each: + runs-on: ubuntu-latest + needs: prepare + if: ${{ !fromJson(inputs.dry_run) }} + strategy: + # Each job pushes an automated commit to WurstClient.net@master, so running them all in parallel + # would likely cause conflicts. Also, various servers might hit rate limits if we just upload + # all of the files at once. + max-parallel: 1 + # If something goes wrong, all published files have to be manually deleted. + # Best to fail as early as possible. + fail-fast: true + matrix: + branch: ${{ fromJson(needs.prepare.outputs.branches) }} + # TODO: Maybe also verify that the wurst_version in each branch is as expected before publishing? + steps: + - name: Build publish inputs + id: publish_inputs + run: | + JSON_STRING=$(cat << EOF + { + "close_milestone": "true", + "upload_backups": "true", + "publish_github": "true", + "update_website": "true" + } + EOF + ) + # Convert to single line and escape quotes + echo "json=${JSON_STRING//$'\n'/}" >> "$GITHUB_OUTPUT" + - name: Trigger publish workflow + id: publish_dispatch + uses: codex-/return-dispatch@v2 + with: + token: ${{ github.token }} + owner: Wurst-Imperium + repo: Wurst7 + ref: ${{ matrix.branch }} + workflow: publish.yml + workflow_inputs: ${{ steps.publish_inputs.outputs.json }} + - name: Wait for publish workflow to finish (run ${{ steps.publish_dispatch.outputs.run_id }}) + uses: codex-/await-remote-run@v1 + with: + token: ${{ github.token }} + owner: Wurst-Imperium + repo: Wurst7 + run_id: ${{ steps.publish_dispatch.outputs.run_id }} + run_timeout_seconds: 600 # 10 minutes + + announce: + runs-on: ubuntu-latest + needs: [prepare, publish_each] + if: ${{ !failure() && !cancelled() && inputs.announce_ports }} + steps: + - name: Build announcement inputs + id: announce_inputs + run: | + JSON_STRING=$(cat << EOF + { + "wurst_version": "${{ inputs.wurst_version }}", + "branches": "${{ inputs.branches }}", + "dry_run": "${{ inputs.dry_run }}" + } + EOF + ) + # Convert to single line and escape quotes + echo "json=${JSON_STRING//$'\n'/}" >> "$GITHUB_OUTPUT" + - name: Trigger announce workflow + id: announce_dispatch + uses: codex-/return-dispatch@v2 + with: + token: ${{ secrets.WURSTCLIENT_NET_PUBLISH_TOKEN }} + owner: Wurst-Imperium + repo: WurstClient.net + ref: gh-pages + workflow: announce_wurst_ports.yml + workflow_inputs: ${{ steps.announce_inputs.outputs.json }} + - name: Wait for announce workflow to finish (run ${{ steps.announce_dispatch.outputs.run_id }}) + uses: codex-/await-remote-run@v1 + with: + token: ${{ secrets.WURSTCLIENT_NET_PUBLISH_TOKEN }} + owner: Wurst-Imperium + repo: WurstClient.net + run_id: ${{ steps.announce_dispatch.outputs.run_id }} + run_timeout_seconds: 600 # 10 minutes diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2f84893e5b..bea2ec4c00 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,11 +24,6 @@ on: required: true type: boolean default: false - announce_backport: - description: "Announce as a backport on WurstForum" - required: false - type: boolean - default: false distinct_id: description: "Automatically set by the return-dispatch action (leave blank if running manually)" required: false @@ -105,8 +100,7 @@ jobs: { "wurst_version": "$WURST_VERSION", "mc_version": "$MC_VERSION", - "fapi_version": "$FAPI_VERSION", - "announce": "${{ inputs.announce_backport }}" + "fapi_version": "$FAPI_VERSION" } EOF ) diff --git a/src/main/java/net/wurstclient/altmanager/AltRenderer.java b/src/main/java/net/wurstclient/altmanager/AltRenderer.java index dbe6fea282..7ce0f0d765 100644 --- a/src/main/java/net/wurstclient/altmanager/AltRenderer.java +++ b/src/main/java/net/wurstclient/altmanager/AltRenderer.java @@ -10,23 +10,16 @@ import java.util.HashMap; import java.util.UUID; -import org.joml.Matrix4f; import org.lwjgl.opengl.GL11; import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.gl.ShaderProgramKeys; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.BufferRenderer; -import net.minecraft.client.render.Tessellator; -import net.minecraft.client.render.VertexFormat; -import net.minecraft.client.render.VertexFormats; +import net.minecraft.client.render.RenderLayer; import net.minecraft.client.util.DefaultSkinHelper; import net.minecraft.client.util.SkinTextures; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; import net.minecraft.util.Uuids; @@ -35,46 +28,22 @@ public final class AltRenderer private static final HashMap loadedSkins = new HashMap<>(); - private static void bindSkinTexture(String name) + private static Identifier getSkinTexture(String name) { if(name.isEmpty()) name = "Steve"; - if(loadedSkins.get(name) == null) + Identifier texture = loadedSkins.get(name); + if(texture == null) { UUID uuid = Uuids.getOfflinePlayerUuid(name); - - PlayerListEntry entry = - new PlayerListEntry(new GameProfile(uuid, name), false); - - loadedSkins.put(name, entry.getSkinTextures().texture()); + GameProfile profile = new GameProfile(uuid, name); + PlayerListEntry entry = new PlayerListEntry(profile, false); + texture = entry.getSkinTextures().texture(); + loadedSkins.put(name, texture); } - RenderSystem.setShaderTexture(0, loadedSkins.get(name)); - } - - private static void drawTexture(DrawContext context, int x, int y, float u, - float v, int w, int h, int fw, int fh) - { - int x2 = x + w; - int y2 = y + h; - int z = 0; - float uOverFw = u / fw; - float uPlusWOverFw = (u + w) / fw; - float vOverFh = v / fh; - float vPlusHOverFh = (v + h) / fh; - - RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX); - MatrixStack matrixStack = context.getMatrices(); - Matrix4f matrix4f = matrixStack.peek().getPositionMatrix(); - BufferBuilder bufferBuilder = Tessellator.getInstance() - .begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); - bufferBuilder.vertex(matrix4f, x, y, z).texture(uOverFw, vOverFh); - bufferBuilder.vertex(matrix4f, x, y2, z).texture(uOverFw, vPlusHOverFh); - bufferBuilder.vertex(matrix4f, x2, y2, z).texture(uPlusWOverFw, - vPlusHOverFh); - bufferBuilder.vertex(matrix4f, x2, y, z).texture(uPlusWOverFw, vOverFh); - BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); + return texture; } public static void drawAltFace(DrawContext context, String name, int x, @@ -82,7 +51,7 @@ public static void drawAltFace(DrawContext context, String name, int x, { try { - bindSkinTexture(name); + Identifier texture = getSkinTexture(name); GL11.glEnable(GL11.GL_BLEND); if(selected) @@ -95,14 +64,16 @@ public static void drawAltFace(DrawContext context, String name, int x, int fh = 192; float u = 24; float v = 24; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Hat fw = 192; fh = 192; u = 120; v = 24; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); GL11.glDisable(GL11.GL_BLEND); @@ -117,7 +88,7 @@ public static void drawAltBody(DrawContext context, String name, int x, { try { - bindSkinTexture(name); + Identifier texture = getSkinTexture(name); boolean slim = DefaultSkinHelper .getSkinTextures(Uuids.getOfflinePlayerUuid(name)) @@ -135,7 +106,8 @@ public static void drawAltBody(DrawContext context, String name, int x, int fh = height * 2; float u = height / 4; float v = height / 4; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Hat x = x + 0; @@ -144,7 +116,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 4; u = height / 4 * 5; v = height / 4; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Chest x = x + 0; @@ -153,7 +126,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 2.5F; v = height / 4 * 2.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Jacket x = x + 0; @@ -162,7 +136,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 2.5F; v = height / 4 * 4.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Left Arm x = x - width / 16 * (slim ? 3 : 4); @@ -171,7 +146,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 5.5F; v = height / 4 * 2.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Left Sleeve x = x + 0; @@ -180,7 +156,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 5.5F; v = height / 4 * 4.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Right Arm x = x + width / 16 * (slim ? 11 : 12); @@ -189,7 +166,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 5.5F; v = height / 4 * 2.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Right Sleeve x = x + 0; @@ -198,7 +176,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 5.5F; v = height / 4 * 4.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Left Leg x = x - width / 2; @@ -207,7 +186,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 0.5F; v = height / 4 * 2.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Left Pants x = x + 0; @@ -216,7 +196,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 0.5F; v = height / 4 * 4.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Right Leg x = x + width / 4; @@ -225,7 +206,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 0.5F; v = height / 4 * 2.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Right Pants x = x + 0; @@ -234,7 +216,8 @@ public static void drawAltBody(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 0.5F; v = height / 4 * 4.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); GL11.glDisable(GL11.GL_BLEND); @@ -249,7 +232,7 @@ public static void drawAltBack(DrawContext context, String name, int x, { try { - bindSkinTexture(name); + Identifier texture = getSkinTexture(name); boolean slim = DefaultSkinHelper .getSkinTextures(Uuids.getOfflinePlayerUuid(name)) @@ -267,7 +250,8 @@ public static void drawAltBack(DrawContext context, String name, int x, int fh = height * 2; float u = height / 4 * 3; float v = height / 4; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Hat x = x + 0; @@ -276,7 +260,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 4; u = height / 4 * 7; v = height / 4; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Chest x = x + 0; @@ -285,7 +270,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 4; v = height / 4 * 2.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Jacket x = x + 0; @@ -294,7 +280,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 4; v = height / 4 * 4.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Left Arm x = x - width / 16 * (slim ? 3 : 4); @@ -303,7 +290,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * (slim ? 6.375F : 6.5F); v = height / 4 * 2.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Left Sleeve x = x + 0; @@ -312,7 +300,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * (slim ? 6.375F : 6.5F); v = height / 4 * 4.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Right Arm x = x + width / 16 * (slim ? 11 : 12); @@ -321,7 +310,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * (slim ? 6.375F : 6.5F); v = height / 4 * 2.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Right Sleeve x = x + 0; @@ -330,7 +320,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * (slim ? 6.375F : 6.5F); v = height / 4 * 4.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Left Leg x = x - width / 2; @@ -339,7 +330,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 1.5F; v = height / 4 * 2.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Left Pants x = x + 0; @@ -348,7 +340,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 1.5F; v = height / 4 * 4.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Right Leg x = x + width / 4; @@ -357,7 +350,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 1.5F; v = height / 4 * 2.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); // Right Pants x = x + 0; @@ -366,7 +360,8 @@ public static void drawAltBack(DrawContext context, String name, int x, h = height / 8 * 3; u = height / 4 * 1.5F; v = height / 4 * 4.5F; - drawTexture(context, x, y, u, v, w, h, fw, fh); + context.drawTexture(RenderLayer::getGuiTextured, texture, x, y, u, + v, w, h, fw, fh); GL11.glDisable(GL11.GL_BLEND); diff --git a/src/main/java/net/wurstclient/commands/CopyItemCmd.java b/src/main/java/net/wurstclient/commands/CopyItemCmd.java index b4702923a6..02ad6b5fff 100644 --- a/src/main/java/net/wurstclient/commands/CopyItemCmd.java +++ b/src/main/java/net/wurstclient/commands/CopyItemCmd.java @@ -8,6 +8,7 @@ package net.wurstclient.commands; import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ItemStack; import net.wurstclient.command.CmdError; import net.wurstclient.command.CmdException; @@ -62,19 +63,19 @@ private ItemStack getItem(AbstractClientPlayerEntity player, String slot) switch(slot.toLowerCase()) { case "hand": - return player.getInventory().getSelectedStack(); + return player.getMainHandStack(); case "head": - return player.getInventory().getArmorStack(3); + return player.getEquippedStack(EquipmentSlot.HEAD); case "chest": - return player.getInventory().getArmorStack(2); + return player.getEquippedStack(EquipmentSlot.CHEST); case "legs": - return player.getInventory().getArmorStack(1); + return player.getEquippedStack(EquipmentSlot.LEGS); case "feet": - return player.getInventory().getArmorStack(0); + return player.getEquippedStack(EquipmentSlot.FEET); default: throw new CmdSyntaxError();