Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean createItemFromRecipe(EntityPlayer player, Recipe r) {
- ItemStack[] inventory = player.inventory.mainInventory;
- ItemStack[] recipeItems = r.getRecipeItems();
- ItemStack itemToMake = r.getItemStack();
- ItemStack[] foundItems = new ItemStack[recipeItems.length - 1];
- int foundCount = 0;
- int recipeItem = 0;
- //check if player has the items required for the recipe in his/her inventory
- while(foundItems.length <= foundItems.length) {
- if(recipeItems.equals(foundItems)) {
- return true;
- } else {
- for(int i = 0; i < inventory.length; i++) {
- if(inventory[i] != null) {
- if(ItemStack.areItemStacksEqual(recipeItems[recipeItem], inventory[i])) {
- foundItems[foundCount++] = recipeItems[recipeItem];
- break;
- }
- }
- }
- recipeItem++;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement