Пример #1
0
 public static void setCraftingRecipeList(List<IRecipe> craftingRecipeList) {
   if (!setPrivateObject(
       CraftingManager.getInstance(),
       craftingRecipeList,
       ObfuscationConstants.CRAFTINGMANAGER_RECIPES))
     logError("could not set crafting recipe list");
 }
Пример #2
0
  /** Gets the last x recipes added to the recipe list. */
  public static List<IRecipe> getLatestAddedRecipes(int x) {
    List<IRecipe> list = CraftingManager.getInstance().getRecipeList();
    List<IRecipe> newList = new ArrayList();
    for (int i = x - 1; i >= 0; i--) newList.add(list.get(list.size() - 1 - i));

    return newList;
  }
Пример #3
0
  public static void purgeRecipes() {

    List<ItemStack> toPurge = new ArrayList<ItemStack>();

    for (String entry : SI.CONFIG.purgerecipes) {
      Object is = SI.REGISTRY.stringToItemStack(entry);
      if (is instanceof ItemStack) {
        toPurge.add((ItemStack) is);
      }
    }

    List recipes = CraftingManager.getInstance().getRecipeList();
    List removallist = new ArrayList();

    for (ItemStack purgeEntry : toPurge) {
      for (Object entry : recipes) {
        if (entry instanceof IRecipe) {
          ItemStack output = ((IRecipe) entry).getRecipeOutput();
          if (output != null) {

            if ((output.getItem() == purgeEntry.getItem())
                && (output.getItemDamage() == 32767
                    || output.getItemDamage() == purgeEntry.getItemDamage())) {
              removallist.add(entry);
            }
          }
        }
      }
    }

    for (Object toRemove : removallist) {
      recipes.remove(toRemove);
    }
  }
  /** Find recipes excluding one or more recipe types */
  public static ItemStack findMatchingRecipeExcluding(
      InventoryCrafting inv, World world, Class... excluding) {
    int i = 0;
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;
    int j;
    List recipes = CraftingManager.getInstance().getRecipeList();

    for (j = 0; j < inv.getSizeInventory(); ++j) {
      ItemStack itemstack2 = inv.getStackInSlot(j);

      if (itemstack2 != null) {
        if (i == 0) {
          itemstack = itemstack2;
        }

        if (i == 1) {
          itemstack1 = itemstack2;
        }

        ++i;
      }
    }

    if (i == 2
        && itemstack.getItem() == itemstack1.getItem()
        && itemstack.stackSize == 1
        && itemstack1.stackSize == 1
        && itemstack.getItem().isRepairable()) {
      Item item = itemstack.getItem();
      int j1 = item.getMaxDamage() - itemstack.getItemDamage(); // getItemDamageForDisplay
      int k = item.getMaxDamage() - itemstack1.getItemDamage();
      int l = j1 + k + item.getMaxDamage() * 5 / 100;
      int i1 = item.getMaxDamage() - l;

      if (i1 < 0) {
        i1 = 0;
      }

      return new ItemStack(itemstack.getItem(), 1, i1);
    } else {
      for (j = 0; j < recipes.size(); ++j) {
        IRecipe irecipe = (IRecipe) recipes.get(j);

        // 1.1.1 Botania fix (try catch)
        try {
          if ((!Arrays.asList(excluding).contains(irecipe.getClass()))
              && irecipe.matches(inv, world)) {
            return irecipe.getCraftingResult(inv);
          }
        } catch (Exception e) {
        }
      }

      return null;
    }
  }
Пример #5
0
  public void addShapelessRecipe(ItemStack result, Object... recipe) {
    String name = Item.itemRegistry.getNameForObject(result.getItem());

    if (BuildCraftCore.recipesBlacklist.contains(name)) {
      return;
    }

    CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(result, recipe));
  }
Пример #6
0
 public static void removeAnyRecipe(ItemStack resultItem) {
   List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
   for (int i = 0; i < recipes.size(); i++) {
     IRecipe tmpRecipe = recipes.get(i);
     ItemStack recipeResult = tmpRecipe.getRecipeOutput();
     if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) {
       recipes.remove(i--);
     }
   }
 }
  @Override
  public void update() {
    // Always update listeners even if not making stuff
    if (!worldObj.isRemote && _workbench != null) _workbench.update();

    // If we are disabled, we don't do anything
    if (!_enabled) return;

    boolean wasCraftingFlag = isCrafting();
    boolean dirtyFlag = false;
    if (isCrafting()) {
      ++_ticksCrafted;
      dirtyFlag = true;
    }

    if (!worldObj.isRemote) {

      if (_workbench != null) _workbench.update();

      // Make sure we are still in a valid crafting configuration
      if (!canCraft()) {
        _ticksCrafted = 0;
        _ticksToCraft = 0;
        dirtyFlag = wasCraftingFlag;
      } else {
        if (isCrafting()) {
          if (_ticksCrafted <= _ticksToCraft) return;

          // Craft it.
          // LOGGER.debug("Crafting final item");
          craftItem();
          dirtyFlag = true;
        }

        // Now, let's see if we can craft again
        if (canCraft()) {
          // Start up the crafting
          ItemStack newStack =
              CraftingManager.getInstance()
                  .findMatchingRecipe(_craftingCore.getCraftingMatrix(), getWorld());
          // LOGGER.debug("Started crafting: " + newStack );
          _ticksToCraft = ticksToCraftOneItem(newStack);
          _ticksCrafted = 0;

          // We are always dirty because we have to update progress
          dirtyFlag = true;
        }
      }
    }

    if (dirtyFlag) {
      markDirty();
    }
  }
  private ItemStack getAndUpdateOutput() {
    final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);

    for (int x = 0; x < ic.getSizeInventory(); x++) {
      ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
    }

    final ItemStack is =
        CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj);
    this.cOut.setInventorySlotContents(0, is);
    return is;
  }
