| 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.nbt.NBTTagCompound;
|
| 7 | import net.minecraft.world.World;
|
| 8 | import net.minecraft.world.storage.MapData;
|
| 9 |
|
| 10 | public class RecipesMapExtending extends ShapedRecipes
|
| 11 | {
|
| 12 | public RecipesMapExtending()
|
| 13 | {
|
| 14 | super(3, 3, new ItemStack[] {new ItemStack(Items.paper), new ItemStack(Items.paper), new ItemStack(Items.paper), new ItemStack(Items.paper), new ItemStack(Items.filled_map, 0, 32767), new ItemStack(Items.paper), new ItemStack(Items.paper), new ItemStack(Items.paper), new ItemStack(Items.paper)}, new ItemStack(Items.map, 0, 0));
|
| 15 | }
|
| 16 |
|
| 17 | /**
|
| 18 | * Used to check if a recipe matches current crafting inventory
|
| 19 | */
|
| 20 | public boolean matches(InventoryCrafting inv, World worldIn)
|
| 21 | {
|
| 22 | if (!super.matches(inv, worldIn))
|
| 23 | {
|
| 24 | return false;
|
| 25 | }
|
| 26 | else
|
| 27 | {
|
| 28 | ItemStack itemstack = null;
|
| 29 |
|
| 30 | for (int i = 0; i < inv.getSizeInventory() && itemstack == null; ++i)
|
| 31 | {
|
| 32 | ItemStack itemstack1 = inv.getStackInSlot(i);
|
| 33 |
|
| 34 | if (itemstack1 != null && itemstack1.getItem() == Items.filled_map)
|
| 35 | {
|
| 36 | itemstack = itemstack1;
|
| 37 | }
|
| 38 | }
|
| 39 |
|
| 40 | if (itemstack == null)
|
| 41 | {
|
| 42 | return false;
|
| 43 | }
|
| 44 | else
|
| 45 | {
|
| 46 | MapData mapdata = Items.filled_map.getMapData(itemstack, worldIn);
|
| 47 | return mapdata == null ? false : mapdata.scale < 4;
|
| 48 | }
|
| 49 | }
|
| 50 | }
|
| 51 |
|
| 52 | /**
|
| 53 | * Returns an Item that is the result of this recipe
|
| 54 | */
|
| 55 | public ItemStack getCraftingResult(InventoryCrafting inv)
|
| 56 | {
|
| 57 | ItemStack itemstack = null;
|
| 58 |
|
| 59 | for (int i = 0; i < inv.getSizeInventory() && itemstack == null; ++i)
|
| 60 | {
|
| 61 | ItemStack itemstack1 = inv.getStackInSlot(i);
|
| 62 |
|
| 63 | if (itemstack1 != null && itemstack1.getItem() == Items.filled_map)
|
| 64 | {
|
| 65 | itemstack = itemstack1;
|
| 66 | }
|
| 67 | }
|
| 68 |
|
| 69 | itemstack = itemstack.copy();
|
| 70 | itemstack.stackSize = 1;
|
| 71 |
|
| 72 | if (itemstack.getTagCompound() == null)
|
| 73 | {
|
| 74 | itemstack.setTagCompound(new NBTTagCompound());
|
| 75 | }
|
| 76 |
|
| 77 | itemstack.getTagCompound().setBoolean("map_is_scaling", true);
|
| 78 | return itemstack;
|
| 79 | }
|
| 80 | }
|
| 81 |
|