aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/rosegoldaddons/mixins/MixinMinecraft.java
blob: e8426add68cfbc8fc56ea2a0132786e8f0610af7 (plain)
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
package rosegoldaddons.mixins;

import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge;
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 rosegoldaddons.events.ClickEvent;

@Mixin(Minecraft.class)
public class MixinMinecraft {
    @Inject(method = "rightClickMouse", at = @At("HEAD"), cancellable = true)
    public void rightClickEvent(CallbackInfo ci) {
        if(MinecraftForge.EVENT_BUS.post(new ClickEvent.Right())) ci.cancel();
    }

    @Inject(method = "clickMouse", at = @At("HEAD"), cancellable = true)
    public void leftClickEvent(CallbackInfo ci) {
        if(MinecraftForge.EVENT_BUS.post(new ClickEvent.Left())) ci.cancel();
    }

    @Inject(method = "middleClickMouse", at = @At("HEAD"), cancellable = true)
    public void middleClickEvent(CallbackInfo ci) {
        if(MinecraftForge.EVENT_BUS.post(new ClickEvent.Middle())) ci.cancel();
    }
}