Пример #9
0
 public ArrayList<IRecipe> getVanillaRecipes() {
   if (!this.isCrafting()) return new ArrayList();
   ArrayList<ItemStack> li = this.getItemStacks();
   if (li == null || li.isEmpty()) return new ArrayList();
   ArrayList<IRecipe> rec = new ArrayList();
   for (ItemStack is : li) {
     rec.addAll(
         ReikaRecipeHelper.getAllRecipesByOutput(
             CraftingManager.getInstance().getRecipeList(), is));
   }
   return rec;
 }
Пример #10
0
	@Override
	public List<Recipe> getRecipesFor(ItemStack result) {
		//net.minecraft.src.ItemStack realStack = (net.minecraft.src.ItemStack) result;
		List<Recipe> res = new ArrayList<Recipe> ();
		net.minecraft.item.ItemStack stack = new net.minecraft.item.ItemStack(result.getTypeId(), result.getAmount(), result.getDurability());
		ShapedRecipes[] recipes = (ShapedRecipes[]) CraftingManager.getInstance().getRecipeList().toArray();
		for (ShapedRecipes i : recipes) {
			if (i.getRecipeOutput() == stack) {
				res.add((Recipe) i);
			}
		}
		return res;
	}
Пример #11
0
  private static void addOreDictRecipe(ItemStack output, Object... r) {

    CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, r));

    List<ItemStack[]> l = new ArrayList<ItemStack[]>();

    int sCount = 0;
    for (int i = 0; i < r.length; i++) {

      if (sCount == 3) break;

      if (r[i] instanceof String) {
        sCount++;
        for (char c : ((String) r[i]).toCharArray()) {

          if (c == ' ') {
            l.add(null);
            continue;
          }
          for (int i2 = 0; i2 < r.length; i2++) {

            if (!(r[i2] instanceof Character)) continue;

            if (((Character) r[i2]) == c) {

              if (r[i2 + 1] instanceof ItemStack) {
                l.add(new ItemStack[] {(ItemStack) r[i2 + 1]});
              } else {
                l.add(
                    OreDictionary.getOres((String) r[i2 + 1])
                        .toArray(new ItemStack[OreDictionary.getOres((String) r[i2 + 1]).size()]));
              }

              continue;

            } else if (i2 != r.length - 1) continue;
            else {

              System.err.println("RIP RUN");

              return;
            }
          }
        }
      }
    }

    ItemStack is2 = new ItemStack(output.getItem(), 1, output.getItemDamage());

    shaped.put(is2.getUnlocalizedName(), l.toArray(new ItemStack[l.size()][9]));
  }
Пример #12
0
 @SuppressWarnings("unchecked")
 @EventHandler
 public void load(FMLInitializationEvent event) {
   initBaseItems();
   initAlloys();
   initIndigo();
   initMicroblocks();
   initCoverMaterials();
   initBlocks();
   initAchievements();
   CraftingManager.getInstance().getRecipeList().add(new RecipeBag());
   proxy.registerRenderers();
   NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
 }
  @SuppressWarnings("unchecked")
  @Init
  public void load(FMLInitializationEvent event) {

    // Register the GUI Handler
    NetworkRegistry.instance().registerGuiHandler(instance, proxy);

    // Register the PlayerDestroyItem Handler
    MinecraftForge.EVENT_BUS.register(new PlayerDestroyItemHandler());

    // Register the Item Pickup Handler
    MinecraftForge.EVENT_BUS.register(new ItemEventHandler());

    // Register the EntityLiving Handler
    MinecraftForge.EVENT_BUS.register(new EntityLivingHandler());

    MinecraftForge.EVENT_BUS.register(new ActionRequestHandler());

    MinecraftForge.EVENT_BUS.register(new WorldTransmutationHandler());

    GameRegistry.registerCraftingHandler(new CraftingHandler());

    // Register the DrawBlockHighlight Handler
    proxy.registerDrawBlockHighlightHandler();

    // Initialize mod tile entities
    proxy.registerTileEntities();

    // Initialize custom rendering and pre-load textures (Client only)
    proxy.initRenderingAndTextures();

    // Add in the ability to dye Alchemical Bags
    CraftingManager.getInstance().getRecipeList().add(new RecipesAlchemicalBagDyes());

    // Register the Fuel Handler
    GameRegistry.registerFuelHandler(new FuelHandler());

    // Quick test to see that sending an encoded recipe to be added to the recipe registry works
    FMLInterModComms.sendMessage(
        Reference.MOD_ID,
        InterModComms.ADD_RECIPE,
        NBTHelper.encodeRecipeAsNBT(
            Item.bucketWater, Arrays.asList(Item.bucketEmpty, Block.waterStill)));
    FMLInterModComms.sendMessage(
        Reference.MOD_ID,
        InterModComms.ADD_RECIPE,
        NBTHelper.encodeRecipeAsNBT(
            Item.bucketLava, Arrays.asList(Item.bucketEmpty, Block.lavaStill)));
  }
Пример #14
0
  @SuppressWarnings("unchecked")
  private void removeRecipes(String toDelete) {
    ItemStack resultItem = new ItemStack((Item) Item.itemRegistry.getObject(toDelete));

    List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();

    for (int i = 0; i < recipes.size(); i++) {
      IRecipe tmpRecipe = recipes.get(i);
      ItemStack recipeResult = tmpRecipe.getRecipeOutput();
      if (resultItem != null && recipeResult != null) resultItem.stackSize = recipeResult.stackSize;

      if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) {
        recipes.remove(i--);
      }
    }
  }
  public void craftItem() {
    // If we are here there is room and we have compatible stacks.  Update sizes
    ItemStack newStack =
        CraftingManager.getInstance().findMatchingRecipe(_craftingMatrix, getWorld());
    ItemStack outStack = _craftOutput.getStackInSlot(0);

    if (outStack != null) outStack.stackSize += newStack.stackSize;
    else _craftOutput.setInventorySlotContents(0, newStack.copy());

    for (int i = 0; i < 9; ++i) {
      ItemStack stack = _craftingMatrix.getStackInSlot(i);
      if (stack != null) --stack.stackSize;
    }

    _ticksToCraft = 0;
    _ticksCrafted = 0;
  }
