Skip to content

Commit

Permalink
Oredict support for custom materials
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Aug 23, 2014
1 parent 762f74b commit 1dd13c5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
Expand Up @@ -140,7 +140,7 @@ public int getPartValue (ItemStack material)

for (CustomMaterial mat : TConstructRegistry.customMaterials)
{
if (material.isItemEqual(mat.input))
if (mat.matches(material))
return mat.value;
}
}
Expand Down
35 changes: 30 additions & 5 deletions src/main/java/tconstruct/library/tools/CustomMaterial.java
@@ -1,26 +1,51 @@
package tconstruct.library.tools;

import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

import java.util.List;

public abstract class CustomMaterial
{
public final int materialID;
public final int value;
public final ItemStack input;
public final ItemStack craftingItem;
public final String oredict;

public CustomMaterial(int materialID, int value, ItemStack input, ItemStack craftingItem)
{
this.materialID = materialID;
this.value = value;
this.input = input;
this.craftingItem = craftingItem;
this.oredict = null;
}

public CustomMaterial(int materialID, int value, String oredict, ItemStack craftingItem)
{
this.materialID = materialID;
this.value = value;
this.input = null;
this.craftingItem = craftingItem;
this.oredict = oredict;
}

/*
* public boolean matches(ItemStack input, ItemStack pattern) { if
* (ItemStack.areItemStacksEqual(this.input, input) &&
* ItemStack.areItemStacksEqual(this.craftingPattern, pattern)) return true;
* return false; }
/**
* Wether an itemstack is a stack of this custom material or not.
*/
public boolean matches(ItemStack stack)
{
if(this.oredict != null)
{
List<ItemStack> items = OreDictionary.getOres(oredict);
for(ItemStack item : items)
if(OreDictionary.itemMatches(item, stack, false))
return true;
return false;
}
return stack.isItemEqual(input);
}

}
@@ -0,0 +1,4 @@
package tconstruct.library.tools;

public class FletchlingLeafMaterial {
}

0 comments on commit 1dd13c5

Please sign in to comment.