mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
Oredict support for custom materials
This commit is contained in:
1 parent
762f74bc7a
commit
1dd13c5a5f
3 files changed
+35
-6
No files matched your search
@@ -1,6 +1,10 @@
|
||||
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
|
||||
{
|
||||
@@ -8,6 +12,7 @@ public abstract class CustomMaterial
|
||||
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)
|
||||
{
|
||||
@@ -15,12 +20,32 @@ public abstract class CustomMaterial
|
||||
this.value = value;
|
||||
this.input = input;
|
||||
this.craftingItem = craftingItem;
|
||||
this.oredict = null;
|
||||
}
|
||||
|
||||
/*
|
||||
* public boolean matches(ItemStack input, ItemStack pattern) { if
|
||||
* (ItemStack.areItemStacksEqual(this.input, input) &&
|
||||
* ItemStack.areItemStacksEqual(this.craftingPattern, pattern)) return true;
|
||||
* return false; }
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user