net.minecraft.item.crafting.IRecipe Java Examples

The following examples show how to use net.minecraft.item.crafting.IRecipe. 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: GTTileDisassembler.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void init() {
	if (GTConfig.general.enableDisassembler) {
		for (IRecipe recipe : ForgeRegistries.RECIPES) {
			ItemStack input = recipe.getRecipeOutput().copy();
			List<ItemStack> outputList = new ArrayList<>();
			for (int i = 0; i < recipe.getIngredients().size(); ++i) {
				List<ItemStack> tempList = new ArrayList<>();
				Collections.addAll(tempList, recipe.getIngredients().get(i).getMatchingStacks());
				if (!tempList.isEmpty()) {
					ItemStack tempStack = isHighValueMaterial(tempList.get(0).copy()) ? Ic2Items.scrapMetal.copy()
							: tempList.get(0).copy();
					if (canItemBeReturned(tempStack)) {
						outputList.add(tempStack);
					}
				}
			}
			if (canInputBeUsed(input) && !outputList.isEmpty()) {
				ItemStack[] arr = outputList.toArray(new ItemStack[0]);
				addRecipe(new IRecipeInput[] { new RecipeInputItemStack(input) }, totalEu(5000), arr);
			}
		}
	}
}
 
Example #2
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 #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 : 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: 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 #5
Source File: CommonProxy.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@SubscribeEvent
   public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
	//boildEdamame
	GameRegistry.addSmelting( new ItemStack(ItemLoader.material,1,3), new ItemStack(ItemLoader.foodset,16,22), 0.25f);
	//SoyBeenParched
	GameRegistry.addSmelting( new ItemStack(ItemLoader.soybeans,1), new ItemStack(ItemLoader.material,1,6), 0.2f);

	GameRegistry.addSmelting( new ItemStack(ItemLoader.material,1,13), new ItemStack(ItemLoader.material,1,14), 0.2f);
	
	RecipesUtil.addOreDictionarySmelting("listAlltofu", new ItemStack(ItemLoader.tofu_food,1,3), 0.2f);
	
	GameRegistry.addSmelting(new ItemStack(ItemLoader.tofu_food,1,2), new ItemStack(ItemLoader.foodset,1,16), 0.2f);
	GameRegistry.addSmelting(new ItemStack(ItemLoader.material,1,20), new ItemStack(ItemLoader.foodset,1,8), 0.2f);
	GameRegistry.addSmelting(new ItemStack(ItemLoader.foodset,1,11), new ItemStack(ItemLoader.foodset,1,12), 0.2f);
	
	RecipesUtil.addOreDictionarySmelting("listAlltofuBlock", new ItemStack(BlockLoader.GRILD), 0.6f);
}
 
Example #6
Source File: RecipeSorterTFC.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
public int compareRecipes(IRecipe irecipe, IRecipe irecipe1)
{
	if (irecipe instanceof ShapelessRecipes && irecipe1 instanceof ShapedRecipes)
	{
		return 1;
	}
	if (irecipe1 instanceof ShapelessRecipes && irecipe instanceof ShapedRecipes)
	{
		return -1;
	}
	if (irecipe1.getRecipeSize() < irecipe.getRecipeSize())
	{
		return -1;
	}
	return irecipe1.getRecipeSize() <= irecipe.getRecipeSize() ? 0 : 1;
}
 
Example #7
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 #8
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 #9
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 #10
Source File: CommonProxy.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
    GTLog.logger.info("Registering ore dictionary...");

    MetaItems.registerOreDict();
    MetaBlocks.registerOreDict();
    OreDictionaryLoader.init();
    MaterialInfoLoader.init();

    GTLog.logger.info("Registering recipes...");

    MetaItems.registerRecipes();
    MachineRecipeLoader.init();
    CraftingRecipeLoader.init();
    MetaTileEntityLoader.init();
    RecipeHandlerList.register();
}
 
Example #11
Source File: ItemBookCode.java    From Minecoprocessors with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public static void registerRecipes(final RegistryEvent.Register<IRecipe> event) {
  NonNullList<Ingredient> lst = NonNullList.create();
  lst.add(Ingredient.fromItem(Items.WRITABLE_BOOK));
  lst.add(Ingredient.fromItem(BlockMinecoprocessor.ITEM_INSTANCE));
  event.getRegistry().register(new ShapelessRecipes("", new ItemStack(ItemBookCode.INSTANCE), lst) {
    @Override
    public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
      NonNullList<ItemStack> l = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);

      for (int i = 0; i < l.size(); ++i) {
        ItemStack stack = inv.getStackInSlot(i);

        if (stack.getItem() == BlockMinecoprocessor.ITEM_INSTANCE) {
          ItemStack returnStack = stack.copy();
          returnStack.setCount(1);
          l.set(i, returnStack);
          return l;
        }
      }

      throw new RuntimeException("Item to return not found in inventory");
    }
  }.setRegistryName(ItemBookCode.REGISTRY_NAME));
}
 
