aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/ambientaddons/mixin/MixinPlayerControllerMP.java
blob: e62f34008b1b4739bd13bd02e8295979a78454f0 (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
package com.ambientaddons.mixin;

import com.ambientaddons.events.GuiContainerEvent;
import com.ambientaddons.events.HitBlockEvent;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.inventory.Slot;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
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.CallbackInfoReturnable;

@Mixin(PlayerControllerMP.class)
public abstract class MixinPlayerControllerMP {

    @Inject(method = "clickBlock", at = @At("HEAD"), cancellable = true)
    private void onClickBlock(BlockPos loc, EnumFacing face, CallbackInfoReturnable<Boolean> cir) {
        if (MinecraftForge.EVENT_BUS.post(new HitBlockEvent(loc, face))) {
            cir.setReturnValue(false);
        }
    }
}