// Path: src/main/java/exter/substratum/item/ItemMaterial.java
// public class ItemMaterial extends Item
// {
//   public interface ISpecialHandler
//   {
//     ActionResult<ItemStack> onRightClick(ItemStack stack,ItemMaterial item,EnumMaterial material,World world, EntityPlayer player, EnumHand hand);
//     ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt);
//   }
// 
//   public final EnumMaterialItem item;
//   
//   private ISpecialHandler special = null;
// 
//   public ItemMaterial(EnumMaterialItem material_item)
//   {
//     super();
//     this.item = material_item;
//     setCreativeTab(TabMaterials.tab);
//     setHasSubtypes(true);
//     setUnlocalizedName("substratum." + material_item.prefix_lc);
//     setRegistryName(material_item.prefix_lc);
//   }
//   
//   public ItemMaterial setSpecialHandler(ISpecialHandler special)
//   {
//     this.special = special;
//     return this;
//   }
//   
//   @Override
//   public String getUnlocalizedName(ItemStack itemstack)
//   {
//     return String.format("%s_%s", getUnlocalizedName(), item.materials.get(itemstack.getMetadata()).suffix_lc);
//   }
// 
//   @Override
//   @SideOnly(Side.CLIENT)
//   public void getSubItems(Item item, CreativeTabs tabs, NonNullList<ItemStack> list)
//   {
//     int i;
//     for(i = 0; i < this.item.materials.size(); i++)
//     {
//       // Deprecate Iron Nugget TODO: Remove in later versions
//       if(this.item == EnumMaterialItem.NUGGET && this.item.materials.get(i) == EnumMaterial.IRON)
//       {
//         continue;
//       }
// 
//       if(this.item.materials.get(i) != EnumMaterial.NULL)
//       {
//         ItemStack itemstack = new ItemStack(this, 1, i);
//         list.add(itemstack);
//       }
//     }
//   }
//   
//   public int getMaterialMeta(EnumMaterial material)
//   {
//     return item.materials.indexOf(material);
//   }
// 
//   public ItemStack getStack(EnumMaterial material)
//   {
//     return getStack(material,1);
//   }
// 
//   public ItemStack getStack(EnumMaterial material,int amount)
//   {
//     int meta = getMaterialMeta(material);
//     if(meta == -1)
//     {
//       return null;
//     }
//     return new ItemStack(this,amount,meta);
//   }
//   
//   @Override
//   public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
//   {
//     ItemStack stack = player.getHeldItem(hand);
//     if(special != null)
//     {
//       return special.onRightClick(stack, this, item.materials.get(stack.getMetadata()), world, player, hand);
//     } else
//     {
//       return super.onItemRightClick(world, player, hand);
//     }
//   }
//   
//   @Override
//   public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
//   {
//     if(special != null)
//     {
//       return special.initCapabilities(stack, nbt);
//     }
//     return null;
//   }
// }


import javax.annotation.Nullable;
import exter.substratum.item.ItemMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.FluidTankProperties;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fluids.capability.IFluidTankProperties;

  @Override
  public <T> T getCapability(Capability<T> capability, EnumFacing facing)
  {
    if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
    {
      return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(this);
    }
    return null;
  }
  
  private Fluid getFluid()
  {
    return SubstratumFluids.material_fluids.get(
            ((ItemMaterial)item.getItem()).item.materials.get(item.getMetadata()));
  }

  @Override
  public IFluidTankProperties[] getTankProperties()
  {
    return new IFluidTankProperties[]{ new FluidTankProperties(new FluidStack(getFluid(),amount),amount)};
  }

  @Override
  public int fill(FluidStack resource, boolean doFill)
  {
    return 0;
  }

  @Nullable
// Path: src/main/java/exter/substratum/item/ItemMaterial.java
// public class ItemMaterial extends Item
// {
//   public interface ISpecialHandler
//   {
//     ActionResult<ItemStack> onRightClick(ItemStack stack,ItemMaterial item,EnumMaterial material,World world, EntityPlayer player, EnumHand hand);
//     ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt);
//   }
// 
//   public final EnumMaterialItem item;
//   
//   private ISpecialHandler special = null;
// 
//   public ItemMaterial(EnumMaterialItem material_item)
//   {
//     super();
//     this.item = material_item;
//     setCreativeTab(TabMaterials.tab);
//     setHasSubtypes(true);
//     setUnlocalizedName("substratum." + material_item.prefix_lc);
//     setRegistryName(material_item.prefix_lc);
//   }
//   
//   public ItemMaterial setSpecialHandler(ISpecialHandler special)
//   {
//     this.special = special;
//     return this;
//   }
//   
//   @Override
//   public String getUnlocalizedName(ItemStack itemstack)
//   {
//     return String.format("%s_%s", getUnlocalizedName(), item.materials.get(itemstack.getMetadata()).suffix_lc);
//   }
// 
//   @Override
//   @SideOnly(Side.CLIENT)
//   public void getSubItems(Item item, CreativeTabs tabs, NonNullList<ItemStack> list)
//   {
//     int i;
//     for(i = 0; i < this.item.materials.size(); i++)
//     {
//       // Deprecate Iron Nugget TODO: Remove in later versions
//       if(this.item == EnumMaterialItem.NUGGET && this.item.materials.get(i) == EnumMaterial.IRON)
//       {
//         continue;
//       }
// 
//       if(this.item.materials.get(i) != EnumMaterial.NULL)
//       {
//         ItemStack itemstack = new ItemStack(this, 1, i);
//         list.add(itemstack);
//       }
//     }
//   }
//   
//   public int getMaterialMeta(EnumMaterial material)
//   {
//     return item.materials.indexOf(material);
//   }
// 
//   public ItemStack getStack(EnumMaterial material)
//   {
//     return getStack(material,1);
//   }
// 
//   public ItemStack getStack(EnumMaterial material,int amount)
//   {
//     int meta = getMaterialMeta(material);
//     if(meta == -1)
//     {
//       return null;
//     }
//     return new ItemStack(this,amount,meta);
//   }
//   
//   @Override
//   public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
//   {
//     ItemStack stack = player.getHeldItem(hand);
//     if(special != null)
//     {
//       return special.onRightClick(stack, this, item.materials.get(stack.getMetadata()), world, player, hand);
//     } else
//     {
//       return super.onItemRightClick(world, player, hand);
//     }
//   }
//   
//   @Override
//   public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
//   {
//     if(special != null)
//     {
//       return special.initCapabilities(stack, nbt);
//     }
//     return null;
//   }
// }


// Path: src/main/java/exter/substratum/fluid/FluidContainerCapability.java
import javax.annotation.Nullable;
import exter.substratum.item.ItemMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.FluidTankProperties;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fluids.capability.IFluidTankProperties;


  @Override
  public <T> T getCapability(Capability<T> capability, EnumFacing facing)
  {
    if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
    {
      return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(this);
    }
    return null;
  }
  
  private Fluid getFluid()
  {
    return SubstratumFluids.material_fluids.get(
            ((ItemMaterial)item.getItem()).item.materials.get(item.getMetadata()));
  }

  @Override
  public IFluidTankProperties[] getTankProperties()
  {
    return new IFluidTankProperties[]{ new FluidTankProperties(new FluidStack(getFluid(),amount),amount)};
  }

  @Override
  public int fill(FluidStack resource, boolean doFill)
  {
    return 0;
  }

  @Nullable
  @Override