Skip to content

Commit bacf47b

Browse files
committed
Merge branch '1.21.5' into improvement/scaffold
2 parents 6e57aa9 + 0beeb3a commit bacf47b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1063
-668
lines changed

src/main/java/com/lambda/mixin/render/BackgroundRendererMixin.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.lambda.module.modules.render.WorldColors;
2121
import net.minecraft.client.render.BackgroundRenderer;
2222
import net.minecraft.util.math.Vec3d;
23+
import net.minecraft.world.biome.Biome;
2324
import org.spongepowered.asm.mixin.Mixin;
2425
import org.spongepowered.asm.mixin.injection.At;
2526
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -40,16 +41,22 @@
4041
public class BackgroundRendererMixin {
4142
@Redirect(method = "getFogColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;getX()D"))
4243
private static double redirectRed(Vec3d baseColor) {
43-
return WorldColors.backgroundColor(baseColor).getX();
44+
return WorldColors.fogOfWarColor(baseColor).getX();
4445
}
4546

4647
@Redirect(method = "getFogColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;getY()D"))
4748
private static double redirectGreen(Vec3d baseColor) {
48-
return WorldColors.backgroundColor(baseColor).getY();
49+
return WorldColors.fogOfWarColor(baseColor).getY();
4950
}
5051

5152
@Redirect(method = "getFogColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;getZ()D"))
5253
private static double redirectBlue(Vec3d baseColor) {
53-
return WorldColors.backgroundColor(baseColor).getZ();
54+
return WorldColors.fogOfWarColor(baseColor).getZ();
5455
}
56+
57+
@Redirect(method = "getFogColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getWaterFogColor()I"))
58+
private static int redirectWaterFogColor(Biome biome) {
59+
return WorldColors.waterFogColor(biome.getWaterFogColor());
60+
}
61+
5562
}

src/main/java/com/lambda/mixin/render/RenderSystemMixin.java renamed to src/main/java/com/lambda/mixin/render/DebugRendererMixin.java

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,20 @@
1717

1818
package com.lambda.mixin.render;
1919

20-
import com.lambda.module.modules.render.WorldColors;
21-
import com.mojang.blaze3d.systems.RenderSystem;
22-
import org.spongepowered.asm.mixin.Final;
20+
import com.lambda.module.modules.debug.DebugRendererModule;
21+
import net.minecraft.client.render.Frustum;
22+
import net.minecraft.client.render.VertexConsumerProvider;
23+
import net.minecraft.client.render.debug.*;
24+
import net.minecraft.client.util.math.MatrixStack;
2325
import org.spongepowered.asm.mixin.Mixin;
24-
import org.spongepowered.asm.mixin.Shadow;
2526
import org.spongepowered.asm.mixin.injection.At;
2627
import org.spongepowered.asm.mixin.injection.Inject;
2728
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2829

29-
@Mixin(RenderSystem.class)
30-
public class RenderSystemMixin {
31-
@Shadow @Final private static float[] shaderColor;
32-
33-
@Inject(method = "setShaderColor(FFFF)V", at = @At(value = "HEAD"), cancellable = true)
34-
private static void onSetShaderColor(float red, float green, float blue, float alpha, CallbackInfo ci) {
35-
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomFog()) {
36-
ci.cancel();
37-
shaderColor[0] = WorldColors.getFogColor().getRed() / 255f;
38-
shaderColor[1] = WorldColors.getFogColor().getGreen() / 255f;
39-
shaderColor[2] = WorldColors.getFogColor().getBlue() / 255f;
40-
shaderColor[3] = WorldColors.getFogColor().getAlpha() / 255f;
41-
}
30+
@Mixin(DebugRenderer.class)
31+
public class DebugRendererMixin {
32+
@Inject(method = "render", at = @At("TAIL"))
33+
private void onRender(MatrixStack matrices, Frustum frustum, VertexConsumerProvider.Immediate vertexConsumers, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
34+
DebugRendererModule.render(matrices, vertexConsumers, cameraX, cameraY, cameraZ);
4235
}
4336
}

src/main/java/com/lambda/mixin/render/GameRendererMixin.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@
1919

2020
import com.lambda.event.EventFlow;
2121
import com.lambda.event.events.RenderEvent;
22+
import com.lambda.graphics.RenderMain;
23+
import com.lambda.gui.DearImGui;
2224
import com.lambda.gui.LambdaScreen;
2325
import com.lambda.module.modules.client.ClickGui;
26+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
27+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
28+
import net.minecraft.client.render.Camera;
2429
import net.minecraft.client.render.GameRenderer;
2530
import net.minecraft.client.render.RenderTickCounter;
31+
import net.minecraft.client.render.WorldRenderer;
32+
import net.minecraft.client.util.ObjectAllocator;
33+
import org.joml.Matrix4f;
2634
import org.spongepowered.asm.mixin.Mixin;
2735
import org.spongepowered.asm.mixin.injection.At;
2836
import org.spongepowered.asm.mixin.injection.Inject;
@@ -37,9 +45,22 @@ private void updateTargetedEntityInvoke(float tickDelta, CallbackInfo info) {
3745
}
3846
}
3947

