diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
index e59aecb6..22254f55 100644
--- a/ReleaseNotes.txt
+++ b/ReleaseNotes.txt
@@ -8,6 +8,8 @@ New
- 3 tiers
- Configurable level / io display
- Existing cap banks unchanged but are no longer craftable. Convert them to new version by placing in the crafting grid (power level is maintained)
+- Added preferences for Ore Dictionary outputs for the SAG Mill and Alloy Furnace.
+ - Defaults to Thermal Foundation when available, see OreDictionaryPreferences_Core.xml
- Added config option to add Ore Dictionary entries and registered names to tooltips (default is off)
Changes
diff --git a/resources/assets/enderio/config/OreDictionaryPreferences_Core.xml b/resources/assets/enderio/config/OreDictionaryPreferences_Core.xml
index 733285c7..f3026c89 100644
--- a/resources/assets/enderio/config/OreDictionaryPreferences_Core.xml
+++ b/resources/assets/enderio/config/OreDictionaryPreferences_Core.xml
@@ -37,9 +37,9 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt
-
+
-
+
@@ -71,6 +71,40 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/crazypants/enderio/machine/alloy/VanillaSmeltingRecipe.java b/src/main/java/crazypants/enderio/machine/alloy/VanillaSmeltingRecipe.java
index 9264e36a..b57063a1 100644
--- a/src/main/java/crazypants/enderio/machine/alloy/VanillaSmeltingRecipe.java
+++ b/src/main/java/crazypants/enderio/machine/alloy/VanillaSmeltingRecipe.java
@@ -17,6 +17,7 @@ import crazypants.enderio.machine.recipe.IRecipe;
import crazypants.enderio.machine.recipe.Recipe;
import crazypants.enderio.machine.recipe.RecipeInput;
import crazypants.enderio.machine.recipe.RecipeOutput;
+import crazypants.enderio.material.OreDictionaryPreferences;
public class VanillaSmeltingRecipe implements IMachineRecipe {
@@ -103,6 +104,7 @@ public class VanillaSmeltingRecipe implements IMachineRecipe {
if(output == null) {
return new ResultStack[0];
}
+ output = OreDictionaryPreferences.instance.getPreferred(output);
ItemStack result = output.copy();
result.stackSize = result.stackSize * getNumInputs(inputs);
return new ResultStack[] { new ResultStack(result) };
@@ -165,7 +167,9 @@ public class VanillaSmeltingRecipe implements IMachineRecipe {
List result = new ArrayList();
Map metaList = FurnaceRecipes.smelting().getSmeltingList();
for (Entry entry : metaList.entrySet()) {
- result.add(new Recipe(new RecipeInput(entry.getKey()), RF_PER_ITEM, new RecipeOutput(entry.getValue())));
+ ItemStack output = entry.getValue();
+ output = OreDictionaryPreferences.instance.getPreferred(output);
+ result.add(new Recipe(new RecipeInput(entry.getKey()), RF_PER_ITEM, new RecipeOutput(output)));
}
return result;
}
diff --git a/src/main/java/crazypants/enderio/material/OreDictionaryPreferences.java b/src/main/java/crazypants/enderio/material/OreDictionaryPreferences.java
index 2346f8a2..6f952586 100644
--- a/src/main/java/crazypants/enderio/material/OreDictionaryPreferences.java
+++ b/src/main/java/crazypants/enderio/material/OreDictionaryPreferences.java
@@ -4,9 +4,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import crazypants.util.OreDictionaryHelper;
-
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
+import crazypants.util.OreDictionaryHelper;
public final class OreDictionaryPreferences {
@@ -17,6 +18,7 @@ public final class OreDictionaryPreferences {
}
private Map preferences = new HashMap();
+ private Map stackCache = new HashMap();
public void setPreference(String oreDictName, ItemStack stack) {
if(oreDictName == null || stack == null) {
@@ -39,4 +41,77 @@ public final class OreDictionaryPreferences {
return result;
}
+ public ItemStack getPreferred(ItemStack stack) {
+ if(stack == null) {
+ return null;
+ }
+ StackKey key = new StackKey(stack);
+ if(stackCache.containsKey(key)) {
+ return stackCache.get(key);
+ }
+ ItemStack result = null;
+ int[] ids = OreDictionary.getOreIDs(stack);
+ if(ids != null) {
+ for (int i = 0; i < ids.length && result == null; i++) {
+ String oreDict = OreDictionary.getOreName(ids[i]);
+ if(preferences.containsKey(oreDict)) {
+ result = preferences.get(oreDict);
+ }
+ }
+ }
+
+ if(result == null) {
+ result = stack;
+ }
+ stackCache.put(key, result);
+ return stack;
+
+ }
+
+ private static class StackKey {
+
+ Item item;
+ int damage;
+
+ StackKey(ItemStack stack) {
+ item = stack.getItem();
+ damage = stack.getItemDamage();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + damage;
+ result = prime * result + ((item == null) ? 0 : item.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(this == obj) {
+ return true;
+ }
+ if(obj == null) {
+ return false;
+ }
+ if(getClass() != obj.getClass()) {
+ return false;
+ }
+ StackKey other = (StackKey) obj;
+ if(damage != other.damage) {
+ return false;
+ }
+ if(item == null) {
+ if(other.item != null) {
+ return false;
+ }
+ } else if(!item.equals(other.item)) {
+ return false;
+ }
+ return true;
+ }
+
+ }
+
}