Place IAutoCrafter interface into AutoCrafting class

Looking at saving space plus its a one method interface
This commit is contained in:
DarkGuardsman 2013-09-02 15:30:46 -04:00
parent 5a563266cc
commit c9a8298058
3 changed files with 20 additions and 26 deletions

View file

@ -26,27 +26,22 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import dark.common.BlockRegistry.BlockData; import dark.common.BlockRegistry.BlockData;
import dark.common.blocks.BlockOre; import dark.common.blocks.BlockOre;
import dark.common.debug.BlockDebug; import dark.common.debug.BlockDebug;
import dark.common.debug.BlockDebug.debugBlocks;
import dark.common.items.EnumMeterials; import dark.common.items.EnumMeterials;
import dark.common.items.ItemBattery; import dark.common.items.ItemBattery;
import dark.common.items.ItemBlockOre; import dark.common.items.ItemBlockOre;
import dark.common.items.ItemOreDirv; import dark.common.items.ItemOreDirv;
import dark.common.items.ItemParts; import dark.common.items.ItemParts;
import dark.common.items.ItemParts.Parts;
import dark.common.items.ItemTools; import dark.common.items.ItemTools;
import dark.common.items.ItemWrench; import dark.common.items.ItemWrench;
import dark.common.items.ItemParts.Parts;
import dark.common.transmit.BlockWire; import dark.common.transmit.BlockWire;
import dark.common.transmit.TileEntityWire;
import dark.prefab.BlockMulti; import dark.prefab.BlockMulti;
import dark.prefab.ModPrefab; import dark.prefab.ModPrefab;
import dark.prefab.TileEntityMulti; import dark.prefab.TileEntityMulti;
import dark.prefab.helpers.FluidRestrictionHandler; import dark.prefab.helpers.FluidRestrictionHandler;
import dark.prefab.helpers.SaveManager;
import dark.prefab.items.ItemBlockHolder;
/** @author HangCow, DarkGuardsman */ /** @author HangCow, DarkGuardsman */
@Mod(modid = DarkMain.MOD_ID, name = DarkMain.MOD_NAME, version = DarkMain.VERSION, dependencies = "after:BuildCraft|Energy", useMetadata = true) @Mod(modid = DarkMain.MOD_ID, name = DarkMain.MOD_NAME, version = DarkMain.VERSION, dependencies = "after:BuildCraft|Energy", useMetadata = true)
@ -221,13 +216,13 @@ public class DarkMain extends ModPrefab
@ForgeSubscribe @ForgeSubscribe
public void onWorldSave(WorldEvent.Save event) public void onWorldSave(WorldEvent.Save event)
{ {
SaveManager.save(!event.world.isRemote); //SaveManager.save(!event.world.isRemote);
} }
@EventHandler @EventHandler
public void serverStopping(FMLServerStoppingEvent event) public void serverStopping(FMLServerStoppingEvent event)
{ {
SaveManager.save(true); //SaveManager.save(true);
} }
@Override @Override

View file

@ -20,7 +20,7 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.ReflectionHelper;
/** Rewrite of the imprinter crafting system into its own manageable class /** Rewrite of the imprinter crafting system into its own manageable class
* *
* @author DarkGuardsman */ * @author DarkGuardsman */
public class AutoCraftingManager public class AutoCraftingManager
{ {
@ -57,7 +57,7 @@ public class AutoCraftingManager
} }
/** Does this player's inventory contain the required resources to craft this item? /** Does this player's inventory contain the required resources to craft this item?
* *
* @return Required items to make the desired item. */ * @return Required items to make the desired item. */
public Pair<ItemStack, ItemStack[]> getIdealRecipe(ItemStack outputItem) public Pair<ItemStack, ItemStack[]> getIdealRecipe(ItemStack outputItem)
{ {
@ -123,7 +123,7 @@ public class AutoCraftingManager
} }
/** Gets the itemStacks in the inv based on slots /** Gets the itemStacks in the inv based on slots
* *
* @param inv - @IInventory instance * @param inv - @IInventory instance
* @param slots - slot # to be used * @param slots - slot # to be used
* @return array of itemStack the same size as the slots input array */ * @return array of itemStack the same size as the slots input array */
@ -143,7 +143,7 @@ public class AutoCraftingManager
} }
/** Returns if the following inventory has the following resource required. /** Returns if the following inventory has the following resource required.
* *
* @param recipeItems - The items to be checked for the recipes. */ * @param recipeItems - The items to be checked for the recipes. */
public ArrayList<ItemStack> hasResource(Object[] recipeItems) public ArrayList<ItemStack> hasResource(Object[] recipeItems)
{ {
@ -231,7 +231,7 @@ public class AutoCraftingManager
} }
/** Decreases the stack by a set amount /** Decreases the stack by a set amount
* *
* @param stack - starting stack * @param stack - starting stack
* @param amount - amount of items * @param amount - amount of items
* @return the edited stack */ * @return the edited stack */
@ -262,7 +262,7 @@ public class AutoCraftingManager
} }
/** Checks if an item exist within the inv array /** Checks if an item exist within the inv array
* *
* @param recipeItem - itemstack being searched for * @param recipeItem - itemstack being searched for
* @param containingItems - inv array containing the search bounds * @param containingItems - inv array containing the search bounds
* @return the point in the array the item was found -1 = the item was null or not valid -2 = * @return the point in the array the item was found -1 = the item was null or not valid -2 =
@ -294,14 +294,14 @@ public class AutoCraftingManager
/** Checks if itemstack are equal based on crafting result rather than normal itemstack this is /** Checks if itemstack are equal based on crafting result rather than normal itemstack this is
* done so that if the itemstack returns with * done so that if the itemstack returns with
* *
* @param recipeItem - itemstack being compared * @param recipeItem - itemstack being compared
* @param checkStack - itemstack being comparted * @param checkStack - itemstack being comparted
* @return true if the items are a match for each other * @return true if the items are a match for each other
* *
* If the item can't be stack and is able to take damage the item will be check on damaged * If the item can't be stack and is able to take damage the item will be check on damaged
* status * status
* *
* If the item's meta data is not normal or in other words equals 32767 the meta data will be * If the item's meta data is not normal or in other words equals 32767 the meta data will be
* ignored */ * ignored */
public static boolean areStacksEqual(ItemStack recipeItem, ItemStack checkStack) public static boolean areStacksEqual(ItemStack recipeItem, ItemStack checkStack)
@ -322,7 +322,7 @@ public class AutoCraftingManager
} }
/** Consumes an item checking for extra conditions like container items /** Consumes an item checking for extra conditions like container items
* *
* @param stack - starting itemStack * @param stack - starting itemStack
* @param ammount - amount to consume * @param ammount - amount to consume
* @return what is left of the itemStack if any */ * @return what is left of the itemStack if any */
@ -367,7 +367,7 @@ public class AutoCraftingManager
} }
/** Used to automatically remove selected items from crafting inv /** Used to automatically remove selected items from crafting inv
* *
* @param requiredItems - items that are to be removed */ * @param requiredItems - items that are to be removed */
public void consumeItems(ItemStack... requiredItems) public void consumeItems(ItemStack... requiredItems)
{ {
@ -394,4 +394,10 @@ public class AutoCraftingManager
} }
} }
} }
public static interface IAutoCrafter
{
/** The slots used by the crafter for resources */
public int[] getCraftingInv();
}
} }

View file

@ -1,7 +0,0 @@
package dark.prefab.helpers;
public interface IAutoCrafter
{
/** The slots used by the crafter for resources */
public int[] getCraftingInv();
}