Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public static boolean createItemFromRecipe(EntityPlayer player, Recipe r) {
  2. ItemStack[] inventory = player.inventory.mainInventory;
  3.  
  4. ItemStack[] recipeItems = r.getRecipeItems();
  5. ItemStack itemToMake = r.getItemStack();
  6. ItemStack[] foundItems = new ItemStack[recipeItems.length - 1];
  7.  
  8. int foundCount = 0;
  9. int recipeItem = 0;
  10.  
  11. //check if player has the items required for the recipe in his/her inventory
  12. while(foundItems.length <= foundItems.length) {
  13. if(recipeItems.equals(foundItems)) {
  14. return true;
  15. } else {
  16. for(int i = 0; i < inventory.length; i++) {
  17. if(inventory[i] != null) {
  18. if(ItemStack.areItemStacksEqual(recipeItems[recipeItem], inventory[i])) {
  19. foundItems[foundCount++] = recipeItems[recipeItem];
  20. break;
  21. }
  22. }
  23. }
  24. recipeItem++;
  25. }
  26. }
  27. return false;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement