mirror of
https://github.com/GTNewHorizons/WailaHarvestability.git
synced 2026-11-25 06:14:34 +00:00
37 lines
961 B
Java
37 lines
961 B
Java
package squeek.wailaharvestability.helpers;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraftforge.oredict.OreDictionary;
|
|
|
|
public class OreHelper
|
|
{
|
|
public static boolean isBlockAnOre(Block block)
|
|
{
|
|
return isBlockAnOre(block, 0);
|
|
}
|
|
|
|
public static boolean isBlockAnOre(Block block, int metadata)
|
|
{
|
|
return isItemAnOre(new ItemStack(block, 1, metadata));
|
|
}
|
|
|
|
public static boolean isItemAnOre(ItemStack itemStack)
|
|
{
|
|
// check the ore dictionary to see if it starts with "ore"
|
|
int oreID = -1;
|
|
if ((oreID = OreDictionary.getOreID(itemStack)) != -1 && OreDictionary.getOreName(oreID).startsWith("ore"))
|
|
return true;
|
|
|
|
// ore in the display name (but not part of another word)
|
|
if (itemStack.getDisplayName().matches(".*(^|\\s)([oO]re)($|\\s).*"))
|
|
return true;
|
|
|
|
// ore as the start of the unlocalized name
|
|
if (itemStack.getUnlocalizedName().startsWith("ore"))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
}
|