This commit is contained in:
Gig 2015-04-24 14:20:09 +01:00
parent 6e0ec1d861
commit 4ac26ac086
137 changed files with 10339 additions and 7322 deletions

View file

@ -4,72 +4,83 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class CentrifugeRecipie {
ItemStack inputItem;
ItemStack output1, output2, output3, output4;
int tickTime;
int cells;
ItemStack inputItem;
ItemStack output1, output2, output3, output4;
int tickTime;
int cells;
public CentrifugeRecipie(ItemStack inputItem, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int cells) {
this.inputItem = inputItem;
this.output1 = output1;
this.output2 = output2;
this.output3 = output3;
this.output4 = output4;
this.tickTime = tickTime;
this.cells = cells;
}
public CentrifugeRecipie(ItemStack inputItem, ItemStack output1,
ItemStack output2, ItemStack output3, ItemStack output4,
int tickTime, int cells)
{
this.inputItem = inputItem;
this.output1 = output1;
this.output2 = output2;
this.output3 = output3;
this.output4 = output4;
this.tickTime = tickTime;
this.cells = cells;
}
public CentrifugeRecipie(Item inputItem, int inputAmount, Item output1, Item output2, Item output3, Item output4, int tickTime, int cells) {
this.inputItem = new ItemStack(inputItem, inputAmount);
if (output1 != null)
this.output1 = new ItemStack(output1);
if (output2 != null)
this.output2 = new ItemStack(output2);
if (output3 != null)
this.output3 = new ItemStack(output3);
if (output4 != null)
this.output4 = new ItemStack(output4);
this.tickTime = tickTime;
this.cells = cells;
}
public CentrifugeRecipie(Item inputItem, int inputAmount, Item output1,
Item output2, Item output3, Item output4, int tickTime, int cells)
{
this.inputItem = new ItemStack(inputItem, inputAmount);
if (output1 != null)
this.output1 = new ItemStack(output1);
if (output2 != null)
this.output2 = new ItemStack(output2);
if (output3 != null)
this.output3 = new ItemStack(output3);
if (output4 != null)
this.output4 = new ItemStack(output4);
this.tickTime = tickTime;
this.cells = cells;
}
public CentrifugeRecipie(CentrifugeRecipie centrifugeRecipie) {
this.inputItem = centrifugeRecipie.getInputItem();
this.output1 = centrifugeRecipie.getOutput1();
this.output2 = centrifugeRecipie.getOutput2();
this.output3 = centrifugeRecipie.getOutput3();
this.output4 = centrifugeRecipie.getOutput4();
this.tickTime = centrifugeRecipie.getTickTime();
this.cells = centrifugeRecipie.getCells();
}
public CentrifugeRecipie(CentrifugeRecipie centrifugeRecipie)
{
this.inputItem = centrifugeRecipie.getInputItem();
this.output1 = centrifugeRecipie.getOutput1();
this.output2 = centrifugeRecipie.getOutput2();
this.output3 = centrifugeRecipie.getOutput3();
this.output4 = centrifugeRecipie.getOutput4();
this.tickTime = centrifugeRecipie.getTickTime();
this.cells = centrifugeRecipie.getCells();
}
public ItemStack getInputItem() {
return inputItem;
}
public ItemStack getInputItem()
{
return inputItem;
}
public ItemStack getOutput1() {
return output1;
}
public ItemStack getOutput1()
{
return output1;
}
public ItemStack getOutput2() {
return output2;
}
public ItemStack getOutput2()
{
return output2;
}
public ItemStack getOutput3() {
return output3;
}
public ItemStack getOutput3()
{
return output3;
}
public ItemStack getOutput4() {
return output4;
}
public ItemStack getOutput4()
{
return output4;
}
public int getTickTime() {
return tickTime;
}
public int getTickTime()
{
return tickTime;
}
public int getCells() {
return cells;
}
public int getCells()
{
return cells;
}
}

View file

