Skip to content

Commit ca72b9a

Browse files
authored
Merge branch 'master' into feature/renderer
2 parents 895a069 + 87e0095 commit ca72b9a

File tree

12 files changed

+138
-48
lines changed

12 files changed

+138
-48
lines changed

.github/workflows/add-label.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
build:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- name: Checkout your code
21+
- name: Check Out Repository
2222
uses: actions/checkout@v3
2323
- name: Labeler
2424
uses: srvaroa/labeler@master

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ jobs:
1818
env:
1919
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
2020
steps:
21-
- name: Checkout Main
21+
- name: Checkout Repository
2222
uses: actions/checkout@v4.1.1
2323

2424
- name: Get Short Commit Hash
2525
id: vars
2626
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
2727

28-
- name: Set up JDK
28+
- name: Set-Up JDK 17
2929
uses: actions/setup-java@v4
3030
with:
31-
distribution: 'oracle'
31+
distribution: 'temurin'
3232
java-version: '17'
3333
architecture: x64
3434
cache: 'gradle'

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ jobs:
1818
env:
1919
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
2020
steps:
21-
- name: Checkout Main
21+
- name: Checkout Repository
2222
uses: actions/checkout@v4.1.1
2323

2424
- name: Get Short Commit Hash
2525
id: vars
2626
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
2727

