Skip to content

Commit 478dd20

Browse files
committed
Request system, Rotation request rework, HotbarManager
1 parent 0fbd682 commit 478dd20

File tree

75 files changed

+1571
-770
lines changed

Some content is hidden

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

75 files changed

+1571
-770
lines changed

common/src/main/java/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import baritone.Baritone;
2121
import baritone.api.utils.Rotation;
2222
import baritone.utils.player.BaritonePlayerContext;
23-
import com.lambda.interaction.RotationManager;
23+
import com.lambda.interaction.request.rotation.RotationManager;
2424
import com.lambda.util.BaritoneUtils;
2525
import org.spongepowered.asm.mixin.Final;
2626
import org.spongepowered.asm.mixin.Mixin;

common/src/main/java/com/lambda/mixin/baritone/MixinLookBehavior.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import baritone.api.event.events.RotationMoveEvent;
2222
import baritone.api.utils.Rotation;
2323
import baritone.behavior.LookBehavior;
24-
import com.lambda.interaction.RotationManager;
24+
import com.lambda.interaction.request.rotation.RotationManager;
2525
import com.lambda.util.BaritoneUtils;
2626
import org.spongepowered.asm.mixin.Mixin;
2727
import org.spongepowered.asm.mixin.injection.At;

common/src/main/java/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
package com.lambda.mixin.entity;
1919

2020
import com.lambda.event.EventFlow;
21+
import com.lambda.event.events.InventoryEvent;
2122
import com.lambda.event.events.PlayerEvent;
2223
import net.minecraft.client.network.ClientPlayerEntity;
2324
import net.minecraft.client.network.ClientPlayerInteractionManager;
2425
import net.minecraft.entity.Entity;
2526
import net.minecraft.entity.player.PlayerEntity;
27+
import net.minecraft.entity.player.PlayerInventory;
2628
import net.minecraft.screen.slot.SlotActionType;
2729
import net.minecraft.util.ActionResult;
2830
import net.minecraft.util.Hand;
@@ -34,6 +36,7 @@
3436
import org.spongepowered.asm.mixin.Shadow;
3537
import org.spongepowered.asm.mixin.injection.At;
3638
import org.spongepowered.asm.mixin.injection.Inject;
39+
import org.spongepowered.asm.mixin.injection.Redirect;
3740
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3841
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3942

@@ -83,6 +86,11 @@ public void clickSlotHead(int syncId, int slotId, int button, SlotActionType act
8386
if (EventFlow.post(click).isCanceled()) ci.cancel();
8487
}
8588