Example #12
Source File: MinecraftRecipeRegistry.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean remove(Object o) {
	if (!backwardWrappers.containsKey(o)) {
		return false;
	}

	boolean result = original.remove(o);
	if (result) {
		onMinecraftRecipeRemoved((IRecipe) o);
	}

	return result;
}
 
Example #13
Source File: RecipeConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public IRecipe toNative(CraftingRecipe recipe) {
	if (recipe instanceof ShapedCraftingRecipe) {
		return toNative((ShapedCraftingRecipe) recipe);
	} else if (recipe instanceof ShapelessCraftingRecipe) {
		return toNative((ShapelessCraftingRecipe) recipe);
	} else {
		return new NovaCraftingRecipe(recipe);
	}
}
 
Example #14
Source File: StandardRecipePage.java    From OpenModsLib with MIT License 5 votes vote down vote up
public StandardRecipePage(String title, String description, @Nonnull ItemStack resultingItem) {
	addComponent(new GuiComponentSprite(75, 40, iconArrow));
	addComponent(new GuiComponentItemStackSpinner(140, 30, resultingItem));

	{
		final IRecipe recipe = RecipeUtils.getFirstRecipeForItemStack(resultingItem);
		if (recipe != null) {
			final ItemStack[][] input = RecipeUtils.getFullRecipeInput(recipe);
			if (input != null) {
				final int width = (recipe instanceof IShapedRecipe)? ((IShapedRecipe)recipe).getRecipeWidth() : 3;
				addComponent(new GuiComponentCraftingGrid(10, 20, input, width, iconCraftingGrid));
			}
		}
	}

	{
		String translatedTitle = TranslationUtils.translateToLocal(title);
		final GuiComponentLabel titleLabel = new GuiComponentLabel(0, 0, translatedTitle);
		titleLabel.setScale(BookScaleConfig.getPageTitleScale());
		addComponent(new GuiComponentHCenter(0, 2, getWidth()).addComponent(titleLabel));
	}

	{
		String translatedDescription = TranslationUtils.translateToLocal(description).replaceAll("\\\\n", "\n");
		GuiComponentLabel lblDescription = new GuiComponentLabel(10, 80, getWidth() - 5, 200, translatedDescription);
		lblDescription.setScale(BookScaleConfig.getPageContentScale());
		lblDescription.setAdditionalLineHeight(BookScaleConfig.getRecipePageSeparator());
		addComponent(lblDescription);
	}
}
 
Example #15
Source File: ShapedRecipeTests.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
private List<IRecipe> createTestRecipes(Item result)
{
    return Lists.newArrayList(new ShapedRecipes("group", 1, 1, NonNullList.from(Ingredient.EMPTY, Ingredient.fromItem(Items.ITEM_FRAME)), new ItemStack(result)),
                              new ShapedRecipes("group", 2, 2,
                                                NonNullList.from(Ingredient.EMPTY,
                                                                 Ingredient.fromStacks(new ItemStack(Blocks.STONE)), Ingredient.fromStacks(new ItemStack(Blocks.STONE)),
                                                                 Ingredient.fromStacks(new ItemStack(Blocks.LOG)), Ingredient.fromStacks(new ItemStack(Blocks.LOG))),
                                                new ItemStack(result)));
}
 
Example #16
Source File: IStructure.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Deprecated
static HashSet<IRecipe> getRecipesForItem(ItemStack stack) {
	HashSet<IRecipe> recipes = new HashSet<>();
	for (IRecipe recipe : ForgeRegistries.RECIPES.getValues()) {
		if (recipe == null) continue;
		if (ItemStack.areItemsEqualIgnoreDurability(recipe.getRecipeOutput(), stack)) {
			recipes.add(recipe);
		}
	}
	return recipes;
}
 
Example #17
Source File: RecipeHandlerRollingMachineShaped.java    From NEI-Integration with MIT License 5 votes vote down vote up
private CachedRollingMachineShapedRecipe getCachedRecipe(IRecipe irecipe, boolean genPerms) {
    CachedRollingMachineShapedRecipe recipe = null;
    if (irecipe instanceof ShapedRecipes) {
        recipe = new CachedRollingMachineShapedRecipe((ShapedRecipes) irecipe, genPerms);
    } else if (irecipe instanceof ShapedOreRecipe) {
        recipe = this.getCachedOreRecipe((ShapedOreRecipe) irecipe, genPerms);
    }
    return recipe;
}
 
Example #18
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 #19
Source File: BaseRecipeRegistry.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
public static IRecipe toolRecipe(ItemStack output, ItemStack X, String Y, String Z) {
    if (isOreRegistered(Y) && isOreRegistered(Z)) {
        for (int i = 0; i < OreDictionary.getOres(Y).size(); i++) {
            for (int j = 0; j < OreDictionary.getOres(Z).size(); j++) {
                return GameRegistry.addShapedRecipe(output, " X ", " Y ", "YZY", 'X', X, 'Y', OreDictionary.getOres(Y).get(j), 'Z', OreDictionary.getOres(Z).get(i));
            }
        }
    }
    return null;
}
 