28-
- name: Set up JDK
28+
- name: Set-Up JDK 17
2929
uses: actions/setup-java@v4
3030
with:
31-
distribution: 'oracle'
31+
distribution: 'temurin'
3232
java-version: '17'
3333
architecture: x64
3434
cache: 'gradle'
@@ -79,7 +79,7 @@ jobs:
7979
"pr_template": "- #{{TITLE}} [#{{AUTHOR}}](#{{URL}})"
8080
}
8181
82-
- name: Create release
82+
- name: Create Release
8383
uses: softprops/action-gh-release@v2.0.8
8484
with:
8585
name: Lambda ${{ github.ref_name }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.lambda.mixin.render;
2+
3+
import com.lambda.module.modules.render.WorldColors;
4+
import net.minecraft.client.render.BackgroundRenderer;
5+
import net.minecraft.util.math.Vec3d;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.injection.At;
8+
import org.spongepowered.asm.mixin.injection.Redirect;
9+
10+
@Mixin(BackgroundRenderer.class)
11+
public class BackgroundRendererMixin {
12+
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;getX()D"))
13+
private static double redirectRed(Vec3d baseColor) {
14+
return WorldColors.backgroundColor(baseColor).getX();
15+
}
16+
17+
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;getY()D"))
18+
private static double redirectGreen(Vec3d baseColor) {
19+
return WorldColors.backgroundColor(baseColor).getY();
20+
}
21+
22+
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;getZ()D"))
23+
private static double redirectBlue(Vec3d baseColor) {
24+
return WorldColors.backgroundColor(baseColor).getZ();
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.lambda.mixin.render;
2+
3+
import com.lambda.module.modules.render.WorldColors;
4+
import com.mojang.blaze3d.systems.RenderSystem;
5+
import org.spongepowered.asm.mixin.Final;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Shadow;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11+
12+
@Mixin(RenderSystem.class)
13+
public class RenderSystemMixin {
14+
@Shadow @Final private static float[] shaderFogColor;
15+
16+
@Inject(method = "_setShaderFogColor", at = @At(value ="HEAD"), cancellable = true)
17+
private static void onSetShaderFogColor(float red, float green, float blue, float alpha, CallbackInfo ci){
18+
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomFog()){
19+
ci.cancel();
20+
shaderFogColor[0] = WorldColors.getFogColor().getRed() / 255f;
21+
shaderFogColor[1] = WorldColors.getFogColor().getGreen() / 255f;
22+
shaderFogColor[2] = WorldColors.getFogColor().getBlue() / 255f;
23+
shaderFogColor[3] = WorldColors.getFogColor().getAlpha() / 255f;
24+
}
25+
}
26+
}

common/src/main/java/com/lambda/mixin/world/ClientWorldMixin.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22

33
import com.lambda.event.EventFlow;
44
import com.lambda.event.events.WorldEvent;
5+
import com.lambda.module.modules.render.WorldColors;
6+
import com.lambda.util.math.ColorUtils;
57
import net.minecraft.block.BlockState;
68
import net.minecraft.client.world.ClientWorld;
79
import net.minecraft.entity.Entity;
810
import net.minecraft.util.math.BlockPos;
11+
import net.minecraft.util.math.Vec3d;
912
import org.spongepowered.asm.mixin.Mixin;
1013
import org.spongepowered.asm.mixin.injection.At;
1114
import org.spongepowered.asm.mixin.injection.Inject;
1215
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1317

1418
@Mixin(ClientWorld.class)
1519
public class ClientWorldMixin {
@@ -24,4 +28,18 @@ private void handleBlockUpdateInject(BlockPos pos, BlockState state, int flags,
2428
private void addEntity(Entity entity, CallbackInfo ci) {
2529
if (EventFlow.post(new WorldEvent.EntitySpawn(entity)).isCanceled()) ci.cancel();
2630
}
31+
32+
@Inject(method = "getCloudsColor", at = @At("HEAD"), cancellable = true)
33+
private void getCloudsColorInject(float tickDelta, CallbackInfoReturnable<Vec3d> cir) {
34+
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomClouds()) {
35+
cir.setReturnValue(ColorUtils.getVec3d(WorldColors.getCloudColor()));
36+
}
37+
}
38+
39+
@Inject(method = "getSkyColor", at = @At("HEAD"), cancellable = true)
40+
private void getSkyColorInject(Vec3d cameraPos, float tickDelta, CallbackInfoReturnable<Vec3d> cir) {
41+
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomSky()) {
42+
cir.setReturnValue(ColorUtils.getVec3d(WorldColors.getSkyColor()));
43+
}
44+
}
2745
}

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

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ object DiscordRPC : Module(
3535
name = "DiscordRPC",
3636
description = "Discord Rich Presence configuration",
3737
defaultTags = setOf(ModuleTag.CLIENT),
38-
enabledByDefault = true,
38+
// enabledByDefault = true, // ToDo: Bring this back on beta release
3939
) {
4040
private val page by setting("Page", Page.General)
4141

@@ -52,7 +52,7 @@ object DiscordRPC : Module(
5252
/* Technical settings */
5353
private var rpcServer by setting("RPC Server", "http://127.0.0.1:8080") { page == Page.Settings } // TODO: Change this in production
5454
private var apiVersion by setting("API Version", ApiVersion.V1) { page == Page.Settings }
55-
private val delay by setting("Update Delay", 5000, 5000..10000, 1, unit = "ms", visibility = { page == Page.Settings })
55+
private val delay by setting("Update Delay", 15000, 15000..30000, 100, unit = "ms", visibility = { page == Page.Settings })
5656

5757
/* Party settings */
5858
private val enableParty by setting("Enable Party", true, description = "Allows you to create parties.") { page == Page.Party }
@@ -64,6 +64,7 @@ object DiscordRPC : Module(
6464
private var startup = System.currentTimeMillis()
6565
private val dimensionRegex = Regex("""\b\w+_\w+\b""")
6666

67+
private var ready: ReadyEvent? = null
6768
private var discordAuth: AuthenticatePacket.Data? = null
6869
private var rpcAuth: Authentication? = null
6970
private var currentParty: AtomicReference<Party?> = AtomicReference(null)
@@ -157,6 +158,21 @@ object DiscordRPC : Module(
157158
rpc.disconnect()
158159
leaveParty(rpcServer, apiVersion.value, rpcAuth?.accessToken ?: return)
159160
}
161+
162+
ready = null
163+
discordAuth = null
164+
rpcAuth = null
165+
currentParty.lazySet(null)
166+
}
167+
168+
fun createParty() {
169+
if (!allowed) return
170+
171+
createParty(rpcServer, apiVersion.value, rpcAuth?.accessToken ?: return, maxPlayers, public)
172+
.also { response ->
173+
if (response.error != null) warn("Failed to create a party: ${response.error}")
174+
currentParty.lazySet(response.data)
175+
}
160176
}
161177

162178
fun join(id: String = rpc.activityManager.activity?.party?.id ?: "") {
@@ -203,20 +219,14 @@ object DiscordRPC : Module(
203219
}
204220

205221
private suspend fun KDiscordIPC.register(auth: ConnectionEvent.Connect.Login.Key) {
206-
// TODO: Check if the rpc is already ready
222+
if (rpc.connected && ready != null) return
223+
207224
on<ReadyEvent> {
225+
ready = this
226+
208227
// Party features
209228
subscribe(DiscordEvent.ActivityJoinRequest)
210229
subscribe(DiscordEvent.ActivityJoin)
211-
//subscribe(DiscordEvent.LobbyUpdate)
212-
//subscribe(DiscordEvent.LobbyDelete)
213-
//subscribe(DiscordEvent.LobbyMemberConnect)
214-
//subscribe(DiscordEvent.LobbyMemberDisconnect)
215-
//subscribe(DiscordEvent.LobbyMemberUpdate)
216-
217-
// QOL features
218-
//subscribe(DiscordEvent.SpeakingStart)
219-
//subscribe(DiscordEvent.SpeakingStop)
220230

221231
if (System.currentTimeMillis() - connectionTime > 300000) {
222232
warn("The authentication hash has expired, reconnect to the server.")
@@ -236,11 +246,7 @@ object DiscordRPC : Module(
236246
rpcAuth = response.data
237247
}
238248

239-
if (createByDefault) createParty(rpcServer, apiVersion.value, rpcAuth?.accessToken ?: return@on, maxPlayers, public)
240-
.also { response ->
241-
if (response.error != null) warn("Failed to create a party: ${response.error}")
242-
currentParty.lazySet(response.data)
243-
}
249+
if (createByDefault) createParty()
244250
}
245251

246252
// Event when someone would like to join your party
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.lambda.module.modules.render
2+
3+
import com.lambda.module.Module
4+
import com.lambda.module.tag.ModuleTag
5+
import com.lambda.util.math.ColorUtils.vec3d
6+
import net.minecraft.util.math.Vec3d
7+
import java.awt.Color
8+
9+
object WorldColors : Module(
10+
name = "World Colors",
11+
description = "Changes the color of the sky",
12+
defaultTags = setOf(ModuleTag.RENDER)
13+
){
14+
@JvmStatic
15+
val customSky by setting("Custom Sky", true)
16+
@JvmStatic
17+
val skyColor by setting("Sky Color", Color(255, 24, 75), "The color of your sky") { customSky }
18+
@JvmStatic
19+
val customFog by setting("Custom Fog",false)
20+
@JvmStatic
21+
val fogColor by setting("Fog Color", Color(255, 24, 75, 255), "The color of your fog") { customFog }
22+
@JvmStatic
23+
val customClouds by setting("Custom Clouds", false)
24+
@JvmStatic
25+
val cloudColor by setting("Cloud Color", Color(255, 24, 75)) { customClouds }
26+
27+
@JvmStatic
28+
fun backgroundColor(base: Vec3d) =
29+
if (customFog && isEnabled) fogColor.vec3d else base
30+
}

common/src/main/kotlin/com/lambda/util/math/ColorUtils.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.lambda.util.math
22

3+
import net.minecraft.util.math.Vec3d
34
import java.awt.Color
45

56
object ColorUtils {
@@ -13,4 +14,7 @@ object ColorUtils {
1314
val Color.g get() = green.toDouble() / 255.0
1415
val Color.b get() = blue.toDouble() / 255.0
1516
val Color.a get() = alpha.toDouble() / 255.0
17+
18+
@JvmStatic
19+
val Color.vec3d get() = Vec3d(r, g, b)
1620
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"network.HandshakeC2SPacketMixin",
2323
"network.LoginHelloC2SPacketMixin",
2424
"network.LoginKeyC2SPacketMixin",
25+
"render.BackgroundRendererMixin",
2526
"render.BlockRenderManagerMixin",
2627
"render.CameraMixin",
2728
"render.ChatInputSuggestorMixin",
@@ -34,6 +35,7 @@
3435
"render.LightmapTextureManagerMixin",
3536
"render.LivingEntityRendererMixin",
3637
"render.RenderLayersMixin",
38+
"render.RenderSystemMixin",
3739
"render.RenderTickCounterMixin",
3840
"render.ScreenHandlerMixin",
3941
"render.VertexBufferMixin",

0 commit comments

Comments
 (0)