Skip to content

Commit b9b22fb

Browse files
committed
Merge remote-tracking branch 'origin/1.21.5' into feature/module/BetterFirework
2 parents 6aea738 + 4549780 commit b9b22fb

File tree

209 files changed

+2868
-2857
lines changed

Some content is hidden

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

209 files changed

+2868
-2857
lines changed

build.gradle.kts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ val mockitoInline: String by project
3535
val mockkVersion: String by project
3636
val spairVersion: String by project
3737
val lwjglVersion: String by project
38-
38+
val sodiumVersion: String by project
39+
val litematicaVersion: String by project
3940

4041
val libs = file("libs")
4142
val targets = listOf("fabric.mod.json")
@@ -69,6 +70,7 @@ repositories {
6970
mavenLocal() // Allow the use of local repositories
7071
maven("https://maven.2b2t.vc/releases") // Baritone
7172
maven("https://jitpack.io") // KDiscordIPC
73+
maven("https://api.modrinth.com/maven")
7274
mavenCentral()
7375

7476
// Allow the use of local libraries
@@ -107,7 +109,7 @@ loom {
107109
property("org.lwjgl.util.DebugFunctions", "true")
108110
property("mixin.debug.export", "true")
109111

110-
vmArgs("-XX:+HeapDumpOnOutOfMemoryError", "-XX:+CreateCoredumpOnCrash", "-XX:+UseOSErrorReporting")
112+
vmArgs("-XX:+HeapDumpOnOutOfMemoryError", "-XX:+CreateCoredumpOnCrash")
111113
programArgs("--username", "Steve", "--uuid", "8667ba71b85a4004af54457a9734eed7", "--accessToken", "****")
112114
}
113115
}
@@ -171,8 +173,10 @@ dependencies {
171173
includeLib("io.ktor:ktor-client-content-negotiation:$ktorVersion")
172174
includeLib("io.ktor:ktor-serialization-gson:$ktorVersion")
173175

174-
// Add mods to the mod jar
175-
includeMod("com.github.rfresh2:baritone-fabric:$minecraftVersion")
176+
// Add mods
177+
modImplementation("com.github.rfresh2:baritone-fabric:$minecraftVersion")
178+
modCompileOnly("maven.modrinth:sodium:$sodiumVersion")
179+
modCompileOnly("maven.modrinth:litematica:$litematicaVersion")
176180

177181
// Test implementations
178182
testImplementation(kotlin("test"))
@@ -213,7 +217,7 @@ tasks {
213217

214218
kotlin {
215219
compilerOptions {
216-
freeCompilerArgs.add("-Xcontext-parameters")
220+
freeCompilerArgs.addAll("-Xcontext-parameters", "-Xconsistent-data-class-copy-visibility")
217221
}
218222

219223
jvmToolchain(21)

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ fabricLoaderVersion=0.16.13
4747
yarnMappings=build.1
4848
fabricApiVersion=0.124.0
4949
kotlinFabricVersion=1.13.4+kotlin
50+
sodiumVersion=mc1.21.5-0.6.13-fabric
51+
litematicaVersion=0.22.2
5052

5153
# Kotlin https://kotlinlang.org/
5254
kotlin.code.style=official

src/main/java/com/lambda/mixin/entity/LivingEntityMixin.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
import com.lambda.event.EventFlow;
2222
import com.lambda.event.events.MovementEvent;
2323
import com.lambda.interaction.request.rotating.RotationManager;
24+
import com.lambda.module.modules.movement.Velocity;
2425
import com.lambda.module.modules.render.ViewModel;
26+
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
27+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
28+
import net.minecraft.entity.Entity;
2529
import net.minecraft.entity.LivingEntity;
2630
import net.minecraft.util.math.MathHelper;
2731
import net.minecraft.util.math.Vec3d;
@@ -167,4 +171,12 @@ private int getHandSwingDuration(int constant) {
167171

168172
return ViewModel.INSTANCE.getSwingDuration();
169173
}
174+
175+
@WrapMethod(method = "pushAwayFrom")
176+
private void wrapPushAwayFrom(Entity entity, Operation<Void> original) {
177+
if (lambda$instance == Lambda.getMc().player &&
178+
Velocity.INSTANCE.isEnabled() &&
179+
Velocity.getPushed()) return;
180+
original.call(entity);
181+
}
170182
}

src/main/java/com/lambda/mixin/entity/PlayerInventoryMixin.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,19 @@
1818
package com.lambda.mixin.entity;
1919

2020
import com.lambda.interaction.request.hotbar.HotbarManager;
21-
import com.lambda.interaction.request.hotbar.HotbarRequest;
2221
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
2322
import net.minecraft.entity.player.PlayerInventory;
2423
import org.objectweb.asm.Opcodes;
2524
import org.spongepowered.asm.mixin.Mixin;
2625
import org.spongepowered.asm.mixin.injection.At;
27-
import org.spongepowered.asm.mixin.injection.Inject;
28-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
2926

3027
@Mixin(PlayerInventory.class)
3128
public class PlayerInventoryMixin {
32-
@SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"})
29+
@SuppressWarnings({"MixinAnnotationTarget"})
3330
@ModifyExpressionValue(method = "*", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerInventory;selectedSlot:I", opcode = Opcodes.GETFIELD))
3431
private int modifySelectedSlot(int original) {
35-
final HotbarRequest hotbarRequest = HotbarManager.INSTANCE.getActiveRequest();
36-
if (hotbarRequest == null) return original;
37-
return hotbarRequest.getSlot();
38-
}
39-
40-
@Inject(method = "getSelectedSlot", at = @At("HEAD"), cancellable = true)
41-
private void redirectGetSelectedSlot(CallbackInfoReturnable<Integer> cir) {
42-
final HotbarRequest hotbarRequest = HotbarManager.INSTANCE.getActiveRequest();
43-
if (hotbarRequest == null) return;
44-
cir.setReturnValue(hotbarRequest.getSlot());
32+
final int hotbarSlot = HotbarManager.getActiveSlot();
33+
if (hotbarSlot == -1) return original;
34+
return hotbarSlot;
4535
}
4636
}

src/main/java/com/lambda/mixin/input/KeyBindingMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void autoSprint(CallbackInfoReturnable<Boolean> cir) {
3636
if (!Objects.equals(instance.getTranslationKey(), "key.sprint")) return;
3737

3838
if (Sprint.INSTANCE.isEnabled()) cir.setReturnValue(true);
39-
if (Speed.INSTANCE.isEnabled() && Speed.getMode() == Speed.Mode.GRIM_STRAFE) cir.setReturnValue(true);
39+
if (Speed.INSTANCE.isEnabled() && Speed.getMode() == Speed.Mode.GrimStrafe) cir.setReturnValue(true);
4040
if (TargetStrafe.INSTANCE.isEnabled() && TargetStrafe.isActive()) cir.setReturnValue(true);
4141
}
4242
}

src/main/java/com/lambda/mixin/network/ClientPlayNetworkHandlerMixin.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
import com.lambda.event.EventFlow;
2121
import com.lambda.event.events.InventoryEvent;
2222
import com.lambda.event.events.WorldEvent;
23+
import com.lambda.interaction.request.inventory.InventoryManager;
2324
import com.lambda.module.modules.movement.Velocity;
2425
import com.lambda.module.modules.render.NoRender;
26+
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
27+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
2528
import net.minecraft.client.network.ClientPlayNetworkHandler;
2629
import net.minecraft.client.network.PlayerListEntry;
2730
import net.minecraft.network.packet.s2c.play.*;
@@ -103,4 +106,14 @@ public boolean onServerMetadata(ClientPlayNetworkHandler clientPlayNetworkHandle
103106
void injectVelocity(ExplosionS2CPacket packet, CallbackInfo ci) {
104107
if (Velocity.getExplosion() && Velocity.INSTANCE.isEnabled()) ci.cancel();
105108
}
109+
110+
@WrapMethod(method = "onScreenHandlerSlotUpdate")
111+
private void wrapOnScreenHandlerSlotUpdate(ScreenHandlerSlotUpdateS2CPacket packet, Operation<Void> original) {
112+
InventoryManager.onSlotUpdate(packet, original);
113+
}
114+
115+
@WrapMethod(method = "onInventory")
116+
private void wrapOnInventory(InventoryS2CPacket packet, Operation<Void> original) {
117+
InventoryManager.onInventoryUpdate(packet, original);
118+
}
106119
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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.module.modules.render.XRay;
21+
import net.fabricmc.fabric.impl.client.indigo.renderer.mesh.MutableQuadViewImpl;
22+
import net.fabricmc.fabric.impl.client.indigo.renderer.render.AbstractTerrainRenderContext;
23+
import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo;
24+
import org.spongepowered.asm.mixin.Final;
25+
import org.spongepowered.asm.mixin.Mixin;
26+
import org.spongepowered.asm.mixin.Shadow;
27+
import org.spongepowered.asm.mixin.injection.At;
28+
import org.spongepowered.asm.mixin.injection.Inject;
29+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
30+
31+
@SuppressWarnings("UnstableApiUsage")
32+
@Mixin(AbstractTerrainRenderContext.class)
33+
public class AbstractTerrainRenderContextMixin {
34+
@Final
35+
@Shadow(remap = false)
36+
protected BlockRenderInfo blockInfo;
37+
38+
@Inject(method = "bufferQuad", at = @At(value = "INVOKE", target = "Lnet/fabricmc/fabric/impl/client/indigo/renderer/render/AbstractTerrainRenderContext;bufferQuad(Lnet/fabricmc/fabric/impl/client/indigo/renderer/mesh/MutableQuadViewImpl;Lnet/minecraft/client/render/VertexConsumer;)V"), cancellable = true)
39+
private void injectBufferQuad(MutableQuadViewImpl quad, CallbackInfo ci) {
40+
if (XRay.INSTANCE.isDisabled() || XRay.isSelected(blockInfo.blockState)) return;
41+
int opacity = XRay.getOpacity();
42+
43+
if (opacity == 0) ci.cancel();
44+
else if (opacity < 100) {
45+
int alpha = (int) (opacity * 2.55f);
46+
for (int i = 0; i < 4; i++) {
47+
quad.color(i, ((alpha & 0xFF) << 24) | (quad.color(i) & 0x00FFFFFF));
48+
}
49+
}
50+
}
51+
}
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.mixin.render;
19+
20+
import com.lambda.module.modules.render.XRay;
21+
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
22+
import net.minecraft.block.Block;
23+
import net.minecraft.block.BlockState;
24+
import net.minecraft.util.math.Direction;
25+
import org.spongepowered.asm.mixin.Mixin;
26+
import org.spongepowered.asm.mixin.injection.At;
27+
28+
@Mixin(Block.class)
29+
public class BlockMixin {
30+
@ModifyReturnValue(method = "shouldDrawSide", at = @At("RETURN"))
31+
private static boolean modifyShouldDrawSide(boolean original, BlockState state, BlockState otherState, Direction side) {
32+
if (XRay.INSTANCE.isEnabled() && XRay.isSelected(state) && XRay.getOpacity() < 100)
33+
return true;
34+
return original;
35+
}
36+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.module.modules.render.XRay;
21+
import net.minecraft.block.BlockState;
22+
import net.minecraft.client.render.VertexConsumer;
23+
import net.minecraft.client.render.block.BlockModelRenderer;
24+
import net.minecraft.client.render.model.BlockModelPart;
25+
import net.minecraft.client.util.math.MatrixStack;
26+
import net.minecraft.util.math.BlockPos;
27+
import net.minecraft.world.BlockRenderView;
28+
import org.spongepowered.asm.mixin.Mixin;
29+
import org.spongepowered.asm.mixin.Unique;
30+
import org.spongepowered.asm.mixin.injection.At;
31+
import org.spongepowered.asm.mixin.injection.Constant;
32+
import org.spongepowered.asm.mixin.injection.Inject;
33+
import org.spongepowered.asm.mixin.injection.ModifyConstant;
34+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
35+
36+
import java.util.List;
37+
38+
@Mixin(BlockModelRenderer.class)
39+
public class BlockModelRendererMixin {
40+
@Unique private final ThreadLocal<Integer> opacity = new ThreadLocal<>();
41+
42+
@Inject(method = {"renderSmooth", "renderFlat"}, at = @At("HEAD"), cancellable = true)
43+
private void injectRenderSmoothFlat(BlockRenderView world, List<BlockModelPart> parts, BlockState state, BlockPos pos, MatrixStack matrices, VertexConsumer vertexConsumer, boolean cull, int overlay, CallbackInfo ci) {
44+
if (XRay.INSTANCE.isDisabled()) {
45+
this.opacity.set(-1);
46+
return;
47+
}
48+
int alpha = (int) (XRay.getOpacity() * 2.55);
49+
50+
if (alpha == 0) ci.cancel();
51+
else this.opacity.set(alpha);
52+
}
53+
54+
@ModifyConstant(method = "renderQuad", constant = @Constant(floatValue = 1, ordinal = 3))
55+
private float modifyAlpha(float original) {
56+
int alpha = this.opacity.get();
57+
return alpha == -1 ? original : alpha / 255f;
58+
}
59+
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@
3333
public class CapeFeatureRendererMixin {
3434
@ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/PlayerEntityRenderState;FF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SkinTextures;capeTexture()Lnet/minecraft/util/Identifier;"))
3535
Identifier renderCape(Identifier original, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, PlayerEntityRenderState player, float f, float g) {
36-
var entity = Lambda.getMc().world.getEntityById(player.id);
37-
if (!Capes.INSTANCE.isEnabled() || !CapeManager.INSTANCE.containsKey(entity.getUuid())) return original;
36+
var entry = Lambda.getMc().getNetworkHandler().getPlayerListEntry(player.name); // this will cause issues if we try to render while not in game
37+
if (entry == null) return original;
3838

39-
return Identifier.of("lambda", CapeManager.INSTANCE.get(entity.getUuid()));
39+
var profile = entry.getProfile();
40+
if (!Capes.INSTANCE.isEnabled() || !CapeManager.INSTANCE.getCache().containsKey(profile.getId())) return original;
41+
42+
return Identifier.of("lambda", CapeManager.INSTANCE.getCache().get(profile.getId()));
4043
}
4144
}

0 commit comments

Comments
 (0)