Example #20
Source File: ReflectionUtil.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void setCraftingRecipeList(List<IRecipe> craftingRecipeList) {
	if (!setPrivateObject(
		CraftingManager.getInstance(),
		craftingRecipeList,
		ObfuscationConstants.CRAFTINGMANAGER_RECIPES)) {
		Game.logger().error("could not set crafting recipe list");
	}
}
 
Example #21
Source File: ShapelessRecipe.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
boolean removeRecipe(Collection<IRecipe> from)
{
    if (items.size() == 0)
    {
        return removeWithResult(from);
    } else if (result == null)
    {
        return removeWithInput(from);
    } else
    {
        return removeWithBoth(from);
    }
}
 
Example #22
Source File: Recipes.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
public static void register() {
	final ItemStack duckAntenna = MetasGeneric.duckAntenna.newItemStack();

	@SuppressWarnings("unchecked")
	final List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList();

	if (OpenPeripheralAddons.Blocks.pim != null) {
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.pim, "ooo", "rcr", 'o', Blocks.obsidian, 'r', Items.redstone, 'c', Blocks.chest));
	}

	if (OpenPeripheralAddons.Blocks.sensor != null) {
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.sensor, "ooo", " w ", "sss", 'o', Blocks.obsidian, 'w', "stickWood", 's', Blocks.stone_slab));
	}

	if (OpenPeripheralAddons.Blocks.glassesBridge != null) {
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.glassesBridge, "sas", "ses", "srs", 's', Blocks.stone, 'r', Blocks.redstone_block, 'e', Items.ender_pearl, 'a', duckAntenna.copy()));
	}

	if (OpenPeripheralAddons.Blocks.selector != null) {
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.selector, "sss", "scs", "sgs", 's', Blocks.stone, 'c', Blocks.trapped_chest, 'g', Blocks.glass_pane));
	}

	if (OpenPeripheralAddons.Items.glasses != null) {
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Items.glasses, "igi", "aei", "prp", 'g', Blocks.glowstone, 'i', Items.iron_ingot, 'e', Items.ender_pearl, 'p', Blocks.glass_pane, 'r', Items.redstone, 'a', duckAntenna.copy()));
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Items.glasses, "igi", "iea", "prp", 'g', Blocks.glowstone, 'i', Items.iron_ingot, 'e', Items.ender_pearl, 'p', Blocks.glass_pane, 'r', Items.redstone, 'a', duckAntenna.copy()));

		recipeList.add(new TerminalAddonRecipe());
		RecipeSorter.register("openperipheraladdons:terminal", TerminalAddonRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
	}

	if (OpenPeripheralAddons.Items.keyboard != null) {
		recipeList.add(new ShapelessOreRecipe(OpenPeripheralAddons.Items.keyboard, duckAntenna.copy(), Items.bone, Items.redstone, Items.ender_pearl, Items.slime_ball));
	}

	if (Loader.isModLoaded(Mods.COMPUTERCRAFT)) ModuleComputerCraft.registerRecipes(recipeList);
	if (Loader.isModLoaded(Mods.RAILCRAFT)) ModuleRailcraft.registerRecipes(recipeList);

}
 
Example #23
Source File: CraftingManagerCS4.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
public static ItemStack findMatchingRecipe(Iterable<IRecipe> recipes, InventoryCrafting craftMatrix, World worldIn)
{
    for (IRecipe irecipe : recipes)
    {
        if (irecipe.matches(craftMatrix, worldIn))
        {
            return irecipe.getCraftingResult(craftMatrix);
        }
    }

    return ItemStack.EMPTY;
}
 
Example #24
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 #25
Source File: ShapedRecipe.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
private boolean matchesInput(IRecipe recipe)
{
    if (recipe instanceof ShapedRecipes)
    {
        return matchesInput((ShapedRecipes) recipe);
    } else if (recipe instanceof ShapedOreRecipe)
    {
        return matchesInput((ShapedOreRecipe) recipe);
    }

    return false;
}
 
Example #26
Source File: MinecraftRecipeRegistry.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public IRecipe set(int index, IRecipe element) {
	IRecipe current = original.get(index);
	onMinecraftRecipeRemoved(current);

	original.set(index, element);
	onMinecraftRecipeAdded(element);

	return current;
}
 
Example #27
Source File: MinecraftRecipeRegistry.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean remove(Object o) {
	if (!backwardWrappers.containsKey(o)) {
		return false;
	}

	boolean result = original.remove(o);
	if (result) {
		onMinecraftRecipeRemoved((IRecipe) o);
	}

	return result;
}
 
Example #28
Source File: MinecraftRecipeRegistry.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void onMinecraftRecipeAdded(IRecipe recipe) {
	if (backwardWrappers.containsKey(recipe)) {
		return;
	}

	CraftingRecipe novaRecipe = convert(recipe);

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

	Game.recipes().addRecipe(novaRecipe);
}
 
Example #29
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 #30
Source File: ShapelessRecipe.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
private boolean removeWithBoth(Collection<IRecipe> from)
{
    List<IRecipe> recipes = from.stream()
                                .filter(this::matchesOutput)
                                .filter(this::matchesInput)
                                .collect(Collectors.toList());

    return from.removeAll(recipes);
}