Skip to content

Commit e3220f9

Browse files
committed
Merge branch 'master' into LongJump
2 parents 5b4fea5 + 879fbaf commit e3220f9

File tree

22 files changed

+689
-161
lines changed

22 files changed

+689
-161
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Customize your experience, and improve your efficiency!
1616
Find our plugins [here](https://github.com/lambda-plugins).
1717

1818
<p align="center">
19-
<a href="https://github.com/lambda-client/lambda/releases/download/3.2.1/lambda-3.2.1.jar"><img alt="lambda-3.2.1.jar" src="https://github.com/lambda-client/assets/main/download_button_3.2.1.png" width="70%" height="70%"></a>
19+
<a href="https://github.com/lambda-client/lambda/releases/download/3.3.0/lambda-3.3.0.jar"><img alt="lambda-3.3.0.jar" src="https://github.com/lambda-client/assets/main/download_button_3.3.0.png" width="70%" height="70%"></a>
2020
</p>
2121

2222
<div align="center">

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ dependencies {
109109
compileOnly 'org.jetbrains:annotations:23.0.0'
110110

111111
// This Baritone will NOT be included in the jar
112-
implementation 'com.github.cabaletta:baritone:1.2.14'
112+
implementation('cabaletta:baritone-deobf-unoptimized-mcp-dev:1.2').setChanging(true)
113113

114114
// This Baritone WILL be included in the jar
115-
jarLibs 'cabaletta:baritone-api:1.2'
115+
jarLibs('cabaletta:baritone-api:1.2').setChanging(true)
116116

117117
// Add everything in jarLibs to implementation (compile)
118118
implementation configurations.jarLibs

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ org.gradle.caching=true
33
org.gradle.parallel=true
44

55
modGroup=com.lambda
6-
modVersion=3.2.1
6+
modVersion=3.3.0
77

88
minecraftVersion=1.12.2
99
forgeVersion=14.23.5.2860
1010
mappingsChannel=stable
1111
mappingsVersion=39-1.12
1212

13-
kotlinVersion=1.8.0
13+
kotlinVersion=1.8.10
1414
kotlinxCoroutinesVersion=1.6.4
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.lambda.mixin.network;
2+
3+
import com.lambda.client.event.LambdaEventBus;
4+
import com.lambda.client.event.events.ChunkDataEvent;
5+
import net.minecraft.client.multiplayer.WorldClient;
6+
import net.minecraft.client.network.NetHandlerPlayClient;
7+
import net.minecraft.network.play.server.SPacketChunkData;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.Shadow;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13+
14+
@Mixin(value = NetHandlerPlayClient.class)
15+
public class MixinNetHandlerPlayClient {
16+
17+
@Shadow private WorldClient world;
18+
19+
@Inject(method = "handleChunkData", at = @At("TAIL"))
20+
public void handleChunkData(SPacketChunkData packetIn, CallbackInfo ci) {
21+
LambdaEventBus.INSTANCE.post(new ChunkDataEvent(packetIn.isFullChunk(), this.world.getChunk(packetIn.getChunkX(), packetIn.getChunkZ())));
22+
}
23+
}

src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java

Lines changed: 93 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import net.minecraft.inventory.IInventory;
2525
import net.minecraft.network.play.client.CPacketEntityAction;
2626
import net.minecraft.network.play.client.CPacketPlayer;
27+
import net.minecraft.util.MovementInput;
28+
import net.minecraft.util.math.AxisAlignedBB;
2729
import net.minecraft.util.math.Vec3d;
2830
import net.minecraft.world.IInteractionObject;
2931
import net.minecraft.world.World;
@@ -37,9 +39,16 @@
3739
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3840
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3941

42+
import java.util.Objects;
43+
4044
@Mixin(value = EntityPlayerSP.class, priority = Integer.MAX_VALUE)
4145
public abstract class MixinEntityPlayerSP extends EntityPlayer {
4246
@Shadow @Final public NetHandlerPlayClient connection;
47+
@Shadow public MovementInput movementInput;
48+
@Shadow public float renderArmYaw;
49+
@Shadow public float renderArmPitch;
50+
@Shadow public float prevRenderArmYaw;
51+
@Shadow public float prevRenderArmPitch;
4352
@Shadow protected Minecraft mc;
4453
@Shadow private double lastReportedPosX;
4554
@Shadow private double lastReportedPosY;
@@ -56,9 +65,6 @@ public MixinEntityPlayerSP(World worldIn, GameProfile gameProfileIn) {
5665
super(worldIn, gameProfileIn);
5766
}
5867

59-
@Shadow
60-
protected abstract boolean isCurrentViewEntity();
61-
6268
@Shadow
6369
protected abstract void updateAutoJump(float p_189810_1_, float p_189810_2_);
6470

@@ -89,7 +95,7 @@ private void onPushOutOfBlocks(CallbackInfoReturnable<Boolean> callbackInfoRetur
8995
public void onDisplayGUIChest(IInventory chestInventory, CallbackInfo ci) {
9096
if (BeaconSelector.INSTANCE.isEnabled()) {
9197
if (chestInventory instanceof IInteractionObject && "minecraft:beacon".equals(((IInteractionObject) chestInventory).getGuiID())) {
92-
Minecraft.getMinecraft().displayGuiScreen(new LambdaGuiBeacon(this.inventory, chestInventory));
98+
Minecraft.getMinecraft().displayGuiScreen(new LambdaGuiBeacon(inventory, chestInventory));
9399
ci.cancel();
94100
}
95101
}
@@ -104,11 +110,11 @@ public void moveHead(MoverType type, double x, double y, double z, CallbackInfo
104110
LambdaEventBus.INSTANCE.post(event);
105111

106112
if (event.isModified()) {
107-
double prevX = this.posX;
108-
double prevZ = this.posZ;
113+
double prevX = posX;
114+
double prevZ = posZ;
109115

110116
super.move(type, event.getX(), event.getY(), event.getZ());
111-
this.updateAutoJump((float) (this.posX - prevX), (float) (this.posZ - prevZ));
117+
updateAutoJump((float) (posX - prevX), (float) (posZ - prevZ));
112118

113119
ci.cancel();
114120
}
@@ -123,11 +129,50 @@ public boolean modifySprinting(boolean sprinting) {
123129
}
124130
}
125131

126-
// We have to return true here so it would still update movement inputs from Baritone and send packets
127-
@Inject(method = "isCurrentViewEntity", at = @At("RETURN"), cancellable = true)
128-
protected void mixinIsCurrentViewEntity(CallbackInfoReturnable<Boolean> cir) {
129-
if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null) {
130-
cir.setReturnValue(mc.getRenderViewEntity() == Freecam.INSTANCE.getCameraGuy());
132+
// Cannot use an inject in isCurrentViewEntity due to rusherhack redirecting it here
133+
@Inject(method = "onUpdateWalkingPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;isCurrentViewEntity()Z"), cancellable = true)
134+
protected void mixinUpdateWalkingPlayerCompat(CallbackInfo ci) {
135+
if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null && Objects.equals(this, mc.player)) {
136+
ci.cancel();
137+
// we need to perform the same actions as what is in the mc method
138+
++positionUpdateTicks;
139+
final AxisAlignedBB boundingBox = getEntityBoundingBox();
140+
final Vec3d pos = new Vec3d(posX, boundingBox.minY, posZ);
141+
final Vec2f rot = new Vec2f(rotationYaw, rotationPitch);
142+
final boolean isMoving = isMoving(pos);
143+
final boolean isRotating = isRotating(rot);
144+
sendPlayerPacket(isMoving, isRotating, pos, rot);
145+
if (isMoving) {
146+
lastReportedPosX = pos.x;
147+
lastReportedPosY = pos.y;
148+
lastReportedPosZ = pos.z;
149+
positionUpdateTicks = 0;
150+
}
151+
152+
if (isRotating) {
153+
lastReportedYaw = rot.getX();
154+
lastReportedPitch = rot.getY();
155+
}
156+
157+
prevOnGround = onGround;
158+
autoJumpEnabled = mc.gameSettings.autoJump;
159+
}
160+
}
161+
162+
// Cannot use an inject in isCurrentViewEntity due to rusherhack redirecting it here
163+
@Inject(method = "updateEntityActionState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;isCurrentViewEntity()Z"), cancellable = true)
164+
protected void mixinEntityActionState(CallbackInfo ci) {
165+
if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null && Objects.equals(this, mc.player)) {
166+
ci.cancel();
167+
168+
// we need to perform the same actions as what is in the mc method
169+
moveStrafing = movementInput.moveStrafe;
170+
moveForward = movementInput.moveForward;
171+
isJumping = movementInput.jump;
172+
prevRenderArmYaw = renderArmYaw;
173+
prevRenderArmPitch = renderArmPitch;
174+
renderArmPitch = renderArmPitch + (rotationPitch - renderArmPitch) * 0.5f;
175+
renderArmYaw = renderArmYaw + (rotationYaw - renderArmYaw) * 0.5f;
131176
}
132177
}
133178

@@ -141,23 +186,25 @@ private void onUpdateInvokeOnUpdateWalkingPlayer(CallbackInfo ci) {
141186
Vec3d serverSidePos = PlayerPacketManager.INSTANCE.getServerSidePosition();
142187
Vec2f serverSideRotation = PlayerPacketManager.INSTANCE.getPrevServerSideRotation();
143188

144-
this.lastReportedPosX = serverSidePos.x;
145-
this.lastReportedPosY = serverSidePos.y;
146-
this.lastReportedPosZ = serverSidePos.z;
189+
lastReportedPosX = serverSidePos.x;
190+
lastReportedPosY = serverSidePos.y;
191+
lastReportedPosZ = serverSidePos.z;
147192

148-
this.lastReportedYaw = serverSideRotation.getX();
149-
this.lastReportedPitch = serverSideRotation.getY();
193+
lastReportedYaw = serverSideRotation.getX();
194+
lastReportedPitch = serverSideRotation.getY();
150195
}
151196

152197
@Inject(method = "onUpdateWalkingPlayer", at = @At("HEAD"), cancellable = true)
153198
private void onUpdateWalkingPlayerHead(CallbackInfo ci) {
199+
if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null
200+
&& Objects.equals(this, Freecam.INSTANCE.getCameraGuy())) return;
154201

155202
CriticalsUpdateWalkingEvent criticalsEditEvent = new CriticalsUpdateWalkingEvent();
156203
LambdaEventBus.INSTANCE.post(criticalsEditEvent);
157204

158205
// Setup flags
159-
Vec3d position = new Vec3d(this.posX, this.getEntityBoundingBox().minY, this.posZ);
160-
Vec2f rotation = new Vec2f(this.rotationYaw, this.rotationPitch);
206+
Vec3d position = new Vec3d(posX, getEntityBoundingBox().minY, posZ);
207+
Vec2f rotation = new Vec2f(rotationYaw, rotationPitch);
161208
boolean moving = isMoving(position);
162209
boolean rotating = isRotating(rotation);
163210

@@ -181,76 +228,71 @@ private void onUpdateWalkingPlayerHead(CallbackInfo ci) {
181228
sendSneakPacket();
182229
sendPlayerPacket(moving, rotating, position, rotation);
183230

184-
this.prevOnGround = onGround;
231+
prevOnGround = onGround;
185232
}
186233

187-
++this.positionUpdateTicks;
188-
this.autoJumpEnabled = this.mc.gameSettings.autoJump;
234+
++positionUpdateTicks;
235+
autoJumpEnabled = mc.gameSettings.autoJump;
189236
}
190237

191238
event = event.nextPhase();
192239
LambdaEventBus.INSTANCE.post(event);
193240
}
194241

