IOreDictEntry
Link to ioredictentry
When the IOreDict is the lexicon, the IOreDictEntries are the lexicon's entries.
They consist of a name (OreDictionary name) and an explanation (all matching items).
Dieses Paket importieren
Link to dieses-paket-importieren
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.IOreDictEntry;
Retrieving such an Object.
Link to retrieving-such-an-object
There are multiple ways of getting an IOreDictEntry Object: If you refer to an oreDict that does not yet exist, it will be created.
- Using the IOreDict class.
- Using the ore Bracket Handler.
- Using an IItemDefinition's
ores
getter.
ZenGetter
Link to zengetter
You can use these getters to retrieve some information on the oredict:
name | Beschreibung | Rückgabetyp |
---|---|---|
name name | Beschreibung Returns the oreDict's name | Rückgabetyp string |
name empty | Beschreibung Returns if the oreDict is empty | Rückgabetyp bool |
name firstItem | Beschreibung Returns the first of the oreDict's items | Rückgabetyp IItemStack |
ZenMethods
Link to zenmethods
You can use these methos on an IOreDictEntry Object:
Add/Remove items
Link to addremove-items
ZenScript Copyval oreDictEnt = <ore:ingotIron>;
//oreDictEnt.add(IItemStack... item_items);
oreDictEnt.add(<minecraft:grass>);
oreDictEnt.add(<minecraft:iron_ore>, <minecraft:dirt>);
//oreDictEnt.addItems(IItemStack[] items);
oreDictEnt.addItems([<minecraft:redstone>, <minecraft:gold_ore>]);
//oreDictEnt.addAll(IOreDictEntry otherEntry);
oreDictEnt.addAll(<ore:ingotGold>);
//oreDictEnt.remove(IItemStack... item_items);
oreDictEnt.remove(<minecraft:grass>);
oreDictEnt.remove(<minecraft:iron_ore>, <minecraft:dirt>);
//oreDictEnt.removeItems(IItemStack[] items);
oreDictEnt.removeItems([<minecraft:redstone>, <minecraft:gold_ore>]);
Check if an IOreDictEntry contains an item
Link to check-if-an-ioredictentry-contains-an-item
You can check if an IOreDictEntry contains an item using either the in
or has
keywords:
ZenScript Copyval oreDictEnt = <ore:ingotIron>;
//While using in is possible
if(oreDictEnt in <minecraft:iron_ingot>){
print("Iron is in the oreDict!");
}
//many prefer using has as it might make more sense grammar-wise
if(oreDictEnt has <minecraft:iron_ingot>){
print("Iron still is in the oreDict!");
}
Mirror an IOreDictEntry
Link to mirror-an-ioredictentry
Mirroring an IOreDictEntry means that all items in the other oreDictEntry will be replaced by the items in the oreDictEntry the method was executed on:
ZenScript Copy//make iron and copper equivalent
val iron = <ore:ingotIron>;
val copper = <ore:ingotCopper>;
//adds all entries from copper into iron so that the iron oreDictEntry contains both the iron and copper ingots
iron.addAll(copper);
//mirrors iron to copper, so all items in copper will be replaced by all the ones in iron.
//In this case that means by all iron and copper ingots, so copper and iron will have the same entries
copper.mirror(iron);
IIngredient implementation
Link to iingredient-implementation
IOreDictEntry extends IIngredient. This means that all methods available to IIngredient are also available to IOreDictEntries. It also means that you can put IOreDictEntries into IIngredient Arrays (such as the ones in crafting recipe methods).
Iterating through an oreDictEntry's items
Link to iterating-through-an-oredictentrys-items
ZenScript Copyval iron = <ore:ingotIron>;
for item in iron.items{
recipe.remove(item);
}