-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathClientPlayInteractionManagerMixin.java
More file actions
30 lines (26 loc) · 1.19 KB
/
ClientPlayInteractionManagerMixin.java
File metadata and controls
30 lines (26 loc) · 1.19 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
package com.lambda.mixin.entity;
import com.lambda.event.EventFlow;
import com.lambda.event.events.InteractionEvent;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ClientPlayerInteractionManager.class)
public class ClientPlayInteractionManagerMixin {
@Final
@Shadow
private MinecraftClient client;
@Inject(method = "interactBlock", at = @At("HEAD"))
public void interactBlockHead(final ClientPlayerEntity player, final Hand hand, final BlockHitResult hitResult, final CallbackInfoReturnable<ActionResult> cir) {
if (client.world == null) return;
EventFlow.post(new InteractionEvent.Block(client.world, hitResult));
}
}