195242
private void sendSprintPacket() {
196-
boolean sprinting = this.isSprinting();
243+
boolean sprinting = isSprinting();
197244

198-
if (sprinting != this.serverSprintState) {
245+
if (sprinting != serverSprintState) {
199246
if (sprinting) {
200-
this.connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.START_SPRINTING));
247+
connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.START_SPRINTING));
201248
} else {
202-
this.connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.STOP_SPRINTING));
249+
connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.STOP_SPRINTING));
203250
}
204-
this.serverSprintState = sprinting;
251+
serverSprintState = sprinting;
205252
}
206253
}
207254

208255
private void sendSneakPacket() {
209-
boolean sneaking = this.isSneaking();
256+
boolean sneaking = isSneaking();
210257

211-
if (sneaking != this.serverSneakState) {
258+
if (sneaking != serverSneakState) {
212259
if (sneaking) {
213-
this.connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.START_SNEAKING));
260+
connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.START_SNEAKING));
214261
} else {
215-
this.connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.STOP_SNEAKING));
262+
connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.STOP_SNEAKING));
216263
}
217-
this.serverSneakState = sneaking;
264+
serverSneakState = sneaking;
218265
}
219266
}
220267

221268
private void sendPlayerPacket(boolean moving, boolean rotating, Vec3d position, Vec2f rotation) {
222-
if (!this.isCurrentViewEntity()) return;
223-
224-
if (this.isRiding()) {
225-
this.connection.sendPacket(new CPacketPlayer.PositionRotation(this.motionX, -999.0D, this.motionZ, rotation.getX(), rotation.getY(), onGround));
269+
if (isRiding()) {
270+
connection.sendPacket(new CPacketPlayer.PositionRotation(motionX, -999.0D, motionZ, rotation.getX(), rotation.getY(), onGround));
226271
moving = false;
227272
} else if (moving && rotating) {
228-
this.connection.sendPacket(new CPacketPlayer.PositionRotation(position.x, position.y, position.z, rotation.getX(), rotation.getY(), onGround));
273+
connection.sendPacket(new CPacketPlayer.PositionRotation(position.x, position.y, position.z, rotation.getX(), rotation.getY(), onGround));
229274
} else if (moving) {
230-
this.connection.sendPacket(new CPacketPlayer.Position(position.x, position.y, position.z, onGround));
275+
connection.sendPacket(new CPacketPlayer.Position(position.x, position.y, position.z, onGround));
231276
} else if (rotating) {
232-
this.connection.sendPacket(new CPacketPlayer.Rotation(rotation.getX(), rotation.getY(), onGround));
233-
} else if (this.prevOnGround != onGround) {
234-
this.connection.sendPacket(new CPacketPlayer(onGround));
277+
connection.sendPacket(new CPacketPlayer.Rotation(rotation.getX(), rotation.getY(), onGround));
278+
} else if (prevOnGround != onGround) {
279+
connection.sendPacket(new CPacketPlayer(onGround));
235280
}
236281

237-
if (moving) {
238-
this.positionUpdateTicks = 0;
239-
}
282+
if (moving) positionUpdateTicks = 0;
240283
}
241284

242285
private boolean isMoving(Vec3d position) {
243-
double xDiff = position.x - this.lastReportedPosX;
244-
double yDiff = position.y - this.lastReportedPosY;
245-
double zDiff = position.z - this.lastReportedPosZ;
286+
double xDiff = position.x - lastReportedPosX;
287+
double yDiff = position.y - lastReportedPosY;
288+
double zDiff = position.z - lastReportedPosZ;
246289

247-
return this.positionUpdateTicks >= 20 || xDiff * xDiff + yDiff * yDiff + zDiff * zDiff > 9.0E-4D;
290+
return positionUpdateTicks >= 20 || xDiff * xDiff + yDiff * yDiff + zDiff * zDiff > 9.0E-4D;
248291
}
249292

250293
private boolean isRotating(Vec2f rotation) {
251-
double yawDiff = rotation.getX() - this.lastReportedYaw;
252-
double pitchDiff = rotation.getY() - this.lastReportedPitch;
253-
294+
double yawDiff = rotation.getX() - lastReportedYaw;
295+
double pitchDiff = rotation.getY() - lastReportedPitch;
254296
return yawDiff != 0.0D || pitchDiff != 0.0D;
255297
}
256298
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.lambda.mixin.world;
22

33
import com.lambda.client.module.modules.misc.AntiWeather;
4+
import com.lambda.client.module.modules.render.TimeWarp;
45
import com.lambda.client.module.modules.render.NoRender;
56
import net.minecraft.util.math.BlockPos;
67
import net.minecraft.world.EnumSkyBlock;
@@ -32,4 +33,10 @@ private void getRainStrengthHead(float delta, CallbackInfoReturnable<Float> cir)
3233
cir.setReturnValue(0.0f);
3334
}
3435
}
36+
37+
@Inject(method = "getWorldTime", at = @At("HEAD"), cancellable = true)
38+
public void onGetWorldTime(CallbackInfoReturnable<Long> cir) {
39+
if (TimeWarp.INSTANCE.isEnabled())
40+
cir.setReturnValue(TimeWarp.INSTANCE.getUpdatedTime());
41+
}
3542
}