Пример #16
0
  private int func_90014_a(EntityAnimal par1EntityAnimal, EntityAnimal par2EntityAnimal) {
    int i = this.func_90013_b(par1EntityAnimal);
    int j = this.func_90013_b(par2EntityAnimal);
    this.field_90016_e.getStackInSlot(0).setItemDamage(i);
    this.field_90016_e.getStackInSlot(1).setItemDamage(j);
    ItemStack itemstack =
        CraftingManager.getInstance()
            .findMatchingRecipe(this.field_90016_e, ((EntitySheep) par1EntityAnimal).worldObj);
    int k;

    if (itemstack != null && itemstack.getItem().itemID == Item.dyePowder.itemID) {
      k = itemstack.getItemDamage();
    } else {
      k = this.worldObj.rand.nextBoolean() ? i : j;
    }

    return k;
  }
Пример #17
0
  private DyeColor func_175511_a(EntityAnimal p_175511_1_, EntityAnimal p_175511_2_) {
    int var3 = ((EntitySheep) p_175511_1_).func_175509_cj().getDyeColorValue();
    int var4 = ((EntitySheep) p_175511_2_).func_175509_cj().getDyeColorValue();
    this.inventoryCrafting.get(0).setItemDamage(var3);
    this.inventoryCrafting.get(1).setItemDamage(var4);
    ItemStack var5 =
        CraftingManager.getInstance()
            .findMatchingRecipe(this.inventoryCrafting, ((EntitySheep) p_175511_1_).world);
    int var6;

    if (var5 != null && var5.getItem() == Items.dye) {
      var6 = var5.getMetadata();
    } else {
      var6 = this.world.rand.nextBoolean() ? var3 : var4;
    }

    return DyeColor.getDyeColorForValue(var6);
  }
Пример #18
0
  /**
   * Initializes statistics related to craftable items. Is only called after both block and item
   * stats have been initialized.
   */
  private static void initCraftableStats() {
    HashSet var0 = Sets.newHashSet();
    Iterator var1 = CraftingManager.getInstance().getRecipeList().iterator();

    while (var1.hasNext()) {
      IRecipe var2 = (IRecipe) var1.next();

      if (var2.getRecipeOutput() != null) {
        var0.add(var2.getRecipeOutput().getItem());
      }
    }

    var1 = FurnaceRecipes.instance().getSmeltingList().values().iterator();

    while (var1.hasNext()) {
      ItemStack var5 = (ItemStack) var1.next();
      var0.add(var5.getItem());
    }

    var1 = var0.iterator();

    while (var1.hasNext()) {
      Item var6 = (Item) var1.next();

      if (var6 != null) {
        int var3 = Item.getIdFromItem(var6);
        String var4 = func_180204_a(var6);

        if (var4 != null) {
          objectCraftStats[var3] =
              (new StatCrafting(
                      "stat.craftItem.",
                      var4,
                      new ChatComponentTranslation(
                          "stat.craftItem",
                          new Object[] {(new ItemStack(var6)).getChatComponent()}),
                      var6))
                  .registerStat();
        }
      }
    }

    replaceAllSimilarBlocks(objectCraftStats);
  }
  @Override
  public void loadCraftingRecipes(ItemStack result) {
    List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
    for (IRecipe irecipe : allrecipes) {
      if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
        CachedShapelessRecipe recipe = null;
        if (irecipe instanceof ShapelessRecipes) {
          recipe = shapelessRecipe((ShapelessRecipes) irecipe);
        } else if (irecipe instanceof ShapelessOreRecipe) {
          recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
        }

        if (recipe == null) {
          continue;
        }

        arecipes.add(recipe);
      }
    }
  }
 @SuppressWarnings("unchecked")
 public void registerRecipes() {
   IRecipe recipe =
       new ShapedOreRecipe(
           new ItemStack(farm),
           new Object[] {
             "SLS",
             "FHF",
             "SLS",
             'S',
             "cobblestone",
             'F',
             Blocks.fence,
             'L',
             "logWood",
             'H',
             Blocks.hopper
           });
   CraftingManager.getInstance().getRecipeList().add(recipe);
 }
  @Override
  public void loadUsageRecipes(ItemStack ingredient) {
    List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
    for (IRecipe irecipe : allrecipes) {
      CachedShapelessRecipe recipe = null;
      if (irecipe instanceof ShapelessRecipes) {
        recipe = shapelessRecipe((ShapelessRecipes) irecipe);
      } else if (irecipe instanceof ShapelessOreRecipe) {
        recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
      }

      if (recipe == null) {
        continue;
      }

      if (recipe.contains(recipe.ingredients, ingredient)) {
        recipe.setIngredientPermutation(recipe.ingredients, ingredient);
        arecipes.add(recipe);
      }
    }
  }
Пример #22
0
  private static void addShapelessOreDictRecipe(ItemStack output, Object... recipe) {

    ItemStack[][] ns = new ItemStack[recipe.length][1];

    int index = 0;

    List<String> ls = new ArrayList<String>();

    for (Object o : recipe) {

      if (o instanceof ItemStack) {

        ns[index][0] = (ItemStack) o;
        index++;
        continue;
      } else if (o instanceof String) {

        ls.add((String) o);
        continue;
      }
    }

    if (ls.isEmpty()) {

      System.err.println("USE NORMAL SHAPELESSRECIPE");
      return;
    } else {

      for (String s : ls) {

        ns[index] =
            OreDictionary.getOres(s).toArray(new ItemStack[OreDictionary.getOres(s).size()]);
        index++;
      }
    }
    ItemStack is2 = new ItemStack(output.getItem(), 1, output.getItemDamage());

    shapeless.put(is2.getUnlocalizedName(), ns);
    CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(output, recipe));
  }