40-
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/gui/DrawContext;IIF)V", shift = At.Shift.AFTER))
41-
void renderGui(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci) {
42-
if (ClickGui.INSTANCE.isEnabled())
43-
LambdaScreen.INSTANCE.render();
48+
/**
49+
* Begins our 3d render after the game has rendered the world
50+
* <pre>{@code
51+
* float m = Math.max(h, (float)(Integer)this.client.options.getFov().getValue());
52+
* Matrix4f matrix4f2 = this.getBasicProjectionMatrix(m);
53+
* RenderSystem.setProjectionMatrix(matrix4f, ProjectionType.PERSPECTIVE);
54+
* Quaternionf quaternionf = camera.getRotation().conjugate(new Quaternionf());
55+
* Matrix4f matrix4f3 = (new Matrix4f()).rotation(quaternionf);
56+
* this.client.worldRenderer.setupFrustum(camera.getPos(), matrix4f3, matrix4f2);
57+
* this.client.worldRenderer.render(this.pool, renderTickCounter, bl, camera, this, matrix4f3, matrix4f);
58+
* }</pre>
59+
*/
60+
@WrapOperation(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;render(Lnet/minecraft/client/util/ObjectAllocator;Lnet/minecraft/client/render/RenderTickCounter;ZLnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/GameRenderer;Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;)V"))
61+
void onRenderWorld(WorldRenderer instance, ObjectAllocator allocator, RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, Matrix4f positionMatrix, Matrix4f projectionMatrix, Operation<Void> original) {
62+
original.call(instance, allocator, tickCounter, renderBlockOutline, camera, gameRenderer, positionMatrix, projectionMatrix);
63+
64+
RenderMain.render3D(positionMatrix, projectionMatrix);
4465
}
4566
}
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.mixin.render;
19+
20+
import com.lambda.gui.DearImGui;
21+
import net.minecraft.client.gui.DrawContext;
22+
import net.minecraft.client.gui.hud.InGameHud;
23+
import net.minecraft.client.render.RenderTickCounter;
24+
import org.spongepowered.asm.mixin.Mixin;
25+
import org.spongepowered.asm.mixin.injection.At;
26+
import org.spongepowered.asm.mixin.injection.Inject;
27+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28+
29+
@Mixin(InGameHud.class)
30+
public class InGameHudMixin {
31+
/**
32+
* Begins our 2d render after the game has rendered all 2d elements
33+
*/
34+
@Inject(method = "render", at = @At("TAIL"))
35+
private void onRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
36+
DearImGui.INSTANCE.render();
37+
}
38+
}

src/main/java/com/lambda/mixin/render/WorldRendererMixin.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,13 @@
1717

1818
package com.lambda.mixin.render;
1919

