Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Oredict support for custom materials
- Loading branch information
Showing
3 changed files
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 30 additions & 5 deletions
35
src/main/java/tconstruct/library/tools/CustomMaterial.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/tconstruct/library/tools/FletchlingLeafMaterial.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package tconstruct.library.tools; | ||
|
||
public class FletchlingLeafMaterial { | ||
} |