    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, 32767), 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 itemstack = null;
    029
    030            for (int i = 0; i < par1InventoryCrafting.getSizeInventory() && itemstack == null; ++i)
    031            {
    032                ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(i);
    033
    034                if (itemstack1 != null && itemstack1.itemID == Item.map.itemID)
    035                {
    036                    itemstack = itemstack1;
    037                }
    038            }
    039
    040            if (itemstack == null)
    041            {
    042                return false;
    043            }
    044            else
    045            {
    046                MapData mapdata = Item.map.getMapData(itemstack, par2World);
    047                return mapdata == null ? false : mapdata.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 itemstack = null;
    058
    059        for (int i = 0; i < par1InventoryCrafting.getSizeInventory() && itemstack == null; ++i)
    060        {
    061            ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(i);
    062
    063            if (itemstack1 != null && itemstack1.itemID == Item.map.itemID)
    064            {
    065                itemstack = itemstack1;
    066            }
    067        }
    068
    069        itemstack = itemstack.copy();
    070        itemstack.stackSize = 1;
    071
    072        if (itemstack.getTagCompound() == null)
    073        {
    074            itemstack.setTagCompound(new NBTTagCompound());
    075        }
    076
    077        itemstack.getTagCompound().setBoolean("map_is_scaling", true);
    078        return itemstack;
    079    }
    080}