2016-02-28 07:00:22 +01:00
|
|
|
package techreborn.utils;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraftforge.oredict.OreDictionary;
|
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
public class OreDictUtils
|
|
|
|
{
|
2016-02-28 07:00:22 +01:00
|
|
|
|
2016-07-16 11:44:54 +02:00
|
|
|
public static String toFirstLower(String string) {
|
|
|
|
if(string == null || string.isEmpty()) return string;
|
|
|
|
return Character.toLowerCase(string.charAt(0)) + string.substring(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String toFirstUpper(String string) {
|
|
|
|
if(string.isEmpty()) return string;
|
|
|
|
return Character.toUpperCase(string.charAt(0)) + string.substring(1);
|
|
|
|
}
|
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
public static boolean isOre(Block block, String oreName)
|
|
|
|
{
|
2016-02-28 07:00:22 +01:00
|
|
|
return isOre(new ItemStack(Item.getItemFromBlock(block)), oreName);
|
|
|
|
}
|
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
public static boolean isOre(IBlockState state, String oreName)
|
|
|
|
{
|
|
|
|
return isOre(
|
|
|
|
new ItemStack(Item.getItemFromBlock(state.getBlock()), 1, state.getBlock().getMetaFromState(state)),
|
|
|
|
oreName);
|
2016-02-28 07:00:22 +01:00
|
|
|
}
|
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
public static boolean isOre(Item item, String oreName)
|
|
|
|
{
|
2016-02-28 07:00:22 +01:00
|
|
|
return isOre(new ItemStack(item), oreName);
|
|
|
|
}
|
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
public static boolean isOre(ItemStack stack, String oreName)
|
|
|
|
{
|
|
|
|
if (stack != null && stack.getItem() != null && oreName != null)
|
|
|
|
{
|
2016-02-28 20:18:59 +01:00
|
|
|
int id = OreDictionary.getOreID(oreName);
|
2016-02-28 07:00:22 +01:00
|
|
|
int[] ids = OreDictionary.getOreIDs(stack);
|
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
for (int i : ids)
|
|
|
|
{
|
|
|
|
if (id == i)
|
|
|
|
{
|
2016-02-28 07:00:22 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|