-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMinecraftClientMixin.java
More file actions
56 lines (47 loc) · 2.32 KB
/
MinecraftClientMixin.java
File metadata and controls
56 lines (47 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.lambda.mixin;
import com.lambda.Lambda;
import com.lambda.event.EventFlow;
import com.lambda.event.events.ClientEvent;
import com.lambda.event.events.TickEvent;
import com.lambda.module.modules.player.Interact;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(MinecraftClient.class)
public class MinecraftClientMixin {
@Inject(method = "tick", at = @At("HEAD"))
void onTickPre(CallbackInfo ci) {
EventFlow.post(new TickEvent.Pre());
}
@Inject(method = "tick", at = @At("RETURN"))
void onTickPost(CallbackInfo ci) {
EventFlow.post(new TickEvent.Post());
}
@Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;)V", shift = At.Shift.AFTER, remap = false), method = "stop")
private void onShutdown(CallbackInfo ci) {
EventFlow.post(new ClientEvent.Shutdown());
}
/**
* Inject after the thread field is set so `ThreadExecutor#getThread` is available
*/
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;thread:Ljava/lang/Thread;", shift = At.Shift.AFTER, ordinal = 0), method = "run")
private void onStartup(CallbackInfo ci) {
EventFlow.post(new ClientEvent.Startup());
}
@Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
boolean injectMultiActon(ClientPlayerInteractionManager instance) {
if (instance == null) return true;
if (Interact.INSTANCE.isEnabled() && Interact.getMultiAction()) return false;
return instance.isBreakingBlock();
}
@Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isRiding()Z"))
void injectFastPlace(CallbackInfo ci) {
if (!Interact.INSTANCE.isEnabled()) return;
Lambda.getMc().itemUseCooldown = Interact.getPlaceDelay();
}
}