89+
@Redirect(method = "syncSelectedSlot", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerInventory;selectedSlot:I"))
90+
public int overrideSelectedSlotSync(PlayerInventory instance) {
91+
return EventFlow.post(new InventoryEvent.HotbarSlot.Update(instance.selectedSlot)).getSlot();
92+
}
93+
8694
@Inject(method = "updateBlockBreakingProgress", at = @At("HEAD"), cancellable = true)
8795
private void updateBlockBreakingProgressPre(BlockPos pos, Direction side, CallbackInfoReturnable<Boolean> cir) {
8896
var event = EventFlow.post(new PlayerEvent.Breaking.Update(pos, side, currentBreakingProgress));

common/src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.lambda.event.events.PlayerEvent;
2424
import com.lambda.event.events.TickEvent;
2525
import com.lambda.interaction.PlayerPacketManager;
26-
import com.lambda.interaction.RotationManager;
26+
import com.lambda.interaction.request.rotation.RotationManager;
2727
import net.minecraft.client.input.Input;
2828
import net.minecraft.client.network.ClientPlayerEntity;
2929
import net.minecraft.entity.MovementType;
@@ -97,8 +97,6 @@ void sendBegin(CallbackInfo ci) {
9797
ci.cancel();
9898
PlayerPacketManager.sendPlayerPackets();
9999
autoJumpEnabled = Lambda.getMc().options.getAutoJump().getValue();
100-
101-
RotationManager.update();
102100
}
103101

104102
@Inject(method = "tick", at = @At(value = "HEAD"))

common/src/main/java/com/lambda/mixin/entity/EntityMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.lambda.event.EventFlow;
2222
import com.lambda.event.events.EntityEvent;
2323
import com.lambda.event.events.PlayerEvent;
24-
import com.lambda.interaction.RotationManager;
24+
import com.lambda.interaction.request.rotation.RotationManager;
2525
import com.lambda.util.math.Vec2d;
2626
import net.minecraft.entity.Entity;
2727
import net.minecraft.entity.MovementType;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.lambda.Lambda;
2121
import com.lambda.event.EventFlow;
2222
import com.lambda.event.events.MovementEvent;
23-
import com.lambda.interaction.RotationManager;
23+
import com.lambda.interaction.request.rotation.RotationManager;
2424
import net.minecraft.entity.LivingEntity;
2525
import net.minecraft.util.math.MathHelper;
2626
import net.minecraft.util.math.Vec3d;

common/src/main/java/com/lambda/mixin/entity/PlayerEntityMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import com.lambda.event.EventFlow;
2121
import com.lambda.event.events.MovementEvent;
22-
import com.lambda.interaction.RotationManager;
22+
import com.lambda.interaction.request.rotation.RotationManager;
2323
import net.minecraft.client.MinecraftClient;
2424
import net.minecraft.entity.player.PlayerEntity;
2525
import org.spongepowered.asm.mixin.Mixin;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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.entity;
19+
20+
import net.minecraft.client.MinecraftClient;
21+
import net.minecraft.client.network.ClientPlayerInteractionManager;
22+
import net.minecraft.entity.player.PlayerInventory;
23+
import net.minecraft.item.ItemStack;
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.CallbackInfoReturnable;
28+
29+
import static net.minecraft.entity.player.PlayerInventory.isValidHotbarIndex;
30+
31+
@Mixin(PlayerInventory.class)
32+
public class PlayerInventoryMixin {
33+
@Inject(method = "getMainHandStack", at = @At(value = "HEAD"), cancellable = true)
34+
public void handleSpoofedMainHandStack(CallbackInfoReturnable<ItemStack> cir) {
35+
PlayerInventory instance = (PlayerInventory) (Object) this;
36+
MinecraftClient mc = MinecraftClient.getInstance();
37+
ClientPlayerInteractionManager interaction = mc.interactionManager;
38+
39+
if (instance.player != mc.player || interaction == null) return;
40+
41+
int actualSlot = interaction.lastSelectedSlot;
42+
43+
cir.setReturnValue(
44+
isValidHotbarIndex(actualSlot) ? instance.main.get(actualSlot) : ItemStack.EMPTY
45+
);
46+
}
47+
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,19 @@
1919

2020
import com.lambda.event.EventFlow;
2121
import com.lambda.event.events.InventoryEvent;
22-
import com.lambda.event.events.WorldEvent;
2322
import net.minecraft.client.network.ClientPlayNetworkHandler;
2423
import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
2524
import net.minecraft.network.packet.s2c.play.UpdateSelectedSlotS2CPacket;
26-
import net.minecraft.world.explosion.Explosion;
2725
import org.spongepowered.asm.mixin.Mixin;
2826
import org.spongepowered.asm.mixin.injection.At;
2927
import org.spongepowered.asm.mixin.injection.Inject;
30-
import org.spongepowered.asm.mixin.injection.Redirect;
3128
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3229

3330
@Mixin(ClientPlayNetworkHandler.class)
3431
public class ClientPlayNetworkHandlerMixin {
35-
@Inject(method = "onUpdateSelectedSlot", at = @At("TAIL"))
32+
@Inject(method = "onUpdateSelectedSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER), cancellable = true)
3633
private void onUpdateSelectedSlot(UpdateSelectedSlotS2CPacket packet, CallbackInfo ci) {
37-
EventFlow.post(new InventoryEvent.SelectedHotbarSlotUpdate(packet.getSlot()));
34+
if (EventFlow.post(new InventoryEvent.HotbarSlot.Sync(packet.getSlot())).isCanceled()) ci.cancel();
3835
}
3936

4037
@Inject(method = "onScreenHandlerSlotUpdate", at = @At("TAIL"))

common/src/main/java/com/lambda/mixin/render/CameraMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.mixin.render;
1919

20-
import com.lambda.interaction.RotationManager;
20+
import com.lambda.interaction.request.rotation.RotationManager;
2121
import com.lambda.module.modules.player.Freecam;
2222
import com.lambda.module.modules.render.CameraTweaks;
2323
import net.minecraft.client.render.Camera;

0 commit comments

Comments
 (0)