    001package net.minecraft.item.crafting;
    002
    003import net.minecraft.inventory.InventoryCrafting;
    004import net.minecraft.item.Item;
    005import net.minecraft.item.ItemStack;
    006import net.minecraft.world.World;
    007
    008public class RecipesMapCloning implements IRecipe
    009{
    010    /**
    011     * Used to check if a recipe matches current crafting inventory
    012     */
    013    public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World)
    014    {
    015        int i = 0;
    016        ItemStack itemstack = null;
    017
    018        for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j)
    019        {
    020            ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(j);
    021
    022            if (itemstack1 != null)
    023            {
    024                if (itemstack1.itemID == Item.map.itemID)
    025                {
    026                    if (itemstack != null)
    027                    {
    028                        return false;
    029                    }
    030
    031                    itemstack = itemstack1;
    032                }
    033                else
    034                {
    035                    if (itemstack1.itemID != Item.emptyMap.itemID)
    036                    {
    037                        return false;
    038                    }
    039
    040                    ++i;
    041                }
    042            }
    043        }
    044
    045        return itemstack != null && i > 0;
    046    }
    047
    048    /**
    049     * Returns an Item that is the result of this recipe
    050     */
    051    public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting)
    052    {
    053        int i = 0;
    054        ItemStack itemstack = null;
    055
    056        for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j)
    057        {
    058            ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(j);
    059
    060            if (itemstack1 != null)
    061            {
    062                if (itemstack1.itemID == Item.map.itemID)
    063                {
    064                    if (itemstack != null)
    065                    {
    066                        return null;
    067                    }
    068
    069                    itemstack = itemstack1;
    070                }
    071                else
    072                {
    073                    if (itemstack1.itemID != Item.emptyMap.itemID)
    074                    {
    075                        return null;
    076                    }
    077
    078                    ++i;
    079                }
    080            }
    081        }
    082
    083        if (itemstack != null && i >= 1)
    084        {
    085            ItemStack itemstack2 = new ItemStack(Item.map, i + 1, itemstack.getItemDamage());
    086
    087            if (itemstack.hasDisplayName())
    088            {
    089                itemstack2.setItemName(itemstack.getDisplayName());
    090            }
    091
    092            return itemstack2;
    093        }
    094        else
    095        {
    096            return null;
    097        }
    098    }
    099
    100    /**
    101     * Returns the size of the recipe area
    102     */
    103    public int getRecipeSize()
    104    {
    105        return 9;
    106    }
    107
    108    public ItemStack getRecipeOutput()
    109    {
    110        return null;
    111    }
    112}