From c60d03428d4840ec2badace431d6f67480916ee1 Mon Sep 17 00:00:00 2001 From: jsrobson10 Date: Mon, 27 Jul 2020 12:50:34 +1000 Subject: [PATCH] Added recipe init function --- src/projectzombie/init/Recipies.java | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/projectzombie/init/Recipies.java diff --git a/src/projectzombie/init/Recipies.java b/src/projectzombie/init/Recipies.java new file mode 100644 index 0000000..61507f7 --- /dev/null +++ b/src/projectzombie/init/Recipies.java @@ -0,0 +1,48 @@ +package projectzombie.init; + +import java.util.ArrayList; + +import projectzombie.inventory.Crafting; +import projectzombie.inventory.recipe.Recipe; +import projectzombie.inventory.recipe.RecipeBasic; +import projectzombie.util.math.ItemStack; + +public class Recipies +{ + public static ArrayList recipies; + + public static Recipe[] getCraftableRecipies(Crafting tool) + { + int size = 0; + + for(Recipe recipe : recipies) { + size += recipe.canCraft(tool) ? 1 : 0; + } + + int upto = 0; + Recipe[] craftable_recipies = new Recipe[size]; + + for(Recipe recipe : recipies) + { + if(recipe.canCraft(tool)) { + craftable_recipies[upto] = recipe; + upto += 1; + } + } + + return craftable_recipies; + } + + public static void init() + { + recipies = new ArrayList(); + + recipies.add(new RecipeBasic( + new ItemStack[] { + new ItemStack(Items.FLINT, 2, (short)0), + new ItemStack(Items.PLANT_FIBRE, 5, (short)0), + }, new Crafting[] { + Crafting.BASIC, + }, new ItemStack(Items.AMMO, 99, (short)0))); + } +}