Skip to content

Commit 9eb26ad

Browse files
committed
Push capes
1 parent 106d137 commit 9eb26ad

File tree

5 files changed

+116
-6
lines changed

5 files changed

+116
-6
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin.render;
19+
20+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
21+
import net.minecraft.client.render.entity.feature.CapeFeatureRenderer;
22+
import net.minecraft.util.Identifier;
23+
import org.spongepowered.asm.mixin.Mixin;
24+
import org.spongepowered.asm.mixin.injection.At;
25+
26+
@Mixin(CapeFeatureRenderer.class)
27+
public class CapeFeatureRendererMixin {
28+
@ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SkinTextures;capeTexture()Lnet/minecraft/util/Identifier;"))
29+
Identifier renderCape(Identifier original) {
30+
return new Identifier("lambda", "primary.png");
31+
}
32+
}

common/src/main/kotlin/com/lambda/module/modules/client/Network.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ import com.lambda.event.events.ConnectionEvent.Connect.Login.EncryptionResponse
2828
import com.lambda.event.listener.UnsafeListener.Companion.listenOnceUnsafe
2929
import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe
3030
import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafeConcurrently
31-
import com.lambda.network.api.v1.endpoints.login
32-
import com.lambda.network.api.v1.models.Authentication
3331
import com.lambda.module.Module
3432
import com.lambda.module.tag.ModuleTag
33+
import com.lambda.network.api.v1.endpoints.login
34+
import com.lambda.network.api.v1.models.Authentication
3535
import com.lambda.network.api.v1.models.Authentication.Data
3636
import com.lambda.util.extension.isOffline
3737
import net.minecraft.client.network.AllowedAddressResolver
@@ -45,6 +45,7 @@ import net.minecraft.text.Text
4545
import java.math.BigInteger
4646
import java.util.*
4747

48+
4849
object Network : Module(
4950
name = "Network",
5051
description = "Lambda Authentication",
@@ -78,7 +79,7 @@ object Network : Module(
7879
}
7980

8081
listenOnceUnsafe<ConnectionEvent.Connect.Post> {
81-
if (mc.gameProfile.isOffline) return@listenOnceUnsafe true
82+
if (mc.gameProfile.isOffline) return@listenOnceUnsafe true // ToDo: If the player have the properties but are invalid this doesn't work
8283

8384
// If we log in right as the client responds to the encryption request, we start
8485
// a race condition where the game server haven't acknowledged the packets
@@ -89,8 +90,7 @@ object Network : Module(
8990
return@listenOnceUnsafe false
9091
}
9192

92-
auth = resp
93-
deserialized = gson.fromJson(String(Base64.getUrlDecoder().decode(accessToken.split(".")[1])), Data::class.java)
93+
updateToken(resp)
9494

9595
true
9696
}
@@ -113,7 +113,10 @@ object Network : Module(
113113
connection.send(LoginHelloC2SPacket(mc.session.username, mc.session.uuidOrNull))
114114
}
115115

116-
internal fun updateToken(auth: Authentication?) { this.auth = auth }
116+
internal fun updateToken(resp: Authentication?) {
117+
auth = resp
118+
deserialized = gson.fromJson(String(Base64.getUrlDecoder().decode(accessToken.split(".")[1])), Data::class.java)
119+
}
117120

118121
enum class ApiVersion(val value: String) {
119122
// We can use @Deprecated("Not supported") to remove old API versions in the future
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.network.api.v1.endpoints
19+
20+
import com.github.kittinunf.fuel.Fuel
21+
import com.lambda.module.modules.client.Network.apiUrl
22+
import com.lambda.module.modules.client.Network.apiVersion
23+
import java.util.UUID
24+
25+
/**
26+
* Get the cape of the given player UUID.
27+
*
28+
* input:
29+
* - ab24f5d6-dcf1-45e4-897e-b50a7c5e7422
30+
*
31+
* output:
32+
* - cape_1
33+
*/
34+
fun getCape(
35+
uuid: UUID,
36+
) =
37+
Fuel.put("$apiUrl/api/${apiVersion.value}/cape", listOf("id" to uuid.toString()))
38+
.responseString()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.network.api.v1.endpoints
19+
20+
import com.github.kittinunf.fuel.Fuel
21+
import com.github.kittinunf.fuel.core.extensions.authentication
22+
import com.lambda.module.modules.client.Network
23+
import com.lambda.module.modules.client.Network.apiUrl
24+
import com.lambda.module.modules.client.Network.apiVersion
25+
import java.util.*
26+
27+
fun setCape(
28+
// Get the cape of the given player UUID.
29+
// example: ab24f5d6-dcf1-45e4-897e-b50a7c5e7422
30+
// example: ab24f5d6dcf145e4897eb50a7c5e7422
31+
uuid: UUID,
32+
) =
33+
Fuel.put("$apiUrl/api/${apiVersion.value}/cape", listOf("id" to uuid.toString()))
34+
.authentication()
35+
.bearer(Network.accessToken)
36+
.responseString()

common/src/main/resources/lambda.mixins.common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"render.BackgroundRendererMixin",
2929
"render.BlockRenderManagerMixin",
3030
"render.CameraMixin",
31+
"render.CapeFeatureRendererMixin",
3132
"render.ChatInputSuggestorMixin",
3233
"render.ChatScreenMixin",
3334
"render.DebugHudMixin",

0 commit comments

Comments
 (0)