Grinder recipes fixes and auto-generation for ores, gems and ingots through ore dictionary
This commit is contained in:
parent
a5a9460707
commit
5af14bbf01
2 changed files with 87 additions and 106 deletions
|
@ -6,6 +6,8 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OreDictUtils
|
||||
{
|
||||
|
||||
|
@ -19,6 +21,44 @@ public class OreDictUtils
|
|||
return Character.toUpperCase(string.charAt(0)) + string.substring(1);
|
||||
}
|
||||
|
||||
public static String joinDictName(String prefix, String name) {
|
||||
return prefix + toFirstUpper(name);
|
||||
}
|
||||
|
||||
public static String[] getDictData(String prefixed) {
|
||||
StringBuilder prefixBuilder = new StringBuilder();
|
||||
StringBuilder nameBuilder = new StringBuilder();
|
||||
boolean prefixFinished = false;
|
||||
for(int i = 0; i < prefixed.length(); i++) {
|
||||
char charAt = prefixed.charAt(i);
|
||||
if(!prefixFinished) {
|
||||
if(Character.isUpperCase(charAt)) {
|
||||
nameBuilder.append(Character.toLowerCase(charAt));
|
||||
prefixFinished = true;
|
||||
} else prefixBuilder.append(charAt);
|
||||
} else nameBuilder.append(charAt);
|
||||
}
|
||||
return new String[] {
|
||||
prefixBuilder.toString(),
|
||||
nameBuilder.toString()
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean isDictPrefixed(String name, String... prefixes) {
|
||||
for(String prefix : prefixes)
|
||||
if(name.startsWith(prefix))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack getDictOreOrNull(String name, int amount) {
|
||||
List<ItemStack> ores = OreDictionary.getOres(name);
|
||||
if(ores.isEmpty()) return null;
|
||||
ItemStack ore = ores.get(0);
|
||||
ore.stackSize = amount;
|
||||
return ore;
|
||||
}
|
||||
|
||||
public static boolean isOre(Block block, String oreName)
|
||||
{
|
||||
return isOre(new ItemStack(Item.getItemFromBlock(block)), oreName);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue