summaryrefslogtreecommitdiff
path: root/ihl/recipes/RecipeInputWire.java
blob: 0bf285532ee2d9a66c6d3ff6f653bfba8639afe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package ihl.recipes;

import java.util.Arrays;
import java.util.List;

import ic2.api.recipe.IRecipeInput;
import ihl.interfaces.IWire;
import ihl.items_blocks.FlexibleCableItem;
import ihl.utils.IHLUtils;
import net.minecraft.item.ItemStack;

public class RecipeInputWire implements IRecipeInput
{
    public final ItemStack input;
    public final int amount;

    public RecipeInputWire(final ItemStack aInput)
    {
        this(aInput, IHLUtils.getWireLength(aInput));
    }

    public RecipeInputWire(final ItemStack aInput, int aAmount)
    {
        if (aInput.getItem() == null || !(aInput.getItem() instanceof IWire))
        {
            throw new IllegalArgumentException("Invalid item stack specfied");
        }
        else
        {
            this.input = aInput;
            this.amount = aAmount;
        }
    }

    public RecipeInputWire(String string, int i) 
    {
    	this(IHLUtils.getThisModWireItemStackWithLength(string, i),i);
	}
    
    public RecipeInputWire(String material, int length, int transverseSection) 
    {
    	this(IHLUtils.getUninsulatedWire(material, length, transverseSection),length);
	}
    
    public RecipeInputWire(String material, int length, int transverseSection, String insulationMaterial, int insulationThickness, int insulationBreakdownVoltage) 
    {
    	this(IHLUtils.getInsulatedWire(material, length, transverseSection, insulationMaterial, insulationThickness),length);
	}

	@Override
	public boolean matches(ItemStack subject)
    {
       if(subject.getItem() == this.input.getItem() && (subject.getItemDamage() == this.input.getItemDamage() || this.input.getItemDamage() == 32767))
       {
    	   if(subject.getItem() instanceof FlexibleCableItem)
    	   {
    		   FlexibleCableItem item = (FlexibleCableItem) subject.getItem();
    		   return item.isSameWire(this.input, subject);
    	   }
    	   else
    	   {
    		   return true;
    	   }
       }
       return false;
    }

    @Override
	public int getAmount()
    {
        return this.amount;
    }

    @Override
	public List<ItemStack> getInputs()
    {
        return Arrays.asList(new ItemStack[] {this.input});
    }

    @Override
	public String toString()
    {
        ItemStack stack = this.input.copy();
        return "RInputWireItemStack<" + stack + ">";
    }
}