All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.RecipeMapClone Maven / Gradle / Ivy

package net.minecraft.server;

public class RecipeMapClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends

  // CraftBukkit start - Delegate to new parent class
  public RecipeMapClone() {
    super(new ItemStack(Items.MAP, 0, -1), java.util.Arrays.asList(new ItemStack(Items.MAP, 0, 0)));
  }
  // CraftBukkit end

  public boolean a(InventoryCrafting inventorycrafting, World world) {
    int i = 0;
    ItemStack itemstack = null;

    for (int j = 0; j < inventorycrafting.getSize(); ++j) {
      ItemStack itemstack1 = inventorycrafting.getItem(j);

      if (itemstack1 != null) {
        if (itemstack1.getItem() == Items.FILLED_MAP) {
          if (itemstack != null) {
            return false;
          }

          itemstack = itemstack1;
        } else {
          if (itemstack1.getItem() != Items.MAP) {
            return false;
          }

          ++i;
        }
      }
    }

    return itemstack != null && i > 0;
  }

  public ItemStack craftItem(InventoryCrafting inventorycrafting) {
    int i = 0;
    ItemStack itemstack = null;

    for (int j = 0; j < inventorycrafting.getSize(); ++j) {
      ItemStack itemstack1 = inventorycrafting.getItem(j);

      if (itemstack1 != null) {
        if (itemstack1.getItem() == Items.FILLED_MAP) {
          if (itemstack != null) {
            return null;
          }

          itemstack = itemstack1;
        } else {
          if (itemstack1.getItem() != Items.MAP) {
            return null;
          }

          ++i;
        }
      }
    }

    if (itemstack != null && i >= 1) {
      ItemStack itemstack2 = new ItemStack(Items.FILLED_MAP, i + 1, itemstack.getData());

      if (itemstack.hasName()) {
        itemstack2.c(itemstack.getName());
      }

      return itemstack2;
    } else {
      return null;
    }
  }

  public int a() {
    return 9;
  }

  public ItemStack b() {
    return null;
  }

  public ItemStack[] b(InventoryCrafting inventorycrafting) {
    ItemStack[] aitemstack = new ItemStack[inventorycrafting.getSize()];

    for (int i = 0; i < aitemstack.length; ++i) {
      ItemStack itemstack = inventorycrafting.getItem(i);

      if (itemstack != null && itemstack.getItem().r()) {
        aitemstack[i] = new ItemStack(itemstack.getItem().q());
      }
    }

    return aitemstack;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy