001/* 002 * Trident - A Multithreaded Server Alternative 003 * Copyright 2014 The TridentSDK Team 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package net.tridentsdk.inventory.crafting; 018 019import net.tridentsdk.inventory.Item; 020import net.tridentsdk.registry.Registered; 021import net.tridentsdk.util.Value; 022 023import java.util.Collections; 024import java.util.List; 025 026/** 027 * Manages server crafting and smelting recipes 028 * 029 * @author The TridentSDK Team 030 * @since 0.4-alpha 031 */ 032public interface RecipeManager { 033 Value<RecipeManager> instance = Value.none(); 034 035 /** 036 * Obtains an instance of the recipe manager 037 * 038 * @return the recipe manager instance 039 */ 040 static RecipeManager instance() { 041 RecipeManager recipeManager = instance.get(); 042 if (recipeManager == null) { 043 recipeManager = instance.set(Registered.impl().recipe()); 044 } 045 return recipeManager; 046 } 047 048 /** 049 * Adds a recipe without a shape 050 * 051 * @param result the result of the recipe 052 * @param source the items required to craft the result 053 */ 054 void addShapelessRecipe(Item result, List<Item> source); 055 056 /** 057 * Adds a recipe with a specified shape 058 * 059 * @param result the result of the recipe 060 * @param grid the shape of the recipe 061 * @param source the items required to craft the result 062 */ 063 void addShapedRecipe(Item result, char[][] grid, List<CraftTuple> source); 064 065 /** 066 * Adds a smelting recipe to the server 067 * 068 * @param result the result of smelting 069 * @param source the item to smelt 070 * @param smeltTicks the ticks required to smelt the item 071 * @param experience the experience earned from smelting the item 072 */ 073 void addSmeltingRecipe(Item result, Item source, int smeltTicks, float experience); 074 075 /** 076 * Adds a smelting fuel type 077 * 078 * @param source the fuel 079 * @param burnTicks the ticks to burn 080 * @param returnItem the item to return TODO what? 081 */ 082 void addSmeltingFuel(Item source, int burnTicks, Item returnItem); 083 084 /** 085 * Adds a shapeless recipe 086 * 087 * @param result the result of the recipe 088 * @param source the item that the recipe consumes 089 */ 090 default void addShapelessRecipe(Item result, Item source) { 091 addShapelessRecipe(result, Collections.singletonList(source)); 092 } 093 094 /** 095 * Adds a shaped recipe using a single source 096 * 097 * @param result the result of the recipe 098 * @param grid the recipe shape 099 * @param source the recipe ingredients 100 */ 101 default void addShapedRecipe(Item result, char[][] grid, CraftTuple source) { 102 addShapedRecipe(result, grid, Collections.singletonList(source)); 103 } 104 105 /** 106 * Adds a smelting fuel item 107 * 108 * @param source the item type 109 * @param burnTicks the ticks the item burns for 110 */ 111 default void addSmeltingFuel(Item source, int burnTicks) { 112 addSmeltingFuel(source, burnTicks, null); 113 } 114}