This commit is contained in:
modmuss50 2017-06-11 21:22:07 +01:00
parent b6cf2a2c59
commit 29cf9fa90b
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
68 changed files with 220 additions and 222 deletions

View file

@ -29,12 +29,16 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import org.apache.commons.lang3.Validate;
import reborncore.common.util.CraftingHelper;
import java.util.ArrayList;
import java.util.HashMap;
@ -43,27 +47,27 @@ import java.util.List;
public class RollingMachineRecipe {
public static final RollingMachineRecipe instance = new RollingMachineRecipe();
private final List<IRecipe> recipes = new ArrayList<>();
private final HashMap<ResourceLocation, IRecipe> recipes = new HashMap<>();
public void addShapedOreRecipe(ItemStack outputItemStack, Object... objectInputs) {
Validate.notNull(outputItemStack);
Validate.notNull(outputItemStack.getItem());
if (objectInputs.length == 0) {
Validate.notNull(null); //Quick way to crash
}
recipes.add(new ShapedOreRecipe(outputItemStack, objectInputs));
public void addShapedOreRecipe(ResourceLocation resourceLocation, ItemStack outputItemStack, Object... objectInputs) {
// Validate.notNull(outputItemStack);
// Validate.notNull(outputItemStack.getItem());
// if (objectInputs.length == 0) {
// Validate.notNull(null); //Quick way to crash
// }
// recipes.put(resourceLocation, new ShapedOreRecipe(resourceLocation, outputItemStack, objectInputs));
}
public void addShapelessOreRecipe(ItemStack outputItemStack, Object... objectInputs) {
Validate.notNull(outputItemStack);
Validate.notNull(outputItemStack.getItem());
if (objectInputs.length == 0) {
Validate.notNull(null); //Quick way to crash
}
recipes.add(new ShapelessOreRecipe(outputItemStack, objectInputs));
public void addShapelessOreRecipe(ResourceLocation resourceLocation, ItemStack outputItemStack, Object... objectInputs) {
// Validate.notNull(outputItemStack);
// Validate.notNull(outputItemStack.getItem());
// if (objectInputs.length == 0) {
// Validate.notNull(null); //Quick way to crash
// }
// recipes.put(resourceLocation, new ShapelessOreRecipe(resourceLocation, outputItemStack, objectInputs));
}
public void addRecipe(ItemStack output, Object... components) {
public void addRecipe(ResourceLocation resourceLocation, ItemStack output, Object... components) {
String s = "";
int i = 0;
int j = 0;
@ -98,39 +102,25 @@ public class RollingMachineRecipe {
hashmap.put(character, itemstack1);
}
ItemStack recipeArray[] = new ItemStack[j * k];
NonNullList<Ingredient> recipeArray = NonNullList.create();
for (int i1 = 0; i1 < j * k; i1++) {
char c = s.charAt(i1);
if (hashmap.containsKey(c)) {
recipeArray[i1] = ((ItemStack) hashmap.get(c)).copy();
recipeArray.set(i1, CraftingHelper.toIngredient(((ItemStack) hashmap.get(c)).copy()));
} else {
recipeArray[i1] = null;
recipeArray.set(i1, CraftingHelper.toIngredient(ItemStack.EMPTY));
}
}
recipes.add(new ShapedRecipes(j, k, recipeArray, output));
recipes.put(resourceLocation, new ShapedRecipes("", j, k, recipeArray, output));
}
public void addShapelessRecipe(ItemStack output, Object... components) {
List<ItemStack> ingredients = new ArrayList<>();
public void addShapelessRecipe(ResourceLocation resourceLocation,ItemStack output, Object... components) {
NonNullList<Ingredient> ingredients = NonNullList.create();
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!");
}
ingredients.add(CraftingHelper.toIngredient(components[j]));
}
recipes.add(new ShapelessRecipes(output, ingredients));
recipes.put(resourceLocation, new ShapelessRecipes("", output, ingredients));
}
public ItemStack findMatchingRecipe(InventoryCrafting inv, World world) {
@ -144,7 +134,7 @@ public class RollingMachineRecipe {
return null;
}
public List<IRecipe> getRecipeList() {
public HashMap<ResourceLocation, IRecipe> getRecipeList() {
return recipes;
}

View file

@ -27,6 +27,7 @@ package techreborn.api;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import techreborn.api.recipe.IRecipeCompact;
public final class TechRebornAPI {
@ -38,20 +39,20 @@ public final class TechRebornAPI {
public static ISubItemRetriever subItemRetriever;
public static void addRollingOreMachinceRecipe(ItemStack output, Object... components) {
RollingMachineRecipe.instance.addShapedOreRecipe(output, components);
public static void addRollingOreMachinceRecipe(ResourceLocation resourceLocation, ItemStack output, Object... components) {
RollingMachineRecipe.instance.addShapedOreRecipe(resourceLocation, output, components);
}
public static void addShapelessOreRollingMachinceRecipe(ItemStack output, Object... components) {
RollingMachineRecipe.instance.addShapelessOreRecipe(output, components);
public static void addShapelessOreRollingMachinceRecipe(ResourceLocation resourceLocation, ItemStack output, Object... components) {
RollingMachineRecipe.instance.addShapelessOreRecipe(resourceLocation,output, components);
}
public static void addRollingMachinceRecipe(ItemStack output, Object... components) {
RollingMachineRecipe.instance.addRecipe(output, components);
public static void addRollingMachinceRecipe(ResourceLocation resourceLocation, ItemStack output, Object... components) {
RollingMachineRecipe.instance.addRecipe(resourceLocation,output, components);
}
public static void addShapelessRollingMachinceRecipe(ItemStack output, Object... components) {
RollingMachineRecipe.instance.addShapelessRecipe(output, components);
public static void addShapelessRollingMachinceRecipe(ResourceLocation resourceLocation, ItemStack output, Object... components) {
RollingMachineRecipe.instance.addShapelessRecipe(resourceLocation,output, components);
}
/**