-
Notifications
You must be signed in to change notification settings - Fork 3
/
MinecraftClientMixin.java
41 lines (33 loc) · 1.53 KB
/
MinecraftClientMixin.java
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
package com.jorianwoltjer.liveoverflowmod.mixin;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.debug.DebugRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.hit.EntityHitResult;
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.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Optional;
import static com.jorianwoltjer.liveoverflowmod.client.ClientEntrypoint.clipReachHack;
import static com.jorianwoltjer.liveoverflowmod.client.ClientEntrypoint.reachHack;
@Mixin(MinecraftClient.class)
public class MinecraftClientMixin {
private void updateCrossairTarget() {
if (reachHack.enabled || clipReachHack.enabled) {
MinecraftClient client = MinecraftClient.getInstance();
Optional<Entity> entity = DebugRenderer.getTargetedEntity(client.player, 100);
entity.ifPresent(e -> client.crosshairTarget = new EntityHitResult(e));
}
}
// Extend reach for attack
@Inject(method = "doAttack", at = @At(value = "HEAD"))
private void doAttack(CallbackInfoReturnable<Boolean> cir) {
updateCrossairTarget();
}
// Extend reach for interact
@Inject(method = "doItemUse", at = @At(value = "HEAD"))
private void doItemUse(CallbackInfo ci) {
updateCrossairTarget();
}
}