package com.zivilon.cinder_loe.mixins;

import lotr.common.LOTRMod;
import lotr.common.item.LOTRItemBlowgun;
import lotr.common.item.LOTRItemCrossbow;
import lotr.common.item.LOTRItemPlate;
import lotr.common.item.LOTRItemSpear;
import lotr.common.item.LOTRItemThrowingAxe;

import metweaks.guards.customranged.CustomRanged.Category;

import net.minecraft.item.Item;

import java.util.List;
import java.util.Collections;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(targets = "metweaks.guards.customranged.CustomRanged$Category")
public class MixinMETweaksCategory {
    private static Category SLING = Category.SLING;
    private static Category PLATE = Category.PLATE;
    private static Category BOW = Category.BOW;
    private static Category BLOWGUN = Category.BLOWGUN;
    private static Category AXE = Category.AXE;
    private static Category CROSSBOW = Category.CROSSBOW;
    private static Category SPEAR = Category.SPEAR;
    private static Category FIREPOT = Category.FIREPOT;
    private static Category TERMITE = Category.TERMITE;

    /**
     * @author Shinare
     * @reason Changed blowgun check from direct item check to instance check to support Limwaith blowguns
     */
    @Overwrite(remap = false)
    public static Category getCategory(Item item) {
      if (item instanceof LOTRItemCrossbow)
        return CROSSBOW;
      if (item == LOTRMod.sling)
        return SLING;
      if (item instanceof LOTRItemBlowgun)
        return BLOWGUN;
      if (item == LOTRMod.termite)
        return TERMITE;
      if (item == LOTRMod.rhunFirePot)
        return FIREPOT;
      if (item.getClass() == LOTRItemThrowingAxe.class)
        return AXE;
      if (item.getClass() == LOTRItemPlate.class && item != LOTRMod.woodPlate)
        return PLATE;
      if (item.getClass() == LOTRItemSpear.class && item != LOTRMod.spearStone)
        return SPEAR;
      return BOW;
    }
}
