IOreDict
Link to ioredict
The Forge OreDictionary is like a huge Lexicon in the way that it features many different entries and each entry is described by fitting Items.
When talking about ore Dictionarys, people mostly refer to IOreDictEntries not the whole ore Dictionary.
导入相关包
Link to 导入相关包
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import.
import crafttweaker.oredict.IOreDict;
How to retrieve the oreDictionary
Link to how-to-retrieve-the-oredictionary
You can retrieve the OreDictionary using the oreDict
global keyword.
使用方式
Link to 使用方式
So what can be done with the oreDict?
Getting an
Link to getting-an-ioredictentry
You can use either of the three ways below to refer to an OreDictEntry, no matter if it already exists or not.
If the oreDictEntry does not yet exist, it will be created.
ZenScript CopyoreDict.ingotIron;
oreDict.get("ingotIron");
oreDict["ingotIron"];
Iterating through all registered
Link to iterating-through-all-registered-ioredictentries
ZenScript Copy//the entries member is for retrieving all registered oreDictionary entries!
val allEntries = oreDict.entries;
for oreDictEntry in allEntries{
print(oreDictEntry.name);
}
//Alternatively, you can just iterate through oreDict
for entry in oreDict {
print(entry.name);
}
How to check if an ore Dictionary entry exists
Link to how-to-check-if-an-ore-dictionary-entry-exists
You can use the in
or has
operator to check if an IOreDictEntry already exists:
ZenScript Copyif (oreDict in "ingotIron") {
print("ingotIron exists!");
}
if (oreDict has "ingotIron") {
print("ingotIron exists!");
}
//Alternatively use the contains function:
if(oreDict.contains "ingotIron") {
print("ingotIron exists!");
}