RecipesMapCloning .java

net.minecraft.item.crafting.RecipesMapCloning (class, 130 lines): members: getRemainingItems, getRecipeOutput, getRecipeSize, getCraftingResult, matches.

net.minecraft.item.craftingclass130 linescommon3.1 KB

Implements

API Surface (5)

boolean matches(InventoryCrafting inv, World worldIn)
ItemStack getCraftingResult(InventoryCrafting inv)
int getRecipeSize()
ItemStack getRecipeOutput()
ItemStack[] getRemainingItems(InventoryCrafting inv)

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

RecipesMapCloning.java130 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.item.crafting;
2
3
import net.minecraft.init.Items;
4
import net.minecraft.inventory.InventoryCrafting;
5
import net.minecraft.item.ItemStack;
6
import net.minecraft.world.World;
7
8
public class RecipesMapCloning implements IRecipe
9
{
10
    /**
11
     * Used to check if a recipe matches current crafting inventory
12
     */
13
    public boolean matches(InventoryCrafting inv, World worldIn)
14
    {
15
        int i = 0;
16
        ItemStack itemstack = null;
17
18
        for (int j = 0; j < inv.getSizeInventory(); ++j)
19
        {
20
            ItemStack itemstack1 = inv.getStackInSlot(j);
21
22
            if (itemstack1 != null)
23
            {
24
                if (itemstack1.getItem() == Items.filled_map)
25
                {
26
                    if (itemstack != null)
27
                    {
28
                        return false;
29
                    }
30
31
                    itemstack = itemstack1;
32
                }
33
                else
34
                {
35
                    if (itemstack1.getItem() != Items.map)
36
                    {
37
                        return false;
38
                    }
39
40
                    ++i;
41
                }
42
            }
43
        }
44
45
        return itemstack != null && i > 0;
46
    }
47
48
    /**
49
     * Returns an Item that is the result of this recipe
50
     */
51
    public ItemStack getCraftingResult(InventoryCrafting inv)
52
    {
53
        int i = 0;
54
        ItemStack itemstack = null;
55
56
        for (int j = 0; j < inv.getSizeInventory(); ++j)
57
        {
58
            ItemStack itemstack1 = inv.getStackInSlot(j);
59
60
            if (itemstack1 != null)
61
            {
62
                if (itemstack1.getItem() == Items.filled_map)
63
                {
64
                    if (itemstack != null)
65
                    {
66
                        return null;
67
                    }
68
69
                    itemstack = itemstack1;
70
                }
71
                else
72
                {
73
                    if (itemstack1.getItem() != Items.map)
74
                    {
75
                        return null;
76
                    }
77
78
                    ++i;
79
                }
80
            }
81
        }
82
83
        if (itemstack != null && i >= 1)
84
        {
85
            ItemStack itemstack2 = new ItemStack(Items.filled_map, i + 1, itemstack.getMetadata());
86
87
            if (itemstack.hasDisplayName())
88
            {
89
                itemstack2.setStackDisplayName(itemstack.getDisplayName());
90
            }
91
92
            return itemstack2;
93
        }
94
        else
95
        {
96
            return null;
97
        }
98
    }
99
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
113
    public ItemStack[] getRemainingItems(InventoryCrafting inv)
114
    {
115
        ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
116
117
        for (int i = 0; i < aitemstack.length; ++i)
118
        {
119
            ItemStack itemstack = inv.getStackInSlot(i);
120
121
            if (itemstack != null && itemstack.getItem().hasContainerItem())
122
            {
123
                aitemstack[i] = new ItemStack(itemstack.getItem().getContainerItem());
124
            }
125
        }
126
127
        return aitemstack;
128
    }
129
}
130

Deobfuscated MCP 1.8.9 source of RecipesMapCloning from Marcelektro/MavenMCP-1.8.9 (net/minecraft/item/crafting/RecipesMapCloning.java), stored verbatim.