From 3bea7e5a078fee7624df4e0c9902eec3a49dd362 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Fri, 2 Jan 2015 12:47:10 +0100 Subject: [PATCH] Forgot to add the class for the alternate bolt recipe ;_; --- .../weaponry/AlternateBoltRecipe.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/main/java/tconstruct/weaponry/AlternateBoltRecipe.java diff --git a/src/main/java/tconstruct/weaponry/AlternateBoltRecipe.java b/src/main/java/tconstruct/weaponry/AlternateBoltRecipe.java new file mode 100644 index 00000000..56107d3a --- /dev/null +++ b/src/main/java/tconstruct/weaponry/AlternateBoltRecipe.java @@ -0,0 +1,83 @@ +package tconstruct.weaponry; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; +import net.minecraftforge.oredict.RecipeSorter; +import tconstruct.library.crafting.PatternBuilder; +import tconstruct.library.tools.DualMaterialToolPart; +import tconstruct.library.util.IPattern; +import tconstruct.library.util.IToolPart; +import tconstruct.tools.TinkerTools; +import tconstruct.util.Reference; + +public class AlternateBoltRecipe implements IRecipe { + static { + // register the recipe with the recipesorter + RecipeSorter.register(Reference.MOD_ID + ":part", AlternateBoltRecipe.class, RecipeSorter.Category.SHAPELESS, ""); + } + + private ItemStack outputPart; + + @Override + public boolean matches(InventoryCrafting inventoryCrafting, World world) { + outputPart = null; + ItemStack rod = null; + ItemStack head = null; + + for(int i = 0; i < inventoryCrafting.getSizeInventory(); i++) + { + ItemStack slot = inventoryCrafting.getStackInSlot(i); + // empty slot + if(slot == null) + continue; + + // is it the tool? + if(slot.getItem() == TinkerWeaponry.arrowhead) { + // only one arrowhead + if(head != null) + return false; + + head = slot; + } + else if(slot.getItem() == TinkerTools.toolRod) { + // only one rod + if(rod != null) + return false; + + rod = slot; + } + else { + // unknown object + return false; + } + } + + if(rod == null || head == null) + return false; + + // craft the bolt + int mat1 = ((IToolPart)rod.getItem()).getMaterialID(rod); + int mat2 = ((IToolPart)head.getItem()).getMaterialID(head); + + outputPart = DualMaterialToolPart.createDualMaterial(TinkerWeaponry.partBolt, mat1, mat2); + + return outputPart != null; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting inventory) { + return outputPart; + } + + @Override + public int getRecipeSize() { + return 2; + } + + @Override + public ItemStack getRecipeOutput() { + return outputPart; + } +}