20-
import com.lambda.graphics.RenderMain;
2120
import com.lambda.module.modules.player.Freecam;
2221
import net.minecraft.client.render.Camera;
23-
import net.minecraft.client.render.GameRenderer;
24-
import net.minecraft.client.render.RenderTickCounter;
2522
import net.minecraft.client.render.WorldRenderer;
26-
import net.minecraft.client.util.ObjectAllocator;
27-
import org.joml.Matrix4f;
2823
import org.spongepowered.asm.mixin.Mixin;
2924
import org.spongepowered.asm.mixin.injection.At;
30-
import org.spongepowered.asm.mixin.injection.Inject;
3125
import org.spongepowered.asm.mixin.injection.ModifyArg;
3226
import org.spongepowered.asm.mixin.injection.Redirect;
33-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3427

3528
@Mixin(WorldRenderer.class)
3629
public class WorldRendererMixin {
@@ -43,20 +36,4 @@ private boolean renderIsThirdPerson(Camera camera) {
4336
private boolean renderSetupTerrainModifyArg(boolean hasForcedFrustum) {
4437
return Freecam.INSTANCE.isEnabled() || hasForcedFrustum;
4538
}
46-
47-
/**
48-
* Begins our 3d render after the game has rendered the world
49-
* <pre>{@code
50-
* profiler.swap("cullEntities");
51-
* boolean bl3 = this.getEntitiesToRender(camera, frustum, this.renderedEntities);
52-
* this.renderedEntitiesCount = this.renderedEntities.size();
53-
* profiler.swap("terrain_setup");
54-
* this.setupTerrain(camera, frustum, bl, this.client.player.isSpectator());
55-
* profiler.swap("compile_sections");
56-
* }</pre>
57-
*/
58-
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;setupTerrain(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/Frustum;ZZ)V", shift = At.Shift.AFTER))
59-
private void onRenderWorld(ObjectAllocator allocator, RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, Matrix4f positionMatrix, Matrix4f projectionMatrix, CallbackInfo ci) {
60-
RenderMain.render3D(positionMatrix, projectionMatrix);
61-
}
6239
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,22 @@ private void onRemoveEntity(int entityId, Entity.RemovalReason removalReason, Ca
4848
}
4949

5050
@Inject(method = "getCloudsColor", at = @At("HEAD"), cancellable = true)
51-
private void getCloudsColorInject(float tickDelta, CallbackInfoReturnable<Vec3d> cir) {
51+
private void getCloudsColorInject(float tickDelta, CallbackInfoReturnable<Integer> cir) {
5252
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomClouds()) {
53-
cir.setReturnValue(ColorKt.getVec3d(WorldColors.getCloudColor()));
53+
int rgb = WorldColors.getCloudColor().getRGB() & 0xFFFFFF;
54+
cir.setReturnValue(rgb);
5455
}
5556
}
5657

5758
@Inject(method = "getSkyColor", at = @At("HEAD"), cancellable = true)
58-
private void getSkyColorInject(Vec3d cameraPos, float tickDelta, CallbackInfoReturnable<Vec3d> cir) {
59+
private void getSkyColorInject(Vec3d cameraPos, float tickDelta, CallbackInfoReturnable<Integer> cir) {
5960
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomSky()) {
60-
cir.setReturnValue(ColorKt.getVec3d(WorldColors.getSkyColor()));
61+
int rgb = WorldColors.getSkyColor().getRGB() & 0xFFFFFF;
62+
cir.setReturnValue(rgb);
6163
}
6264
}
6365

66+
6467
@Inject(method = "handleBlockUpdate", at = @At("HEAD"), cancellable = true)
6568
private void handleBlockUpdateInject(BlockPos pos, BlockState newState, int flags, CallbackInfo ci) {
6669
if (EventFlow.post(new WorldEvent.BlockUpdate.Server(pos, newState)).isCanceled()) ci.cancel();

src/main/kotlin/com/lambda/Lambda.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ import com.lambda.config.serializer.ItemStackSerializer
2727
import com.lambda.config.serializer.KeyCodeSerializer
2828
import com.lambda.config.serializer.OptionalSerializer
2929
import com.lambda.core.Loader
30+
import com.lambda.module.modules.client.ClickGui
3031
import com.lambda.threading.recordRenderCall
3132
import com.lambda.util.KeyCode
33+
import com.lambda.util.WindowIcons.setLambdaWindowIcon
3234
import com.mojang.authlib.GameProfile
3335
import net.fabricmc.api.ClientModInitializer
3436
import net.fabricmc.loader.api.FabricLoader
@@ -75,6 +77,7 @@ object Lambda : ClientModInitializer {
7577
override fun onInitializeClient() {
7678
recordRenderCall {
7779
LOG.info("$MOD_NAME $VERSION initialized in ${Loader.initialize()} ms\n")
80+
if (ClickGui.setLambdaWindowIcon) setLambdaWindowIcon()
7881
}
7982
}
8083
}

src/main/kotlin/com/lambda/config/Configuration.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,6 @@ abstract class Configuration : Jsonable {
6363
get() = File("${primary.parent}/${primary.nameWithoutExtension}-backup.${primary.extension}")
6464

6565
init {
66-
// We need to implement a dependency graph of loadables and add functions to run before
67-
// and/or after a given Loadable children class is initialized
68-
//
69-
// class Load1(
70-
// override val priority = 1000,
71-
// override val before = Load2,
72-
// ) : Loadable {}
73-
//
74-
// class Load2(
75-
// override val priority = 1000,
76-
// ) : Loadable {}
77-
//
78-
// class Load3(
79-
// override val priority = 1000,
80-
// override val after = Load2,
81-
// ) : Loadable {}
82-
//
83-
// clientLifecycle<Load2>(shift = Pre) { event -> } // Will run before Load2
84-
// clientLifecycle<Load2>(shift = Post) { event -> } // Will run after Load2
85-
listenUnsafe<ClientEvent.Startup> { tryLoad() }
8666
listenUnsafe<ClientEvent.Shutdown>(Int.MIN_VALUE) { trySave() }
8767

8868
register()

src/main/kotlin/com/lambda/config/configurations/UserConfig.kt renamed to src/main/kotlin/com/lambda/config/configurations/ConfigLoader.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818
package com.lambda.config.configurations
1919

2020
import com.lambda.config.Configuration
21-
import com.lambda.util.FolderRegister
22-
import java.io.File
21+
import com.lambda.core.Loadable
2322

24-
object UserConfig : Configuration() {
25-
override val configName get() = "preferences"
26-
override val primary: File = FolderRegister.config.resolve("$configName.json").toFile()
27-
}
23+
object ConfigLoader: Loadable {
24+
override fun load(): String {
25+
Configuration.configurations.forEach {
26+
it.tryLoad()
27+
}
28+
return "Loaded ${Configuration.configurations.size} configurations"
29+
}
30+
}

src/main/kotlin/com/lambda/config/groups/BreakSettings.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ class BreakSettings(
5050

5151
// Fixes / Delays
5252
override val breakThreshold by c.setting("Break Threshold", 0.70f, 0.1f..1.0f, 0.01f, "The break amount at which the block is considered broken", visibility = vis).group(groupPath, Group.General)
53-
override val fudgeFactor by c.setting("Fudge Factor", 2, 0..5, 1, "The amount of ticks to give double, aka secondary breaks extra for the server to recognise the break", visibility = vis).group(groupPath, Group.General)
53+
override val fudgeFactor by c.setting("Fudge Factor", 1, 0..5, 1, "The number of ticks to add to the break time, usually to account for server lag", visibility = vis).group(groupPath, Group.General)
54+
override val serverSwapTicks by c.setting("Server Swap", 2, 0..5, 1, "The number of ticks to give the server time to recognize the player attributes on the swapped item", " tick(s)", visibility = vis).group(groupPath, Group.General)
5455
// override val desyncFix by c.setting("Desync Fix", false, "Predicts if the players breaking will be slowed next tick as block break packets are processed using the players next position") { vis() && page == Page.General }
55-
override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " ticks", visibility = vis).group(groupPath, Group.General)
56+
override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " tick(s)", visibility = vis).group(groupPath, Group.General)
5657

5758
// Timing
5859
override val breakStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post, TickEvent.Player.Post), description = "The sub-tick timing at which break actions can be performed", visibility = vis).group(groupPath, Group.General)

0 commit comments

Comments
 (0)