@ -1,5 +1,9 @@
package techreborn.api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
@ -9,104 +13,118 @@ import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class RollingMachineRecipe {
private final List<IRecipe> recipes = new ArrayList<IRecipe>();
private final List<IRecipe> recipes = new ArrayList<IRecipe>();
public static final RollingMachineRecipe instance = new RollingMachineRecipe();
public static final RollingMachineRecipe instance = new RollingMachineRecipe();
public void addRecipe(ItemStack output, Object... components) {
String s = "";
int i = 0;
int j = 0;
int k = 0;
if(components[i] instanceof String[]) {
String as[] = (String[])components[i++];
for(int l = 0; l < as.length; l++) {
String s2 = as[l];
k++;
j = s2.length();
s = (new StringBuilder()).append(s).append(s2).toString();
}
} else {
while(components[i] instanceof String) {
String s1 = (String)components[i++];
k++;
j = s1.length();
s = (new StringBuilder()).append(s).append(s1).toString();
}
}
HashMap hashmap = new HashMap();
for(; i < components.length; i += 2) {
Character character = (Character)components[i];
ItemStack itemstack1 = null;
if(components[i + 1] instanceof Item) {
itemstack1 = new ItemStack((Item)components[i + 1]);
} else if(components[i + 1] instanceof Block) {
itemstack1 = new ItemStack((Block)components[i + 1], 1, -1);
} else if(components[i + 1] instanceof ItemStack) {
itemstack1 = (ItemStack)components[i + 1];
}
hashmap.put(character, itemstack1);
}
public void addRecipe(ItemStack output, Object... components)
{
String s = "";
int i = 0;
int j = 0;
int k = 0;
if (components[i] instanceof String[])
{
String as[] = (String[]) components[i++];
for (int l = 0; l < as.length; l++)
{
String s2 = as[l];
k++;
j = s2.length();
s = (new StringBuilder()).append(s).append(s2).toString();
}
} else
{
while (components[i] instanceof String)
{
String s1 = (String) components[i++];
k++;
j = s1.length();
s = (new StringBuilder()).append(s).append(s1).toString();
}
}
HashMap hashmap = new HashMap();
for (; i < components.length; i += 2)
{
Character character = (Character) components[i];
ItemStack itemstack1 = null;
if (components[i + 1] instanceof Item)
{
itemstack1 = new ItemStack((Item) components[i + 1]);
} else if (components[i + 1] instanceof Block)
{
itemstack1 = new ItemStack((Block) components[i + 1], 1, -1);
} else if (components[i + 1] instanceof ItemStack)
{
itemstack1 = (ItemStack) components[i + 1];
}
hashmap.put(character, itemstack1);
}
ItemStack recipeArray[] = new ItemStack[j * k];
for(int i1 = 0; i1 < j * k; i1++) {
char c = s.charAt(i1);
if(hashmap.containsKey(Character.valueOf(c))) {
recipeArray[i1] = ((ItemStack)hashmap.get(Character.valueOf(c))).copy();
} else {
recipeArray[i1] = null;
}
}
ItemStack recipeArray[] = new ItemStack[j * k];
for (int i1 = 0; i1 < j * k; i1++)
{
char c = s.charAt(i1);
if (hashmap.containsKey(Character.valueOf(c)))
{
recipeArray[i1] = ((ItemStack) hashmap
.get(Character.valueOf(c))).copy();
} else
{
recipeArray[i1] = null;
}
}
recipes.add(new ShapedRecipes(j, k, recipeArray, output));
}
recipes.add(new ShapedRecipes(j, k, recipeArray, output));
}
public void addShapelessRecipe(ItemStack output, Object... components) {
List<ItemStack> ingredients = new ArrayList<ItemStack>();
for(int j = 0; j < components.length; j++) {
Object obj = components[j];
if(obj instanceof ItemStack) {
ingredients.add(((ItemStack)obj).copy());
continue;
}
if(obj instanceof Item) {
ingredients.add(new ItemStack((Item)obj));
continue;
}
if(obj instanceof Block) {
ingredients.add(new ItemStack((Block)obj));
} else {
throw new RuntimeException("Invalid shapeless recipe!");
}
}
public void addShapelessRecipe(ItemStack output, Object... components)
{
List<ItemStack> ingredients = new ArrayList<ItemStack>();
for (int j = 0; j < components.length; j++)
{
Object obj = components[j];
if (obj instanceof ItemStack)
{
ingredients.add(((ItemStack) obj).copy());
continue;
}
if (obj instanceof Item)
{
ingredients.add(new ItemStack((Item) obj));
continue;
}
if (obj instanceof Block)
{
ingredients.add(new ItemStack((Block) obj));
} else
{
throw new RuntimeException("Invalid shapeless recipe!");
}
}
recipes.add(new ShapelessRecipes(output, ingredients));
}
recipes.add(new ShapelessRecipes(output, ingredients));
}
public ItemStack findMatchingRecipe(InventoryCrafting inv, World world)
{
for (int k = 0; k < recipes.size(); k++)
{
IRecipe irecipe = (IRecipe) recipes.get(k);
if (irecipe.matches(inv, world))
{
return irecipe.getCraftingResult(inv);
}
}
public ItemStack findMatchingRecipe(InventoryCrafting inv, World world) {
for(int k = 0; k < recipes.size(); k++) {
IRecipe irecipe = (IRecipe)recipes.get(k);
if(irecipe.matches(inv, world)) {
return irecipe.getCraftingResult(inv);
}
}
return null;
}
public List<IRecipe> getRecipeList() {
return recipes;
}
return null;
}
public List<IRecipe> getRecipeList()
{
return recipes;
}
}

View file

@ -1,45 +1,58 @@
package techreborn.api;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import techreborn.util.ItemUtils;
import java.util.ArrayList;
public final class TechRebornAPI {
public static ArrayList<CentrifugeRecipie> centrifugeRecipies = new ArrayList<CentrifugeRecipie>();
public static ArrayList<RollingMachineRecipe> rollingmachineRecipes = new ArrayList<RollingMachineRecipe>();
public static ArrayList<CentrifugeRecipie> centrifugeRecipies = new ArrayList<CentrifugeRecipie>();
public static ArrayList<RollingMachineRecipe> rollingmachineRecipes = new ArrayList<RollingMachineRecipe>();
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);
}
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);
}
public static void addRollingMachinceRecipe(ItemStack output,
Object... components)
{
RollingMachineRecipe.instance.addRecipe(output, components);
}
public static void addRollingMachinceRecipe(ItemStack output, Object... components) {
RollingMachineRecipe.instance.addRecipe(output, components);
}
public void addShapelessRollingMachinceRecipe(ItemStack output, Object... components) {
RollingMachineRecipe.instance.addShapelessRecipe(output, components);
}
public void addShapelessRollingMachinceRecipe(ItemStack output,
Object... components)
{
RollingMachineRecipe.instance.addShapelessRecipe(output, components);
}
}
class RegisteredItemRecipe extends Exception {
public RegisteredItemRecipe(String message) {
super(message);
}
public RegisteredItemRecipe(String message)
{
super(message);
}
}

View file

@ -1,3 +1,5 @@
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api;
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
package techreborn.api;
import cpw.mods.fml.common.API;