src/main/kotlin/com/lambda/client/LambdaMod.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class LambdaMod {
2929
const val ID = "lambda"
3030
const val DIRECTORY = "lambda"
3131

32-
const val VERSION = "3.2.1"
32+
const val VERSION = "3.3.0"
3333

3434
const val APP_ID = 835368493150502923 // DiscordIPC
3535
const val DEPENDENCIES = "required-after:forge@[14.23.5.2860,);"

src/main/kotlin/com/lambda/client/command/Args.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.lambda.client.util.*
1414
import com.lambda.client.util.threads.runSafeR
1515
import kotlinx.coroutines.Dispatchers
1616
import net.minecraft.block.Block
17+
import net.minecraft.entity.EntityList
1718
import net.minecraft.item.Item
1819
import net.minecraft.util.math.BlockPos
1920
import java.io.File
@@ -94,6 +95,21 @@ class BlockArg(
9495
}
9596
}
9697

98+
class EntityArg(
99+
override val name: String
100+
) : AbstractArg<String>(), AutoComplete by StaticPrefixMatch(allEntityNames) {
101+
override suspend fun convertToType(string: String?): String? {
102+
if (string == null) return null
103+
// checks if a valid entity class is registered with this name
104+
return if (EntityList.getClassFromName(string) != null) string else null
105+
}
106+
107+
private companion object {
108+
val allEntityNames = EntityList.getEntityNameList().map { it.path }
109+
}
110+
}
111+
112+
97113
class BaritoneBlockArg(
98114
override val name: String
99115
) : AbstractArg<Block>(), AutoComplete by StaticPrefixMatch(baritoneBlockNames) {

src/main/kotlin/com/lambda/client/command/ClientCommand.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.lambda.client.command
22

33
import com.lambda.client.capeapi.PlayerProfile
4-
import com.lambda.client.command.CommandBuilder
54
import com.lambda.client.command.args.AbstractArg
65
import com.lambda.client.command.utils.BuilderBlock
76
import com.lambda.client.command.utils.ExecuteBlock
@@ -51,6 +50,14 @@ abstract class ClientCommand(
5150
arg(BlockArg(name), block)
5251
}
5352

53+
@CommandBuilder
54+
protected inline fun AbstractArg<*>.entity(
55+
name: String,
56+
entity: BuilderBlock<String>
57+
) {
58+
arg(EntityArg(name), entity)
59+
}
60+
5461
@CommandBuilder
5562
protected inline fun AbstractArg<*>.item(
5663
name: String,

0 commit comments

Comments
 (0)