Skip to content

Commit

Permalink
Forgot to add the class for the alternate bolt recipe ;_;
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Jan 2, 2015
1 parent 195dfc7 commit 3bea7e5
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions 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;
}
}

0 comments on commit 3bea7e5

Please sign in to comment.