added centrifuge recipe + moved itemUtils to its own class

This commit is contained in:
modmuss50 2015-04-12 10:15:53 +01:00
parent 91495286db
commit fcfc6ed1df
7 changed files with 129 additions and 28 deletions

View file

@ -0,0 +1,54 @@
package techreborn.api;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class CentrifugeRecipie {
ItemStack inputItem;
ItemStack output1, output2, output3, output4;
int tickTime;
public CentrifugeRecipie(ItemStack inputItem, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime) {
this.inputItem = inputItem;
this.output1 = output1;
this.output2 = output2;
this.output3 = output3;
this.output4 = output4;
this.tickTime = tickTime;
}
public CentrifugeRecipie(Item inputItem, int inputAmount, Item output1, Item output2, Item output3, Item output4, int tickTime) {
this.inputItem = new ItemStack(inputItem, inputAmount);
this.output1 = new ItemStack(output1);
this.output2 = new ItemStack(output2);
this.output3 = new ItemStack(output3);
this.output4 = new ItemStack(output4);
this.tickTime = tickTime;
}
public ItemStack getInputItem() {
return inputItem;
}
public ItemStack getOutput1() {
return output1;
}
public ItemStack getOutput2() {
return output2;
}
public ItemStack getOutput3() {
return output3;
}
public ItemStack getOutput4() {
return output4;
}
public int getTickTime() {
return tickTime;
}
}

View file

@ -1,5 +1,35 @@
package techreborn.api;
import techreborn.util.ItemUtils;
import java.util.ArrayList;
public final class TechRebornAPI {
public static ArrayList<CentrifugeRecipie> centrifugeRecipies = new ArrayList<CentrifugeRecipie>();
public static void registerCentrifugeRecipe(CentrifugeRecipie recipie){
boolean shouldAdd = true;
for(CentrifugeRecipie centrifugeRecipie : centrifugeRecipies){
if(ItemUtils.isItemEqual(centrifugeRecipie.getInputItem(), recipie.getInputItem(), false, true)){
try {
throw new RegisteredItemRecipe("Item " + recipie.getInputItem().getUnlocalizedName() + " is already being used in a recipe for the Centrifuge");
} catch (RegisteredItemRecipe registeredItemRecipe) {
registeredItemRecipe.printStackTrace();
shouldAdd = false;
}
}
}
if(shouldAdd)
centrifugeRecipies.add(recipie);
}
}
class RegisteredItemRecipe extends Exception
{
public RegisteredItemRecipe(String message)
{
super(message);
}
}