Skip to content

Commit

Permalink
Merge branch 'master' into LogOutSpot
Browse files Browse the repository at this point in the history
  • Loading branch information
JAXPLE authored Feb 8, 2025
2 parents 3acf226 + a8ec435 commit 28a38da
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 472 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/altmanager/AltManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ else if(alt.isCheckedPremium())
* @param alt
* The Alt to be removed.
*/
private void remove(Alt alt)
public void remove(Alt alt)
{
if(!alts.remove(alt))
return;
Expand Down
133 changes: 64 additions & 69 deletions src/main/java/net/wurstclient/altmanager/AltRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -35,54 +28,30 @@ public final class AltRenderer
private static final HashMap<String, Identifier> 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,
int y, int w, int h, boolean selected)
{
try
{
bindSkinTexture(name);
Identifier texture = getSkinTexture(name);
GL11.glEnable(GL11.GL_BLEND);

if(selected)
Expand All @@ -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);

Expand All @@ -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))
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);

Expand All @@ -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))
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);

Expand Down
Loading

0 comments on commit 28a38da

Please sign in to comment.