net.minecraft.item.crafting.CraftingManager Java Examples

The following examples show how to use net.minecraft.item.crafting.CraftingManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModHandler.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static Pair<IRecipe, ItemStack> getRecipeOutput(World world, ItemStack... recipe) {
    if (recipe == null || recipe.length == 0)
        return ImmutablePair.of(null, ItemStack.EMPTY);

    if (world == null) world = DummyWorld.INSTANCE;

    InventoryCrafting craftingGrid = new InventoryCrafting(new DummyContainer(), 3, 3);

    for (int i = 0; i < 9 && i < recipe.length; i++) {
        ItemStack recipeStack = recipe[i];
        if (recipeStack != null && !recipeStack.isEmpty()) {
            craftingGrid.setInventorySlotContents(i, recipeStack);
        }
    }

    for (IRecipe tmpRecipe : CraftingManager.REGISTRY) {
        if (tmpRecipe.matches(craftingGrid, world)) {
            ItemStack itemStack = tmpRecipe.getCraftingResult(craftingGrid);
            return ImmutablePair.of(tmpRecipe, itemStack);
        }
    }

    return ImmutablePair.of(null, ItemStack.EMPTY);
}
 
Example #2
Source File: TileCraftingGrid.java    From Translocators with MIT License 6 votes vote down vote up
public void craft(EntityPlayer player) {
    InventoryCrafting craftMatrix = getCraftMatrix();

    for (int i = 0; i < 4; i++) {
        ItemStack mresult = CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj);
        if (mresult != null) {
            doCraft(mresult, craftMatrix, player);
            break;
        }

        rotateItems(craftMatrix);
    }
    player.swingItem();
    dropItems();
    worldObj.setBlockToAir(xCoord, yCoord, zCoord);
}
 
Example #3
Source File: ShapedRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void loadUsageRecipes(ItemStack ingredient) {
    for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
        CachedShapedRecipe recipe = null;
        if (irecipe instanceof ShapedRecipes)
            recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
        else if (irecipe instanceof ShapedOreRecipe)
            recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);

        if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem()))
            continue;

        recipe.computeVisuals();
        if (recipe.contains(recipe.ingredients, ingredient)) {
            recipe.setIngredientPermutation(recipe.ingredients, ingredient);
            arecipes.add(recipe);
        }
    }
}
 
Example #4
Source File: ShapedRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void loadCraftingRecipes(ItemStack result) {
    for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
        if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
            CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes)
                recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
            else if (irecipe instanceof ShapedOreRecipe)
                recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);

            if (recipe == null)
                continue;

            recipe.computeVisuals();
            arecipes.add(recipe);
        }
    }
}
 
Example #5
Source File: ShapedRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
    if (outputId.equals("crafting") && getClass() == ShapedRecipeHandler.class) {
        for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
            CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes)
                recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
            else if (irecipe instanceof ShapedOreRecipe)
                recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);

            if (recipe == null)
                continue;

            recipe.computeVisuals();
            arecipes.add(recipe);
        }
    } else {
        super.loadCraftingRecipes(outputId, results);
    }
}
 
Example #6
Source File: ShapelessRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@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);
        }
    }
}
 
Example #7
Source File: ShapelessRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@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);
        }
    }
}
 
Example #8
Source File: ShapelessRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@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);
    }
}
 
Example #9
Source File: EnderStorageRecipe.java    From EnderStorage with MIT License 6 votes vote down vote up
public static void removeVanillaChest() {
    GameDataManipulator.replaceItem(Block.getIdFromBlock(Blocks.ender_chest), new ItemEnderChestDummy());
    Iterator<IRecipe> iterator = CraftingManager.getInstance().getRecipeList().iterator();
    while (iterator.hasNext()) {
        ItemStack r = iterator.next().getRecipeOutput();
        if (r != null && r.getItem() == Item.getItemFromBlock(Blocks.ender_chest))
            iterator.remove();
    }

    if (!EnderStorage.removeVanillaRecipe)
        CraftingManager.getInstance().addRecipe(new ItemStack(Blocks.ender_chest),
                "OOO",
                "OeO",
                "OOO",
                'O', Blocks.obsidian,
                'e', Items.ender_eye);
}
 
