    001package net.minecraft.item.crafting;
    002
    003import net.minecraft.inventory.InventoryCrafting;
    004import net.minecraft.item.Item;
    005import net.minecraft.item.ItemStack;
    006import net.minecraft.nbt.NBTTagCompound;
    007import net.minecraft.world.World;
    008import net.minecraft.world.storage.MapData;
    009
    010public class RecipesMapExtending extends ShapedRecipes
    011{
    012    public RecipesMapExtending()
    013    {
    014        super(3, 3, new ItemStack[] {new ItemStack(Item.paper), new ItemStack(Item.paper), new ItemStack(Item.paper), new ItemStack(Item.paper), new ItemStack(Item.map, 0, -1), new ItemStack(Item.paper), new ItemStack(Item.paper), new ItemStack(Item.paper), new ItemStack(Item.paper)}, new ItemStack(Item.emptyMap, 0, 0));
    015    }
    016
    017    /**
    018     * Used to check if a recipe matches current crafting inventory
    019     */
    020    public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World)
    021    {
    022        if (!super.matches(par1InventoryCrafting, par2World))
    023        {
    024            return false;
    025        }
    026        else
    027        {
    028            ItemStack var3 = null;
    029
    030            for (int var4 = 0; var4 < par1InventoryCrafting.getSizeInventory() && var3 == null; ++var4)
    031            {
    032                ItemStack var5 = par1InventoryCrafting.getStackInSlot(var4);
    033
    034                if (var5 != null && var5.itemID == Item.map.itemID)
    035                {
    036                    var3 = var5;
    037                }
    038            }
    039
    040            if (var3 == null)
    041            {
    042                return false;
    043            }
    044            else
    045            {
    046                MapData var6 = Item.map.getMapData(var3, par2World);
    047                return var6 == null ? false : var6.scale < 4;
    048            }
    049        }
    050    }
    051
    052    /**
    053     * Returns an Item that is the result of this recipe
    054     */
    055    public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting)
    056    {
    057        ItemStack var2 = null;
    058
    059        for (int var3 = 0; var3 < par1InventoryCrafting.getSizeInventory() && var2 == null; ++var3)
    060        {
    061            ItemStack var4 = par1InventoryCrafting.getStackInSlot(var3);
    062
    063            if (var4 != null && var4.itemID == Item.map.itemID)
    064            {
    065                var2 = var4;
    066            }
    067        }
    068
    069        var2 = var2.copy();
    070        var2.stackSize = 1;
    071
    072        if (var2.getTagCompound() == null)
    073        {
    074            var2.setTagCompound(new NBTTagCompound());
    075        }
    076
    077        var2.getTagCompound().setBoolean("map_is_scaling", true);
    078        return var2;
    079    }
    080}