Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple OreDictionary names #68

Open
wants to merge 1 commit into
base: 1.12
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions src/main/java/cofh/core/util/helpers/ItemHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,54 +313,74 @@ public static boolean oreNameExists(String oreName) {
return oreProxy.oreNameExists(oreName);
}

public static boolean doesMultiOreStartWith(ItemStack stack, String prefix) {
List<Integer> oreIds = oreProxy.getAllOreIDs(stack);
for(int id : oreIds) {
if(OreDictionary.getOreName(id).startsWith(prefix)) {
return true;
}
}
return false;
}

public static boolean doesMultiOreMatch(ItemStack stack, String oreName) {
List<Integer> oreIds = oreProxy.getAllOreIDs(stack);
for(int id : oreIds) {
if(OreDictionary.getOreName(id).equals(oreName)) {
return true;
}
}
return false;
}

public static boolean hasOreName(ItemStack stack) {

return !getOreName(stack).equals("Unknown");
}

public static boolean isBlock(ItemStack stack) {

return getOreName(stack).startsWith(BLOCK);
return doesMultiOreStartWith(stack, BLOCK);
}

public static boolean isOre(ItemStack stack) {

return getOreName(stack).startsWith(ORE);
return doesMultiOreStartWith(stack, ORE);
}

public static boolean isCluster(ItemStack stack) {

return getOreName(stack).startsWith(CLUSTER);
return doesMultiOreStartWith(stack, CLUSTER);
}

public static boolean isDust(ItemStack stack) {

return getOreName(stack).startsWith(DUST);
return doesMultiOreStartWith(stack, DUST);
}

public static boolean isIngot(ItemStack stack) {

return getOreName(stack).startsWith(INGOT);
return doesMultiOreStartWith(stack, INGOT);
}

public static boolean isPlate(ItemStack stack) {

return getOreName(stack).startsWith(PLATE);
return doesMultiOreStartWith(stack, PLATE);
}

public static boolean isCoin(ItemStack stack) {

return getOreName(stack).startsWith(COIN);
return doesMultiOreStartWith(stack, COIN);
}

public static boolean isNugget(ItemStack stack) {

return getOreName(stack).startsWith(NUGGET);
return doesMultiOreStartWith(stack, NUGGET);
}

public static boolean isLog(ItemStack stack) {

return getOreName(stack).startsWith(LOG);
return doesMultiOreStartWith(stack, LOG);
}

public static void registerWithHandlers(String oreName, ItemStack stack) {
Expand Down