Example #10
Source File: ShapedRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void loadUsageRecipes(ItemStack ingredient) {
    for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
        CachedShapedRecipe recipe = null;
        if (irecipe instanceof ShapedRecipes) {
            recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
        } else if (irecipe instanceof ShapedOreRecipe) {
            recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
        }

        if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem())) {
            continue;
        }

        recipe.computeVisuals();
        if (recipe.contains(recipe.ingredients, ingredient)) {
            recipe.setIngredientPermutation(recipe.ingredients, ingredient);
            arecipes.add(recipe);
        }
    }
}
 
Example #11
Source File: ShapedRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void loadCraftingRecipes(ItemStack result) {
    for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
        if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
            CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes) {
                recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
            } else if (irecipe instanceof ShapedOreRecipe) {
                recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
            }

            if (recipe == null) {
                continue;
            }

            recipe.computeVisuals();
            arecipes.add(recipe);
        }
    }
}
 
Example #12
Source File: ShapedRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
    if (outputId.equals("crafting") && getClass() == ShapedRecipeHandler.class) {
        for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
            CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes) {
                recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
            } else if (irecipe instanceof ShapedOreRecipe) {
                recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
            }

            if (recipe == null) {
                continue;
            }

            recipe.computeVisuals();
            arecipes.add(recipe);
        }
    } else {
        super.loadCraftingRecipes(outputId, results);
    }
}
 
Example #13
Source File: ShapelessRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@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);
        }
    }
}
 
Example #14
Source File: ShapelessRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@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);
    }
}
 
Example #15
Source File: AutoCraftModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();

        if (this.recipe.getValue().length() > 0 && this.timer.passed(this.delay.getValue())) {
            if (mc.currentScreen == null || mc.currentScreen instanceof GuiInventory || mc.currentScreen instanceof GuiCrafting) {
                mc.player.connection.sendPacket(new CPacketPlaceRecipe(mc.player.openContainer.windowId, CraftingManager.getRecipe(new ResourceLocation(this.recipe.getValue().toLowerCase())), true));

                mc.playerController.windowClick(mc.player.openContainer.windowId, 0, 0, this.drop.getValue() ? ClickType.THROW : ClickType.QUICK_MOVE, mc.player);
                mc.playerController.updateController();
            }

            this.timer.reset();
        }
    }
}
 
Example #16
Source File: CraftingRecipeResolver.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void updateCurrentRecipe() {
    IRecipe newRecipe = CraftingManager.findMatchingRecipe(inventoryCrafting, world);
    if (cachedRecipe != newRecipe) {
        this.cachedRecipe = newRecipe;
        if (newRecipe != null) {
            ItemStack resultStack = newRecipe.getCraftingResult(inventoryCrafting).copy();
            this.craftingResultInventory.setStackInSlot(0, resultStack.copy());
            this.cachedRecipeData = new CachedRecipeData(itemSourceList, newRecipe, resultStack.copy());
            copyInventoryItems(craftingGrid, new InvWrapper(this.cachedRecipeData.inventory));
            this.cachedRecipeData.attemptMatchRecipe();
        } else {
            this.craftingResultInventory.setStackInSlot(0, ItemStack.EMPTY);
            this.cachedRecipeData = null;
        }
    }
}
 
