Advertisement
Guest User

Untitled

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