Add easy part crafting in the crafting window

This commit is contained in:
Bernhard Bonigl committed 2014-08-15 16:34:39 +02:00
1 parent c7e4f0153a
commit 531cebbca6
3 files changed
+92

No files matched your search

@@ -63,6 +63,7 @@ public class Config {
public static boolean disableStoneTools;
public static boolean castsBurnMaterial;
public static boolean easyToolRepair;
public static boolean easyPartCrafting;
public static boolean allowPartReuse;
public static boolean removeStoneTorchRecipe;
public static boolean moreExpensiveSilkyCloth;
@@ -188,6 +189,7 @@ public class Config {
disableStoneTools = configfile.getBoolean("disableStoneTools", CATEGORY_Tweaks, true, "Stone Tools can only be used to create casts, but no tools");
castsBurnMaterial = configfile.getBoolean("castingBurnsMaterial", CATEGORY_Tweaks, true, "Creating a metal cast burns up the material that was used to create it");
easyToolRepair = configfile.getBoolean("easyToolRepair", CATEGORY_Tweaks, true, "Allows to repair your tool in a crafting grid, without tool station");
easyPartCrafting = configfile.getBoolean("easyPartCrafting", CATEGORY_Tweaks, false, "Allows to craft tool parts with a pattern and the material in any crafting grid.");
allowPartReuse = configfile.getBoolean("allowPartReuse", CATEGORY_Tweaks, true, "Allows toolparts to be used as material in the Part Builder. Like, turn a Pick head into a Shovel head.!");
// stuff
@@ -144,6 +144,9 @@ public class IguanaTweaks {
// has to be added after exchanging the repair modifier, to obtain the correct cache
if(Config.easyToolRepair)
GameRegistry.addRecipe(new RepairCraftingRecipe());
if(Config.easyPartCrafting)
GameRegistry.addRecipe(new PartCraftingRecipe());
}
private void flintTweaks()
@@ -0,0 +1,87 @@
package iguanaman.iguanatweakstconstruct.tweaks;
import iguanaman.iguanatweakstconstruct.reference.Reference;
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.TConstructRegistry;
import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.util.IPattern;
import tconstruct.tools.items.Pattern;
public class PartCraftingRecipe implements IRecipe {
static {
// register the recipe with the recipesorter
RecipeSorter.register(Reference.MOD_ID + ":part", RepairCraftingRecipe.class, RecipeSorter.Category.SHAPELESS, "");
}
private ItemStack outputPart;
@Override
public boolean matches(InventoryCrafting inventoryCrafting, World world) {
outputPart = null;
ItemStack pattern = null;
ItemStack input = 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() instanceof IPattern) {
// only one pattern
if(pattern != null)
return false;
pattern = slot;
// otherwise.. input material
}
else {
if(input != null)
return false;
input = slot;
}
}
if(pattern == null || input == null)
return false;
// make sure it's a valid pattern
if(!PatternBuilder.instance.toolPatterns.contains(pattern.getItem()))
return false;
ItemStack[] output = PatternBuilder.instance.getToolPart(input, pattern, null);
if(output == null)
return false;
for(ItemStack stack : output)
if(stack != null) {
outputPart = stack;
return true;
}
return false;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
return outputPart;
}
@Override
public int getRecipeSize() {
return 2;
}
@Override
public ItemStack getRecipeOutput() {
return outputPart;
}
}