Example #17
Source File: CircuitImprintLoader.java    From bartworks with MIT License 6 votes vote down vote up
private static void removeOldRecipesFromRegistries() {
    recipeWorldCache.forEach(CraftingManager.getInstance().getRecipeList()::remove);
    BWCoreStaticReplacementMethodes.RECENTLYUSEDRECIPES.clear();
    gtrecipeWorldCache.forEach(GT_Recipe.GT_Recipe_Map.sSlicerRecipes.mRecipeList::remove);
    recipeWorldCache.forEach( r ->
            {
                try {
                    BW_Util.getGTBufferedRecipeList().remove(r);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            );
    recipeWorldCache.clear();
    gtrecipeWorldCache.clear();
}
 
Example #18
Source File: ShapelessRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@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);
        }
    }
}
 
Example #19
Source File: ModRecipes.java    From GardenCollection with MIT License 5 votes vote down vote up
private void addExtraWoodRecipes () {
    RecipeSorter.register("GardenTrees:WoodBlock", WoodBlockRecipe.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped");
    RecipeSorter.register("GardenTrees:WoodPost", WoodPostRecipe.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped");
    RecipeSorter.register("GardenTrees:WoodFence", WoodFenceRecipe.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped");

    for (Map.Entry<UniqueMetaIdentifier, Block> entry : WoodRegistry.instance().registeredTypes()) {
        UniqueMetaIdentifier id = entry.getKey();

        CraftingManager.getInstance().getRecipeList().add(new WoodPostRecipe(id));
        CraftingManager.getInstance().getRecipeList().add(new WoodFenceRecipe(id));
        CraftingManager.getInstance().getRecipeList().add(new WoodBlockRecipe(id));
    }
}
 
Example #20
Source File: CraftingManagerCS4.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
private static Iterable<IRecipe> getRecipesIterable(ResourceLocation list)
{
    if (list.toString().equals("minecraft:vanilla"))
    {
        return CraftingManager.REGISTRY;
    } else
    {
        return getInstance(list).recipes;
    }
}
 
Example #21
Source File: MinecraftRecipeRegistry.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void onNOVARecipeAdded(RecipeEvent.Add<CraftingRecipe> evt) {
	CraftingRecipe recipe = evt.recipe;
	if (forwardWrappers.containsKey(recipe)) {
		return;
	}

	IRecipe minecraftRecipe = convert(recipe);

	backwardWrappers.put(minecraftRecipe, recipe);
	forwardWrappers.put(recipe, minecraftRecipe);

	CraftingManager.getInstance().getRecipeList().add(minecraftRecipe);
}
 
Example #22
Source File: RecipeHandlerShapedCustom.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public void loadAllRecipes() {
    for (Object recipe : CraftingManager.getInstance().getRecipeList()) {
        if (recipe instanceof ShapedRecipeCustom) {
            this.arecipes.add(new CachedShapedCustomRecipe((ShapedRecipeCustom) recipe));
        }
    }
}
 
Example #23
Source File: RecipeHandlerShapedCustom.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public void loadCraftingRecipes(ItemStack result) {
    for (Object recipe : CraftingManager.getInstance().getRecipeList()) {
        if (recipe instanceof ShapedRecipeCustom && Utils.areStacksSameTypeCraftingSafe(((ShapedRecipeCustom) recipe).getRecipeOutput(), result)) {
            this.arecipes.add(new CachedShapedCustomRecipe((ShapedRecipeCustom) recipe));
        }
    }
}
 
Example #24
Source File: RecipeHandlerShapedCustom.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public void loadUsageRecipes(ItemStack ingredient) {
    for (Object recipe : CraftingManager.getInstance().getRecipeList()) {
        if (recipe instanceof ShapedRecipeCustom) {
            CachedShapedCustomRecipe crecipe = new CachedShapedCustomRecipe((ShapedRecipeCustom) recipe);
            if (crecipe.inputs != null && crecipe.contains(crecipe.inputs, ingredient)) {
                crecipe.setIngredientPermutationNBT(crecipe.inputs, ingredient);
                this.arecipes.add(crecipe);
            }
        }
    }
}
 
Example #25
Source File: SlotItemHandlerCraftResult.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ItemStack onTake(EntityPlayer player, ItemStack stack)
{
    this.onCrafting(stack);

    net.minecraftforge.common.ForgeHooks.setCraftingPlayer(player);
    NonNullList<ItemStack> remainingItems = CraftingManager.getRemainingItems(this.craftMatrix, player.getEntityWorld());
    net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);

    for (int i = 0; i < remainingItems.size(); i++)
    {
        ItemStack stackInSlot = this.craftMatrix.getStackInSlot(i);
        ItemStack remainingItemsInSlot = remainingItems.get(i);

        if (stackInSlot.isEmpty() == false)
        {
            this.craftMatrix.decrStackSize(i, 1);
            stackInSlot = this.craftMatrix.getStackInSlot(i);
        }

        if (remainingItemsInSlot.isEmpty() == false)
        {
            if (stackInSlot.isEmpty())
            {
                this.craftMatrix.setInventorySlotContents(i, remainingItemsInSlot);
            }
            else if (ItemStack.areItemsEqual(stackInSlot, remainingItemsInSlot) &&
                     ItemStack.areItemStackTagsEqual(stackInSlot, remainingItemsInSlot))
            {
                remainingItemsInSlot.grow(stackInSlot.getCount());
                this.craftMatrix.setInventorySlotContents(i, remainingItemsInSlot);
            }
            else if (this.player.inventory.addItemStackToInventory(remainingItemsInSlot) == false)
            {
                this.player.dropItem(remainingItemsInSlot, false);
            }
        }
    }

    return stack;
}
 
Example #26
Source File: TileCraftingGrid.java    From Translocators with MIT License 5 votes vote down vote up
private void updateResult() {
    InventoryCrafting craftMatrix = getCraftMatrix();

    for (int i = 0; i < 4; i++) {
        ItemStack mresult = CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj);
        if (mresult != null) {
            result = mresult;
            return;
        }

        rotateItems(craftMatrix);
    }

    result = null;
}
 
Example #27
Source File: Recipes.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static void RegisterNormalRecipes()
{
	CraftingManagerTFC manager = CraftingManagerTFC.getInstance();
	manager.addShapelessRecipe(RecipeType.NORMAL, new ItemStack(TFCItems.StoneAxe), new ItemStack(TFCItems.ToolHead, 1, ToolHeadType.STONE_AXE.ordinal()), "stickWood");
	manager.addShapelessRecipe(RecipeType.NORMAL, new ItemStack(TFCItems.StoneKnife), new ItemStack(TFCItems.ToolHead, 1, ToolHeadType.STONE_KNIFE.ordinal()), "stickWood");
	manager.addShapelessRecipe(RecipeType.NORMAL, new ItemStack(TFCItems.StoneShovel), new ItemStack(TFCItems.ToolHead, 1, ToolHeadType.STONE_SHOVEL.ordinal()), "stickWood");
	manager.addShapelessRecipe(RecipeType.NORMAL, new ItemStack(TFCItems.StoneHoe), new ItemStack(TFCItems.ToolHead, 1, ToolHeadType.STONE_HOE.ordinal()), "stickWood");
	manager.addRecipe(RecipeType.NORMAL, new ItemStack(TFCItems.Firestarter), " X","X ", 'X', "stickWood");
	manager.addRecipe(RecipeType.NORMAL, new ItemStack(TFCBlocks.Thatch), new Object[]{"XX", "XX", Character.valueOf('X'), new ItemStack(TFCItems.Straw, 1)});
	manager.addShapelessRecipe(RecipeType.NORMAL, new ItemStack(TFCItems.Straw, 4), new Object[]{new ItemStack(TFCBlocks.Thatch, 1)});

	manager.addShapelessRecipe(RecipeType.NORMAL_REPAIR, new ItemStack(TFCItems.StoneAxe), new ItemStack(TFCItems.StoneAxe, 1, WILDCARD), new ItemStack(TFCItems.LooseRock, 1, WILDCARD));
	manager.addShapelessRecipe(RecipeType.NORMAL_REPAIR, new ItemStack(TFCItems.StoneKnife), new ItemStack(TFCItems.StoneKnife, 1, WILDCARD), new ItemStack(TFCItems.LooseRock, 1, WILDCARD));
	manager.addShapelessRecipe(RecipeType.NORMAL_REPAIR, new ItemStack(TFCItems.StoneShovel), new ItemStack(TFCItems.StoneShovel, 1, WILDCARD), new ItemStack(TFCItems.LooseRock, 1, WILDCARD));
	manager.addShapelessRecipe(RecipeType.NORMAL_REPAIR, new ItemStack(TFCItems.StoneHoe), new ItemStack(TFCItems.StoneHoe, 1, WILDCARD), new ItemStack(TFCItems.LooseRock, 1, WILDCARD));

	List<IRecipe> list = CraftingManager.getInstance().getRecipeList();
	for(int i = 0; i < list.size(); i++)
	{
		IRecipe rec = list.get(i);
		if(rec.getRecipeOutput().getItem() == Item.getItemFromBlock(Blocks.CRAFTING_TABLE))
		{
			CraftingManager.getInstance().getRecipeList().remove(i);
		}

	}
}
 
Example #28
Source File: BlockMarbleStairsMaker.java    From Chisel with GNU General Public License v2.0 5 votes vote down vote up
public void create(BlockMarbleStairsMakerCreator creator, String name)
{
    blocks = new BlockMarbleStairs[carverHelper.variations.size() / 2];
    for(int i = 0; i < blocks.length; i++)
    {
        String n = name + "." + i;
        blocks[i] = creator == null ?
                new BlockMarbleStairs(blockBase, i * 2, carverHelper) :
                creator.create(blockBase, i * 2, carverHelper);

        blocks[i].setBlockName(n);
        GameRegistry.registerBlock(blocks[i], ItemCarvable.class, n);

        for(int meta = 0; meta < 2 && i * 2 + meta < carverHelper.variations.size(); meta++)
        {
            CarvableVariation variation = carverHelper.variations.get(i * 2 + meta);

            for(int j = 0; j < 8; j++)
                carverHelper.registerVariation(name + ".orientation." + j, variation, blocks[i], j + meta * 8);

            CraftingManager.getInstance().addRecipe(new ItemStack(blocks[i], 4, meta * 8), new Object[]{"*  ", "** ", "***", '*', new ItemStack(blockBase, 1, i * 2 + meta)});
        }

        CarvableHelper.chiselBlocks.add(blocks[i]);
    }

}
 
Example #29
Source File: BotaniaAPI.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
/**
 * 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;
}
 
Example #30
Source File: CraftingRegistrator.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds recipes like 9 gold ingot --> 1 gold block, and 1 gold block --> 9 gold ingots.
 */
public static void addPressureChamberStorageBlockRecipes(){
    List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
    for(IRecipe recipe : recipes) {
        if(recipe instanceof ShapedRecipes) {
            ShapedRecipes shaped = (ShapedRecipes)recipe;
            ItemStack[] input = shaped.recipeItems;
            ItemStack ref = input[0];
            if(ref == null || input.length < 9) continue;
            boolean valid = true;
            for(int i = 0; i < 9; i++) {
                if(input[i] == null || !input[i].isItemEqual(ref)) {
                    valid = false;
                    break;
                }
            }
            if(valid) {
                ItemStack inputStack = ref.copy();
                inputStack.stackSize = 9;
                PressureChamberRecipe.chamberRecipes.add(new PressureChamberRecipe(new ItemStack[]{inputStack}, 1.0F, new ItemStack[]{shaped.getRecipeOutput()}, false));

                ItemStack inputStack2 = shaped.getRecipeOutput().copy();
                inputStack2.stackSize = 1;
                PressureChamberRecipe.chamberRecipes.add(new PressureChamberRecipe(new ItemStack[]{inputStack2}, -0.5F, new ItemStack[]{inputStack}, false));

            }
        }
    }
}