Пример #23
0
 @Override
 public void UpdateInformation(ArrayList<PacketEntry> Packet) {
   addedRecipes.clear();
   String[] input = ArrayPacketEntry.getArray(Packet);
   for (int zahl = 0; zahl < input.length; zahl++) {
     Object[] objects = StringUtils.StringToObjects(input[zahl]);
     if (objects.length == 2 && objects[0] instanceof String && objects[1] instanceof String) {
       IRecipe recipe =
           WorkbenchHelper.StringToRecipe(objects[0].equals("shapedore"), (String) objects[1]);
       if (recipe != null && !addedRecipes.contains(recipe)) addedRecipes.add(recipe);
     }
   }
   List mcRecipes = CraftingManager.getInstance().getRecipeList();
   List newRecipes = new ArrayList();
   for (int i = 0; i < mcRecipes.size(); i++) {
     if (!(mcRecipes.get(i) instanceof BetterShapedRecipe)
         && !(mcRecipes.get(i) instanceof BetterShapelessRecipe)) newRecipes.add(mcRecipes.get(i));
   }
   newRecipes.addAll(addedRecipes);
   mcRecipes.clear();
   mcRecipes.addAll(newRecipes);
 }
  @Override
  public void loadCraftingRecipes(String outputId, Object... results) {
    if (outputId.equals("crafting") && getClass() == ShapelessRecipeHandler.class) {
      List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
      for (IRecipe irecipe : allrecipes) {
        CachedShapelessRecipe recipe = null;
        if (irecipe instanceof ShapelessRecipes) {
          recipe = shapelessRecipe((ShapelessRecipes) irecipe);
        } else if (irecipe instanceof ShapelessOreRecipe) {
          recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
        }

        if (recipe == null) {
          continue;
        }

        arecipes.add(recipe);
      }
    } else {
      super.loadCraftingRecipes(outputId, results);
    }
  }
Пример #25
0
  @Mod.EventHandler
  public static void Init(FMLInitializationEvent event) {
    ForgeChunkManager.setForcedChunkLoadingCallback(
        EstateAgent.instance, new ChunkLoadingCallback());

    CraftingManager.getInstance()
        .addRecipe(
            new ItemStack(ModItems.landbook),
            "aaa",
            "aba",
            "aaa",
            'a',
            new ItemStack(Blocks.dirt),
            'b',
            new ItemStack(Items.book));

    simpleChannel = NetworkRegistry.INSTANCE.newSimpleChannel(References.MODNAME);
    simpleChannel.registerMessage(
        HandlerGeneralServer.class, PacketGeneralServer.class, 1, Side.SERVER);
    simpleChannel.registerMessage(
        HandlerGeneralClient.class, PacketGeneralClient.class, 2, Side.CLIENT);
  }
Пример #26
0
  @Override
  public void loadConfig(Configuration config) {
    addedRecipes.clear();

    // items|result|x|y
    Map<String, Property> shaped = config.getCategory("addshapedore").getValues();
    for (int zahl = 0; zahl < shaped.size(); zahl++) {
      Property RecipeData = (Property) shaped.values().toArray()[zahl];
      String Data = RecipeData.getName();
      IRecipe recipe = WorkbenchHelper.StringToRecipe(true, Data);
      if (recipe != null) addedRecipes.add(recipe);
    }

    Map<String, Property> shapless = config.getCategory("addshapelessore").getValues();
    for (int zahl = 0; zahl < shapless.size(); zahl++) {
      Property RecipeData = (Property) shapless.values().toArray()[zahl];
      String Data = RecipeData.getName();
      IRecipe recipe = WorkbenchHelper.StringToRecipe(false, Data);
      if (recipe != null) addedRecipes.add(recipe);
    }
    CraftingManager.getInstance().getRecipeList().addAll(addedRecipes);
  }
Пример #27
0
  public static IRecipe getRecipeForItemStack(
      ItemStack reqStack) // Does not match NBT. Durrr! -smack-
      {
    if (reqStack == null) {
      return null; // Why are you even doing this to yourself!? You know this can't be healthy!
    }
    List craftingList = CraftingManager.getInstance().getRecipeList();
    for (Object posRecipe : craftingList) {
      if (posRecipe instanceof IRecipe) {
        ItemStack outputStack = ((IRecipe) posRecipe).getRecipeOutput();
        if (outputStack != null) {
          if (outputStack.getItem() == reqStack.getItem()
              && (outputStack.getItem().getHasSubtypes()
                  ? outputStack.getItemDamage() == reqStack.getItemDamage()
                  : true)) {
            return (IRecipe) posRecipe;
          }
        }
      }
    }

    return null;
  }
  private boolean canCraft(boolean requireMats) {
    ItemStack newStack =
        CraftingManager.getInstance()
            .findMatchingRecipe(_craftingCore.getCraftingMatrix(), getWorld());
    if (newStack == null) {
      // LOGGER.debug("Can't craft, no recipe.");
      return false;
    }

    // Check to make sure all things have more than one
    if (requireMats) {
      for (int i = 0; i < 9; ++i) {
        ItemStack stack = _craftingMatrix.getStackInSlot(i);
        if (stack != null && stack.stackSize < 2) {
          // LOGGER.debug("Can't craft, stack size < 2. slot=" + i + ", stack=" + stack);
          return false;
        }
      }
    }

    // Make sure the thing we can make can go into the output
    ItemStack outStack = _craftOutput.getStackInSlot(0);
    if (outStack != null && !outStack.isItemEqual(newStack)) {
      // LOGGER.debug("Can't craft, outStack not same thing. outstack=" + outStack);
      return false;
    }

    // See if we have room for more
    if (outStack != null
        && (outStack.stackSize + newStack.stackSize) >= outStack.getMaxStackSize()) {
      // LOGGER.debug("Can't craft, outStack full. outstack=" + outStack);
      return false;
    }

    // We are a go!
    return true;
  }
