Skip to content

Commit a05bb88

Browse files
committed
Baritone Soft Dependency and even more mixins
1 parent 20f155a commit a05bb88

File tree

18 files changed

+83
-61
lines changed

18 files changed

+83
-61
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ dependencies {
176176

177177
// Add mods
178178
/*modImplementation("com.github.rfresh2:baritone-fabric:$minecraftVersion") */
179-
modImplementation("com.github.rfresh2:baritone-fabric:1.21.10-SNAPSHOT") // ToDo: Move to 1.21.11
179+
modCompileOnly("com.github.rfresh2:baritone-fabric:1.21.10-SNAPSHOT") // ToDo: Move to 1.21.11
180180
modCompileOnly("maven.modrinth:sodium:$sodiumVersion")
181181
modCompileOnly("maven.modrinth:malilib:$maLiLibVersion")
182182
modCompileOnly("maven.modrinth:litematica:$litematicaVersion")

src/main/java/com/lambda/mixin/client/sound/SoundSystemMixin.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
import org.spongepowered.asm.mixin.injection.At;
2626
import org.spongepowered.asm.mixin.injection.Inject;
2727
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
28+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
2829

2930
@Mixin(SoundSystem.class)
3031
public class SoundSystemMixin {
31-
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At("HEAD"), cancellable = true)
32-
public void onPlay(SoundInstance sound, CallbackInfo ci) {
32+
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)Lnet/minecraft/client/sound/SoundSystem$PlayResult;", at = @At("HEAD"), cancellable = true)
33+
public void onPlay(SoundInstance sound, CallbackInfoReturnable<SoundSystem.PlayResult> cir) {
3334
if (EventFlow.post(new ClientEvent.Sound(sound)).isCanceled()) {
34-
ci.cancel();
35+
cir.setReturnValue(SoundSystem.PlayResult.NOT_STARTED);
3536
}
3637
}
3738
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ private void cancelBlockBreakingPre(CallbackInfo ci) {
121121
if (EventFlow.post(new PlayerEvent.Breaking.Cancel(currentBreakingProgress)).isCanceled()) ci.cancel();
122122
}
123123

124-
@WrapMethod(method = "createPlayer(Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/stat/StatHandler;Lnet/minecraft/client/recipebook/ClientRecipeBook;ZZ)Lnet/minecraft/client/network/ClientPlayerEntity;")
125-
private ClientPlayerEntity injectCreatePlayer(ClientWorld world, StatHandler statHandler, ClientRecipeBook recipeBook, boolean lastSneaking, boolean lastSprinting, Operation<ClientPlayerEntity> original) {
126-
var player = original.call(world, statHandler, recipeBook, lastSneaking, lastSprinting);
124+
@WrapMethod(method = "createPlayer(Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/stat/StatHandler;Lnet/minecraft/client/recipebook/ClientRecipeBook;)Lnet/minecraft/client/network/ClientPlayerEntity;")
125+
private ClientPlayerEntity wrapCreatePlayer(ClientWorld world, StatHandler statHandler, ClientRecipeBook recipeBook, Operation<ClientPlayerEntity> original) {
126+
var player = original.call(world, statHandler, recipeBook);
127127
InventoryManager.INSTANCE.setScreenHandler(player.playerScreenHandler);
128128
return player;
129129
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ private float rotHead(LivingEntity entity, Operation<Float> original) {
170170
return (yaw == null) ? original.call(entity) : yaw;
171171
}
172172

173-
@ModifyConstant(method = "getHandSwingDuration", constant = @Constant(intValue = 6))
174-
private int getHandSwingDuration(int constant) {
175-
if (lambda$instance != Lambda.getMc().player || ViewModel.INSTANCE.isDisabled()) return constant;
173+
@WrapMethod(method = "getHandSwingDuration")
174+
private int getHandSwingDuration(Operation<Integer> original) {
175+
if (lambda$instance != Lambda.getMc().player || ViewModel.INSTANCE.isDisabled()) return original.call();
176176

177177
return ViewModel.INSTANCE.getSwingDuration();
178178
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ private float wrapHeadYaw(PlayerEntity instance, Operation<Float> original) {
4747
return (yaw != null) ? yaw : original.call(instance);
4848
}
4949

50-
@WrapOperation(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getYaw()F"))
51-
private float wrapAttackYaw(PlayerEntity instance, Operation<Float> original) {
52-
if ((Object) this != Lambda.getMc().player) {
53-
return original.call(instance);
54-
}
55-
56-
Float yaw = RotationManager.getMovementYaw();
57-
return (yaw != null) ? yaw : original.call(instance);
58-
}
50+
// @WrapOperation(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getYaw()F"))
51+
// private float wrapAttackYaw(PlayerEntity instance, Operation<Float> original) {
52+
// if ((Object) this != Lambda.getMc().player) {
53+
// return original.call(instance);
54+
// }
55+
//
56+
// Float yaw = RotationManager.getMovementYaw();
57+
// return (yaw != null) ? yaw : original.call(instance);
58+
// }
5959
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
2626
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
2727
import net.minecraft.client.Mouse;
28+
import net.minecraft.client.input.MouseInput;
2829
import net.minecraft.client.option.SimpleOption;
2930
import org.spongepowered.asm.mixin.Mixin;
3031
import org.spongepowered.asm.mixin.Shadow;
@@ -36,10 +37,10 @@ public class MouseMixin {
3637

3738
@Shadow private double y;
3839

39-
@WrapMethod(method = "onMouseButton(JIII)V")
40-
private void onMouseButton(long window, int button, int action, int mods, Operation<Void> original) {
41-
if (!EventFlow.post(new MouseEvent.Click(button, action, mods)).isCanceled())
42-
original.call(window, button, action, mods);
40+
@WrapMethod(method = "onMouseButton")
41+
private void onMouseButton(long window, MouseInput input, int action, Operation<Void> original) {
42+
if (!EventFlow.post(new MouseEvent.Click(input.button(), action, input.modifiers())).isCanceled())
43+
original.call(window, input, action);
4344
}
4445

4546
@WrapMethod(method = "onMouseScroll(JDD)V")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void injectPlayerList(PlayerListS2CPacket.Action action, PlayerListS2CPacket.Ent
5353
} else EventFlow.post(new WorldEvent.Player.Leave(name, uuid, currentEntry));
5454
}
5555

56-
@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)
56+
@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/network/PacketApplyBatcher;)V", shift = At.Shift.AFTER), cancellable = true)
5757
private void onUpdateSelectedSlot(UpdateSelectedSlotS2CPacket packet, CallbackInfo ci) {
5858
if (EventFlow.post(new InventoryEvent.HotbarSlot.Sync(packet.slot())).isCanceled()) ci.cancel();
5959
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import net.minecraft.block.entity.SignText;
2222
import net.minecraft.client.render.VertexConsumerProvider;
2323
import net.minecraft.client.render.block.entity.AbstractSignBlockEntityRenderer;
24+
import net.minecraft.client.render.block.entity.state.SignBlockEntityRenderState;
25+
import net.minecraft.client.render.command.OrderedRenderCommandQueue;
2426
import net.minecraft.client.util.math.MatrixStack;
2527
import net.minecraft.util.math.BlockPos;
2628
import org.spongepowered.asm.mixin.Mixin;
@@ -31,7 +33,7 @@
3133
@Mixin(AbstractSignBlockEntityRenderer.class)
3234
public class AbstractSignBlockEntityRendererMixin {
3335
@Inject(method = "renderText", at = @At("HEAD"), cancellable = true)
34-
private void injectRenderText(BlockPos pos, SignText text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int textLineHeight, int maxTextWidth, boolean front, CallbackInfo ci) {
36+
private void injectRenderText(SignBlockEntityRenderState renderState, MatrixStack matrices, OrderedRenderCommandQueue queue, boolean front, CallbackInfo ci) {
3537
if (NoRender.INSTANCE.isEnabled() && NoRender.getNoSignText()) ci.cancel();
3638
}
3739
}

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import net.minecraft.client.render.Camera;
2727
import net.minecraft.entity.Entity;
2828
import net.minecraft.world.BlockView;
29+
import net.minecraft.world.World;
2930
import org.spongepowered.asm.mixin.Mixin;
3031
import org.spongepowered.asm.mixin.Shadow;
3132
import org.spongepowered.asm.mixin.injection.At;
@@ -42,14 +43,7 @@ public abstract class CameraMixin {
4243
public abstract void setRotation(float yaw, float pitch);
4344

4445
@Inject(method = "update", at = @At("TAIL"))
45-
private void onUpdate(
46-
BlockView area,
47-
Entity focusedEntity,
48-
boolean thirdPerson,
49-
boolean inverseView,
50-
float tickDelta,
51-
CallbackInfo ci
52-
) {
46+
private void onUpdate(World area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickProgress, CallbackInfo ci) {
5347
if (!Freecam.INSTANCE.isEnabled()) return;
5448

5549
Freecam.updateCam();
@@ -66,7 +60,7 @@ private void onUpdate(
6660
* }</pre>
6761
*/
6862
@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V", shift = At.Shift.AFTER))
69-
private void injectQuickPerspectiveSwap(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
63+
private void injectQuickPerspectiveSwap(World area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickProgress, CallbackInfo ci) {
7064
var rot = RotationManager.getLockRotation();
7165
if (rot == null) return;
7266
setRotation(rot.getYawF(), rot.getPitchF());

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
import com.lambda.module.modules.render.NoRender;
2121
import net.minecraft.client.render.Frustum;
22-
import net.minecraft.client.render.VertexConsumerProvider;
22+
import net.minecraft.client.render.command.OrderedRenderCommandQueue;
2323
import net.minecraft.client.render.entity.EntityRenderer;
2424
import net.minecraft.client.render.entity.state.EntityRenderState;
25+
import net.minecraft.client.render.state.CameraRenderState;
2526
import net.minecraft.client.util.math.MatrixStack;
2627
import net.minecraft.entity.Entity;
27-
import net.minecraft.text.Text;
2828
import org.spongepowered.asm.mixin.Mixin;
2929
import org.spongepowered.asm.mixin.injection.At;
3030
import org.spongepowered.asm.mixin.injection.Inject;
@@ -39,7 +39,7 @@ private void injectShouldRender(Entity entity, Frustum frustum, double x, double
3939
}
4040

4141
@Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
42-
private void injectRenderLabelIfPresent(EntityRenderState state, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
42+
private void injectRenderLabelIfPresent(EntityRenderState state, MatrixStack matrices, OrderedRenderCommandQueue queue, CameraRenderState cameraRenderState, CallbackInfo ci) {
4343
if (NoRender.INSTANCE.isEnabled() && NoRender.getNoNametags()) ci.cancel();
4444
}
4545
}

0 commit comments

Comments
 (0)