package net.silentchaos512.gems.item.tool;

import java.util.List;

import com.google.common.collect.Lists;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.silentchaos512.gems.api.lib.EnumMaterialGrade;
import net.silentchaos512.gems.api.lib.EnumPartPosition;
import net.silentchaos512.gems.api.tool.part.ToolPartRegistry;
import net.silentchaos512.gems.item.ModItems;
import net.silentchaos512.gems.lib.EnumGem;
import net.silentchaos512.gems.lib.Names;
import net.silentchaos512.gems.util.ToolHelper;

public class ItemGemKatana extends ItemGemSword {

  @Override
  public ItemStack constructTool(ItemStack rod, ItemStack... materials) {

    ItemStack result = ToolHelper.constructTool(this, rod, materials);
    if (result != null) {
      ToolHelper.setPart(result,
          ToolPartRegistry
              .fromStack(new ItemStack(Blocks.WOOL, 1, EnumDyeColor.BLACK.getMetadata())),
          EnumMaterialGrade.NONE, EnumPartPosition.ROD_GRIP);
    }
    return result;
  }

  @Override
  public float getMeleeDamage(ItemStack tool) {

    return getBaseMeleeDamageModifier() + ToolHelper.getMeleeDamage(tool);
  }

  @Override
  public float getMagicDamage(ItemStack tool) {

    return 3.0f + ToolHelper.getMagicDamage(tool);
  }

  @Override
  public float getBaseMeleeDamageModifier() {

    return 3.0f;
  }

  @Override
  public float getBaseMeleeSpeedModifier() {

    return -2.2f;
  }

  @Override
  public void getSubItems(Item item, CreativeTabs tab, List list) {

    if (subItems == null) {
      subItems = ToolHelper.getSubItems(item, 3);
    }
    list.addAll(subItems);
  }

  @Override
  public void addRecipes() {

    String line1 = "gg";
    String line2 = "g ";
    String line3 = "s ";
    for (EnumGem gem : EnumGem.values()) {
      GameRegistry.addRecipe(new ShapedOreRecipe(constructTool(true, gem.getItemSuper()), line1,
          line2, line3, 'g', gem.getItemSuper(), 's', ModItems.craftingMaterial.toolRodGold));
    }
  }

  @Override
  public String getName() {

    return Names.KATANA;
  }
}

@@ -65,49 +65,8 @@
 t;%0A%0A
-import com.google.common.collect.Lists;%0A%0A
 impo
@@ -108,16 +108,16 @@
 veTabs;%0A
+
 import n
@@ -142,16 +142,49 @@
 Blocks;%0A
+import net.minecraft.init.Items;%0A
 import n
@@ -971,115 +971,485 @@
     
-if (result != null
+return addDefaultGrip(result);%0A  %7D%0A%0A  @Override%0A  public ItemStack constructTool(boolean supercharged, ItemStack... materials
 ) %7B%0A
+%0A
     
-  ToolHelper.setPart
+ItemStack rod = supercharged ? ModItems.craftingMaterial.toolRodGold%0A        : new ItemStack(Items.STICK);%0A    ItemStack result = ToolHelper.constructTool(this, rod, materials);%0A    return addDefaultGrip
 (result
-,%0A          ToolPartRegistry%0A              .fromStack(
+);%0A  %7D%0A%0A  private ItemStack addDefaultGrip(ItemStack katana) %7B%0A%0A    if (katana == null)%0A      return null;%0A    ItemStack blackWool = 
 new 
@@ -1511,20 +1511,79 @@
 a())
-),
+;
 %0A    
-     
+ToolHelper.setPart(katana, ToolPartRegistry.fromStack(blackWool),
  Enu
@@ -1602,16 +1602,24 @@
 de.NONE,
+%0A       
  EnumPar
@@ -1639,22 +1639,16 @@
 _GRIP);%0A
-    %7D%0A
     retu
@@ -1650,22 +1650,22 @@
  return 
-result
+katana
 ;%0A  %7D%0A%0A 
@@ -2188,24 +2188,24 @@
  == null) %7B%0A
-
       subIte
@@ -2242,16 +2242,104 @@
 em, 3);%0A
+      for (ItemStack stack : subItems) %7B%0A        stack = addDefaultGrip(stack);%0A      %7D%0A
     %7D%0A  

Fix katanas missing default grip.