Adding CompressionHandler for superAwesomeSigilOfAwesome!

This commit is contained in:
WayofTime 2014-11-20 07:57:08 -05:00
parent 90aeaac6e2
commit 75dcf143d5
6 changed files with 330 additions and 3 deletions

View file

@ -0,0 +1,17 @@
package WayofTime.alchemicalWizardry.api.compress;
import net.minecraft.item.ItemStack;
public abstract class CompressionHandler
{
public abstract ItemStack getResultStack();
public abstract ItemStack getRequiredStack();
/**
* Called to look at the inventory and syphons the required stack. Returns getResultStack if successful, and null if not.
* @param inv The inventory iterated through
* @return The result of the compression
*/
public abstract ItemStack compressInventory(ItemStack[] inv);
}

View file

@ -0,0 +1,34 @@
package WayofTime.alchemicalWizardry.api.compress;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
/**
* A registry aimed to help compress items in an inventory into its compressible form.
*
*/
public class CompressionRegistry
{
public static List<CompressionHandler> compressionRegistry = new ArrayList();
public static void registerHandler(CompressionHandler handler)
{
compressionRegistry.add(handler);
}
public static ItemStack compressInventory(ItemStack[] inv)
{
for(CompressionHandler handler : compressionRegistry)
{
ItemStack stack = handler.compressInventory(inv);
if(stack != null)
{
return stack;
}
}
return null;
}
}