Advertisement
Guest User

Untitled

a guest
Dec 27th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. package com.nitrodev.warehousestorage.recipes.custom;
  2.  
  3.  
  4. import com.nitrodev.warehousestorage.items.ModItems;
  5. import net.minecraft.init.Blocks;
  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.world.World;
  11.  
  12. public class PlankRecipe implements IRecipe {
  13.     ItemStack[] result = new ItemStack[4];
  14.  
  15.     result = null;
  16.  
  17.     @Override
  18.     public boolean matches(InventoryCrafting inventoryCrafting, World world) {
  19.         ItemStack saw = null;
  20.         ItemStack slab = null;
  21.  
  22.         for (int i = 0; i < inventoryCrafting.getSizeInventory(); ++i) {
  23.             ItemStack stackInSlot = inventoryCrafting.getStackInSlot(i);
  24.  
  25.             if (stackInSlot != null) {
  26.                 if (stackInSlot.getItem() == ModItems.itemSaw) {
  27.                     if (saw != null) return false;
  28.                     saw = stackInSlot;
  29.                 }
  30.                 if (stackInSlot.getItem() == Item.getItemFromBlock(Blocks.wooden_slab)) {
  31.                     if (slab != null) return false;
  32.                     slab = stackInSlot;
  33.                 }
  34.  
  35.             }
  36.  
  37.         }
  38.         return saw != null && slab != null;
  39.     }
  40.  
  41.     @Override
  42.     public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
  43.         return getRecipeOutput().copy();
  44.     }
  45.  
  46.     @Override
  47.     public int getRecipeSize() {
  48.         return 4;
  49.     }
  50.  
  51.     @Override
  52.     public ItemStack getRecipeOutput() {
  53.         return new ItemStack(ModItems.itemPlank);
  54.     }
  55.  
  56.     @Override
  57.     public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) {
  58.         return result;
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement