Advertisement
Fer22f

Player-only crafting

Jan 21st, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. package fer22f.mods.satcom;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import net.minecraft.inventory.InventoryCrafting;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.item.crafting.IRecipe;
  10. import net.minecraft.item.crafting.ShapelessRecipes;
  11. import net.minecraft.world.World;
  12.  
  13. public class RecipeSeeds extends ShapelessRecipes implements IRecipe {
  14.  
  15. public static List items = new ArrayList();
  16.  
  17. static
  18. {
  19. items.add(new ItemStack(Item.sugar));
  20. items.add(new ItemStack(Item.seeds));
  21. }
  22.  
  23. public RecipeSeeds()
  24. {
  25. super(new ItemStack(Item.seeds), items);
  26. }
  27.  
  28. public boolean matches(InventoryCrafting matri, World world) {
  29. if (matri.getSizeInventory() != 4)
  30. return false;
  31.  
  32. boolean foundSeed = false;
  33. boolean foundSugar = false;
  34.  
  35. for (int i = 0; i < matri.getSizeInventory(); i++) {
  36. if (matri.getStackInSlot(i) == null)
  37. continue;
  38.  
  39. if (matri.getStackInSlot(i).itemID == Item.seeds.itemID)
  40. {
  41. foundSeed = true;
  42. } else
  43.  
  44. if (matri.getStackInSlot(i).itemID == Item.sugar.itemID)
  45. {
  46. foundSugar = true;
  47. }
  48. }
  49.  
  50. return (foundSeed && foundSugar);
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement