package ru.dbotthepony.mc.otm.mixin;

import net.minecraft.client.Minecraft;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
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 ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability;

@Mixin(Minecraft.class)
public class MixinMinecraft {
	@Redirect(
		method = "pickBlock()V",
		at = @At(
			value = "INVOKE",
			target = "Lnet/minecraft/world/entity/player/Inventory;findSlotMatchingItem(Lnet/minecraft/world/item/ItemStack;)I"
		)
	)
	private int pickBlock(Inventory inventory, ItemStack itemStack) {
		int i = inventory.findSlotMatchingItem(itemStack);

		MatteryPlayerCapability.pickBlockHook(i, itemStack);

		return i;
	}
}