Пример #29
0
  public static void register() {
    @SuppressWarnings("unchecked")
    final List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList();

    // There is no fail checking here because if the Generic item fails,
    // then I doubt anyone wants this to be silent.
    // Too many items would suffer from this. - NC
    MetasGeneric.registerItems();
    OpenBlocks.Items.generic.initRecipes();

    MetasGenericUnstackable.registerItems();
    OpenBlocks.Items.genericUnstackable.initRecipes();

    if (OpenBlocks.Blocks.ladder != null) {
      recipeList.add(
          new ShapelessOreRecipe(OpenBlocks.Blocks.ladder, Blocks.ladder, Blocks.trapdoor));
    }

    if (OpenBlocks.Blocks.guide != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.guide, "ggg", "gtg", "ggg", 'g', Blocks.glass, 't', Blocks.torch));
    }

    if (OpenBlocks.Blocks.elevator != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.elevator,
              "www",
              "wew",
              "www",
              'w',
              Blocks.wool,
              'e',
              Items.ender_pearl));
    }

    if (OpenBlocks.Blocks.target != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.target, "www", "www", "s s", 'w', Blocks.wool, 's', "stickWood"));
    }

    if (OpenBlocks.Blocks.flag != null) {
      recipeList.add(
          new ShapedOreRecipe(
              new ItemStack(OpenBlocks.Blocks.flag, 3),
              "scc",
              "sc ",
              "s  ",
              'c',
              Blocks.carpet,
              's',
              "stickWood"));
    }
    if (OpenBlocks.Blocks.tank != null) {
      recipeList.add(
          new ShapedOreRecipe(
              new ItemStack(OpenBlocks.Blocks.tank, 2),
              "ogo",
              "ggg",
              "ogo",
              'g',
              Blocks.glass_pane,
              'o',
              Blocks.obsidian));
    }
    if (OpenBlocks.Blocks.trophy != null) {
      MinecraftForge.EVENT_BUS.register(new TrophyHandler());
    }
    if (OpenBlocks.Blocks.bearTrap != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.bearTrap,
              "fif",
              "fif",
              "fif",
              'f',
              Blocks.iron_bars,
              'i',
              Items.iron_ingot));
    }

    if (OpenBlocks.Blocks.sprinkler != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.sprinkler,
              "ifi",
              "iri",
              "ifi",
              'i',
              Items.iron_ingot,
              'r',
              Blocks.redstone_torch,
              'f',
              Blocks.iron_bars));
    }

    if (OpenBlocks.Blocks.cannon != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.cannon,
              " d ",
              " f ",
              "iri",
              'd',
              Blocks.dispenser,
              'f',
              Blocks.iron_bars,
              'i',
              Items.iron_ingot,
              'r',
              Blocks.redstone_block));
    }

    if (OpenBlocks.Blocks.vacuumHopper != null) {
      recipeList.add(
          new ShapelessOreRecipe(
              OpenBlocks.Blocks.vacuumHopper, Blocks.hopper, Blocks.obsidian, Items.ender_eye));
    }

    if (OpenBlocks.Blocks.sponge != null) {
      recipeList.add(
          new ShapelessOreRecipe(OpenBlocks.Blocks.sponge, Blocks.wool, Items.slime_ball));
    }

    if (OpenBlocks.Blocks.bigButton != null) {
      recipeList.add(
          new ShapedOreRecipe(OpenBlocks.Blocks.bigButton, "bb", "bb", 'b', Blocks.stone_button));
    }

    if (OpenBlocks.Blocks.imaginary != null) {
      {
        ItemStack pencil =
            ItemImaginary.setupValues(
                null, new ItemStack(OpenBlocks.Blocks.imaginary, 1, ItemImaginary.DAMAGE_PENCIL));
        recipeList.add(
            new ShapelessOreRecipe(
                pencil, Items.coal, "stickWood", Items.ender_eye, Items.slime_ball));
      }

      for (ColorMeta color : ColorUtils.getAllColors()) {
        ItemStack crayon =
            ItemImaginary.setupValues(
                color.rgb,
                new ItemStack(OpenBlocks.Blocks.imaginary, 1, ItemImaginary.DAMAGE_CRAYON));
        recipeList.add(
            new ShapelessOreRecipe(
                crayon, color.oreName, Items.paper, Items.ender_eye, Items.slime_ball));
      }

      recipeList.add(new CrayonMixingRecipe());
    }

    if (OpenBlocks.Blocks.fan != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.fan,
              "f",
              "i",
              "s",
              'f',
              Blocks.iron_bars,
              'i',
              Items.iron_ingot,
              's',
              Blocks.stone_slab));
    }

    if (OpenBlocks.Blocks.xpBottler != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.xpBottler,
              "iii",
              "ibi",
              "iii",
              'i',
              Items.iron_ingot,
              'b',
              Items.glass_bottle));
    }

    if (OpenBlocks.Blocks.villageHighlighter != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.villageHighlighter,
              "www",
              "wew",
              "ccc",
              'w',
              "plankWood",
              'e',
              Items.emerald,
              'c',
              Blocks.cobblestone));
    }

    if (OpenBlocks.Blocks.path != null) {
      recipeList.add(
          new ShapelessOreRecipe(new ItemStack(OpenBlocks.Blocks.path, 2), "stone", "cobblestone"));
    }

    if (OpenBlocks.Blocks.autoAnvil != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.autoAnvil,
              "iii",
              "iai",
              "rrr",
              'i',
              Items.iron_ingot,
              'a',
              Blocks.anvil,
              'r',
              Items.redstone));
    }

    if (OpenBlocks.Blocks.autoEnchantmentTable != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.autoEnchantmentTable,
              "iii",
              "iei",
              "rrr",
              'i',
              Items.iron_ingot,
              'e',
              Blocks.enchanting_table,
              'r',
              Items.redstone));
    }

    if (OpenBlocks.Blocks.xpDrain != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.xpDrain, "iii", "iii", "iii", 'i', Blocks.iron_bars));
    }
    if (OpenBlocks.Blocks.blockBreaker != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.blockBreaker,
              "icc",
              "src",
              "icc",
              'i',
              Items.iron_ingot,
              'c',
              Blocks.cobblestone,
              'r',
              Items.redstone,
              's',
              Items.diamond_pickaxe));
    }

    if (OpenBlocks.Blocks.blockPlacer != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.blockPlacer,
              "icc",
              "src",
              "icc",
              'i',
              Items.iron_ingot,
              'c',
              Blocks.cobblestone,
              'r',
              Items.redstone,
              's',
              Blocks.piston));
    }

    if (OpenBlocks.Blocks.itemDropper != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.itemDropper,
              "icc",
              "src",
              "icc",
              'i',
              Items.iron_ingot,
              'c',
              Blocks.cobblestone,
              'r',
              Items.redstone,
              's',
              Blocks.hopper));
    }

    if (OpenBlocks.Blocks.ropeLadder != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.ropeLadder,
              "sts",
              "sts",
              "sts",
              't',
              "stickWood",
              's',
              Items.string));
    }

    if (OpenBlocks.Blocks.donationStation != null) {
      WeightedRandomChestContent drop =
          new WeightedRandomChestContent(new ItemStack(OpenBlocks.Blocks.donationStation), 1, 1, 2);
      ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(drop);
      ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR).addItem(drop);
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.donationStation,
              "ppp",
              "pcp",
              "ppp",
              'p',
              Items.porkchop,
              'c',
              Blocks.chest));
    }

    if (OpenBlocks.Blocks.paintMixer != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.paintMixer,
              "ooo",
              "i i",
              "iii",
              'o',
              Blocks.obsidian,
              'i',
              Items.iron_ingot));
    }

    if (OpenBlocks.Blocks.canvas != null) {
      recipeList.add(
          new ShapedOreRecipe(
              new ItemStack(OpenBlocks.Blocks.canvas, 9),
              "ppp",
              "pfp",
              "ppp",
              'p',
              Items.paper,
              'f',
              Blocks.fence));
    }

    if (OpenBlocks.Blocks.projector != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.projector,
              "grl",
              "iri",
              "srs",
              's',
              Blocks.stone_slab,
              'r',
              Items.redstone,
              'g',
              Items.glowstone_dust,
              'i',
              Items.iron_ingot,
              'l',
              "gemLapis"));
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.projector,
              "lrg",
              "iri",
              "srs",
              's',
              Blocks.stone_slab,
              'r',
              Items.redstone,
              'g',
              Items.glowstone_dust,
              'i',
              Items.iron_ingot,
              'l',
              "gemLapis"));
    }

    if (OpenBlocks.Blocks.goldenEgg != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.goldenEgg,
              "ggg",
              "geg",
              "ggg",
              'g',
              Items.gold_ingot,
              'e',
              Items.egg));
    }

    if (OpenBlocks.Blocks.sky != null) {
      final ItemStack normal6 = new ItemStack(OpenBlocks.Blocks.sky, 6, 0);
      final ItemStack normal = new ItemStack(OpenBlocks.Blocks.sky, 1, 1);
      final ItemStack inverted = new ItemStack(OpenBlocks.Blocks.sky, 1, 0);
      recipeList.add(
          new ShapedOreRecipe(
              normal6,
              "geg",
              "gsg",
              "geg",
              'g',
              Blocks.glass,
              'e',
              Items.ender_eye,
              's',
              Blocks.end_stone));
      recipeList.add(new ShapelessOreRecipe(inverted, normal, Blocks.redstone_torch));
      recipeList.add(new ShapelessOreRecipe(normal, inverted, Blocks.redstone_torch));
    }

    if (OpenBlocks.Blocks.drawingTable != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.drawingTable,
              "sks",
              "pcp",
              "ppp",
              'p',
              "plankWood",
              'c',
              Blocks.crafting_table,
              's',
              MetasGeneric.unpreparedStencil.newItemStack(),
              'k',
              MetasGeneric.sketchingPencil.newItemStack()));
    }

    if (OpenBlocks.Blocks.radio != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.radio,
              "pbp",
              "prp",
              "pgp",
              'p',
              "plankWood",
              'b',
              Blocks.iron_bars,
              'r',
              Items.redstone,
              'g',
              Items.gold_ingot));
    }

    if (OpenBlocks.Blocks.xpShower != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Blocks.xpShower,
              "iii",
              "  o",
              'i',
              Items.iron_ingot,
              'o',
              Blocks.obsidian));
    }

    if (OpenBlocks.Items.hangGlider != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Items.hangGlider,
              "wsw",
              'w',
              MetasGeneric.gliderWing.newItemStack(),
              's',
              "stickWood"));
    }

    if (OpenBlocks.Items.luggage != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Items.luggage,
              "sds",
              "scs",
              "sss",
              's',
              "stickWood",
              'd',
              Items.diamond,
              'c',
              Blocks.chest));
    }

    if (OpenBlocks.Items.sonicGlasses != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Items.sonicGlasses,
              "ihi",
              "oso",
              "   ",
              's',
              "stickWood",
              'h',
              Items.iron_helmet,
              'o',
              Blocks.obsidian,
              'i',
              Items.iron_ingot));
      ItemStack stack = new ItemStack(OpenBlocks.Items.sonicGlasses);
      WeightedRandomChestContent drop = new WeightedRandomChestContent(stack, 1, 1, 2);
      ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(drop);
    }

    if (OpenBlocks.Blocks.imaginary != null) {
      if (OpenBlocks.Items.pencilGlasses != null) {
        ItemStack block =
            new ItemStack(OpenBlocks.Blocks.imaginary, 1, ItemImaginary.DAMAGE_PENCIL);
        ItemImaginary.setupValues(null, block);
        recipeList.add(new ShapelessOreRecipe(OpenBlocks.Items.pencilGlasses, block, Items.paper));
      }

      if (OpenBlocks.Items.crayonGlasses != null) {
        recipeList.add(new CrayonGlassesRecipe());
      }

      if (OpenBlocks.Items.technicolorGlasses != null) {
        WeightedRandomChestContent drop =
            new WeightedRandomChestContent(
                new ItemStack(OpenBlocks.Items.technicolorGlasses), 1, 1, 2);
        ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(drop);
        ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR).addItem(drop);
      }
    }

    if (OpenBlocks.Items.craneControl != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Items.craneControl,
              "ili",
              "grg",
              "iri",
              'i',
              Items.iron_ingot,
              'g',
              Items.gold_nugget,
              'l',
              Items.glowstone_dust,
              'r',
              Items.redstone));
    }

    if (OpenBlocks.Items.craneBackpack != null) {
      ItemStack line = MetasGeneric.line.newItemStack();
      ItemStack beam = MetasGeneric.beam.newItemStack();
      recipeList.add(
          new ShapelessOreRecipe(
              OpenBlocks.Items.craneBackpack,
              MetasGeneric.craneEngine.newItemStack(),
              MetasGeneric.craneMagnet.newItemStack(),
              beam,
              beam,
              line,
              line,
              line,
              Items.leather));
    }

    if (OpenBlocks.Items.slimalyzer != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Items.slimalyzer,
              "igi",
              "isi",
              "iri",
              'i',
              Items.iron_ingot,
              'g',
              Blocks.glass_pane,
              's',
              Items.slime_ball,
              'r',
              Items.redstone));
    }

    if (OpenBlocks.Items.sleepingBag != null && EntityPlayerVisitor.IsInBedHookSuccess) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Items.sleepingBag,
              "cc ",
              "www",
              "ccw",
              'c',
              Blocks.carpet,
              'w',
              Blocks.wool));
    }

    if (OpenBlocks.Items.paintBrush != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Items.paintBrush,
              "w  ",
              " s ",
              "  s",
              'w',
              Blocks.wool,
              's',
              "stickWood"));
      int[] colors = new int[] {0xFF0000, 0x00FF00, 0x0000FF};
      for (int color : colors) {
        ItemStack stack = ItemPaintBrush.createStackWithColor(color);
        WeightedRandomChestContent drop = new WeightedRandomChestContent(stack, 1, 1, 2);
        ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(drop);
        ChestGenHooks.getInfo(ChestGenHooks.VILLAGE_BLACKSMITH).addItem(drop);
        ChestGenHooks.getInfo(ChestGenHooks.BONUS_CHEST).addItem(drop);
        ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR).addItem(drop);
      }
    }

    if (OpenBlocks.Items.stencil != null) {
      for (Stencil stencil : Stencil.values()) {
        WeightedRandomChestContent drop =
            new WeightedRandomChestContent(
                new ItemStack(OpenBlocks.Items.stencil, 1, stencil.ordinal()), 1, 1, 2);
        ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(drop);
        ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR).addItem(drop);
      }
    }

    if (OpenBlocks.Items.squeegee != null) {
      if (OpenBlocks.Blocks.sponge != null) {
        recipeList.add(
            new ShapedOreRecipe(
                OpenBlocks.Items.squeegee,
                "sss",
                " w ",
                " w ",
                's',
                OpenBlocks.Blocks.sponge,
                'w',
                "stickWood"));
      } else {
        recipeList.add(
            new ShapedOreRecipe(
                OpenBlocks.Items.squeegee,
                "sss",
                " w ",
                " w ",
                's',
                Items.slime_ball,
                'w',
                "stickWood"));
      }
    }

    if (OpenBlocks.Items.emptyMap != null) {
      if (OpenBlocks.Items.heightMap != null) {
        recipeList.add(new MapCloneRecipe());
      }

      recipeList.add(new MapResizeRecipe());

      ItemStack memory = MetasGeneric.mapMemory.newItemStack(2);
      ItemStack cpu = MetasGeneric.mapController.newItemStack(1);
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Items.emptyMap.createMap(0), " m ", "mcm", " m ", 'm', memory, 'c', cpu));
    }

    if (OpenBlocks.Items.cartographer != null) {
      recipeList.add(
          new ShapelessOreRecipe(
              OpenBlocks.Items.cartographer,
              MetasGeneric.assistantBase.newItemStack(),
              Items.ender_eye));
    }

    if (OpenBlocks.Items.goldenEye != null) {
      recipeList.add(new GoldenEyeRechargeRecipe());
      recipeList.add(
          new ShapedOreRecipe(
              new ItemStack(OpenBlocks.Items.goldenEye, 1, ItemGoldenEye.MAX_DAMAGE),
              "ggg",
              "geg",
              "ggg",
              'g',
              Items.gold_nugget,
              'e',
              Items.ender_eye));
    }

    if (OpenBlocks.Items.tastyClay != null) {
      final ItemStack cocoa = new ItemStack(Items.dye, 1, ColorUtils.BROWN);
      recipeList.add(
          new ShapelessOreRecipe(
              new ItemStack(OpenBlocks.Items.tastyClay, 2),
              Items.clay_ball,
              Items.milk_bucket,
              cocoa));
    }

    if (OpenBlocks.Items.cursor != null) {
      final ItemStack whiteWool = ColorUtils.createDyedWool(ColorUtils.WHITE);
      recipeList.add(
          new ShapedOreRecipe(OpenBlocks.Items.cursor, "w  ", "www", "www", 'w', whiteWool));
    }

    if (OpenBlocks.Items.tunedCrystal != null) {
      for (RadioStation station : RadioManager.instance.getRadioStations()) {
        WeightedRandomChestContent drop =
            new WeightedRandomChestContent(station.getStack().copy(), 1, 1, 2);
        ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(drop);
        ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR).addItem(drop);
      }
    }

    if (OpenBlocks.Items.infoBook != null) {
      recipeList.add(
          new ShapelessOreRecipe(
              new ItemStack(OpenBlocks.Items.infoBook), Items.clay_ball, Items.book));
    }

    if (OpenBlocks.Items.devNull != null) {
      MinecraftForge.EVENT_BUS.register(OpenBlocks.Items.devNull);
      recipeList.add(
          new ShapelessOreRecipe(
              new ItemStack(OpenBlocks.Items.devNull), Blocks.cobblestone, Items.apple));
    }

    if (OpenBlocks.Items.spongeonastick != null) {
      if (OpenBlocks.Blocks.sponge != null) {
        recipeList.add(
            new ShapedOreRecipe(
                OpenBlocks.Items.spongeonastick,
                " s ",
                " w ",
                " w ",
                's',
                OpenBlocks.Blocks.sponge,
                'w',
                "stickWood"));
      }
    }

    if (OpenBlocks.Items.pedometer != null) {
      recipeList.add(
          new ShapedOreRecipe(
              OpenBlocks.Items.pedometer,
              "www",
              "rcr",
              "www",
              'w',
              "plankWood",
              'r',
              Items.redstone,
              'c',
              Items.clock));
    }

    OpenBlocks.Fluids.xpJuice =
        new Fluid("xpjuice")
            .setLuminosity(10)
            .setDensity(800)
            .setViscosity(1500)
            .setUnlocalizedName("OpenBlocks.xpjuice");
    FluidRegistry.registerFluid(OpenBlocks.Fluids.xpJuice);

    if (OpenBlocks.Items.filledBucket != null) {
      MetasBucket.registerItems();
    }

    if (explosiveEnchantmentId > 0) {
      MinecraftForge.EVENT_BUS.register(new ExplosiveEnchantmentsHandler());
      Enchantments.explosive = new EnchantmentExplosive(explosiveEnchantmentId);
    }

    if (lastStandEnchantmentId > 0) {
      MinecraftForge.EVENT_BUS.register(new LastStandEnchantmentsHandler());
      Enchantments.lastStand = new EnchantmentLastStand(lastStandEnchantmentId);
    }

    if (flimFlamEnchantmentId > 0) {
      MinecraftForge.EVENT_BUS.register(new FlimFlamEnchantmentsHandler());
      Enchantments.flimFlam = new EnchantmentFlimFlam(flimFlamEnchantmentId);

      for (int i = 0; i < 4; i++) {
        int emeraldCount = 1 << i;
        ItemStack result =
            Items.enchanted_book.getEnchantedItemStack(
                new EnchantmentData(Enchantments.flimFlam, i + 1));
        Object recipe[] = new Object[emeraldCount + 1];
        recipe[0] = Items.book;
        Arrays.fill(recipe, 1, recipe.length, Items.emerald);
        recipeList.add(new ShapelessOreRecipe(result, recipe));
      }
    }
  }
  @Override
  public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) {

    if (craftMatrix instanceof InventoryCrafting) {

      EntityPlayerMP fp;
      if (player instanceof EntityPlayerMP) fp = (EntityPlayerMP) player;
      else fp = BukkitContainer.MOD_PLAYER;

      InventoryCrafting inv = (InventoryCrafting) craftMatrix;
      Iterator<IRecipe> irec = (Iterator<IRecipe>) CraftingManager.getInstance().recipes.iterator();
      IRecipe targ = null;
      while (irec.hasNext()) {
        IRecipe r = irec.next();
        if (r.matches(inv, player.worldObj)) {
          targ = r;
          break;
        }
      }

      if (targ == null) return;

      Recipe recipe = new BukkitRecipe(targ);

      InventoryView what =
          new CraftInventoryView(
              CraftPlayerCache.getCraftPlayer(fp),
              new CraftInventoryCrafting(inv, player.inventory),
              inv.eventHandler);

      // Should be slot of crafting container, will only be trouble if ever have crafting table with
      // more than one slot
      CraftItemEvent ev = new CraftItemEvent(recipe, what, SlotType.CRAFTING, 0, false, false);

      Bukkit.getPluginManager().callEvent(ev);
      if (ev.isCancelled()) {
        // Believe it is too late to do this, this just clears the workbench which has already
        // happened
        // if (!(inv.eventHandler instanceof ContainerWorkbench)) return;
        // ContainerWorkbench cc = (ContainerWorkbench) inv.eventHandler;
        // InventoryCraftResult iv = (InventoryCraftResult) cc.craftResult;
        // iv.setInventorySlotContents(0, null);

        int itemsToRemove = item.stackSize > 0 ? item.stackSize : 1;

        // Is item in hand (single craft)
        if ((player.inventory.getItemStack() != null)
            && (player.inventory.getItemStack().getItem().itemID == item.getItem().itemID)) {
          itemsToRemove = itemsToRemove - player.inventory.getItemStack().stackSize;
          player.inventory.setItemStack(null); // Remove it
          ((EntityPlayerMP) player).updateHeldItem();
        }

        // If item not removed from hand, or not all crafted were removed from hand
        if (itemsToRemove > 0) {
          for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
            if (player.inventory.getStackInSlot(i) != null
                && player.inventory.getStackInSlot(i).getItem().itemID == item.getItem().itemID) {
              int stackSize = ((InventoryPlayer) player.inventory).getStackInSlot(i).stackSize;
              if (stackSize < itemsToRemove) {
                ((InventoryPlayer) player.inventory).decrStackSize(i, stackSize);
                itemsToRemove = itemsToRemove - stackSize;
              } else {
                ((InventoryPlayer) player.inventory).decrStackSize(i, itemsToRemove);
                itemsToRemove = 0;
              }

              if (itemsToRemove == 0) break;
            }
          }
        }

        if (itemsToRemove == 0) // Assume we couldn't remove item, so dont give back ingredients
        {
          // Add ingredients back
          for (int i = 0; i < inv.getSizeInventory(); i++) {
            if (inv.getStackInSlot(i) != null && inv.getStackInSlot(i).stackSize != 0) {
              ItemStack putBack = inv.getStackInSlot(i).copy();
              putBack.stackSize = 1;
              player.inventory.addItemStackToInventory(putBack);
            }
          }
        }
      }
    }
  }