Messy attempt at a blacklist to avoid the possibility of assigning emc values to unavailable ids

This commit is contained in:
pahimar 2013-05-23 00:00:31 -04:00
parent 156c146220
commit ea1c022498
3 changed files with 63 additions and 16 deletions

View file

@ -30,7 +30,6 @@ import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
import com.pahimar.ee3.lib.Reference; import com.pahimar.ee3.lib.Reference;
import com.pahimar.ee3.lib.Strings; import com.pahimar.ee3.lib.Strings;
import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.PacketHandler;
import com.pahimar.ee3.recipe.RecipesTransmutationStone;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.FingerprintWarning; import cpw.mods.fml.common.Mod.FingerprintWarning;

View file

@ -52,19 +52,20 @@ public class TransmutationHelper {
if (currentBlock != null) { if (currentBlock != null) {
meta = currentBlock.damageDropped(meta); meta = currentBlock.damageDropped(meta);
}
currentBlockStack = new ItemStack(id, 1, meta); currentBlockStack = new ItemStack(id, 1, meta);
if (previousBlockStack == null) { if (previousBlockStack == null) {
previousBlockStack = currentBlockStack;
targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage());
}
else {
if (!EquivalencyHandler.instance().areEquivalent(TransmutationHelper.previousBlockStack, currentBlockStack)) {
previousBlockStack = currentBlockStack; previousBlockStack = currentBlockStack;
targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage()); targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage());
} }
else {
if (!EquivalencyHandler.instance().areEquivalent(TransmutationHelper.previousBlockStack, currentBlockStack)) {
previousBlockStack = currentBlockStack;
targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage());
}
}
} }
} }

View file

@ -1,15 +1,29 @@
package com.pahimar.ee3.emc; package com.pahimar.ee3.emc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import com.pahimar.ee3.core.util.LogHelper;
import com.pahimar.ee3.core.util.RecipeHelper;
import com.pahimar.ee3.core.util.StringUtil;
public class DynEMC { public class DynEMC {
private static final DynEMC dynEMC = new DynEMC(); private static final DynEMC dynEMC = new DynEMC();
private static final ArrayList<ItemStack> discoveredItemStacks = new ArrayList<ItemStack>(); private static final ArrayList<Integer> idBlackList = new ArrayList<Integer>();
private static final ArrayList<ItemStack> itemStackBlackList = new ArrayList<ItemStack>();
private static final HashMap<List<Integer>, ItemStack> discoveredItems = new HashMap<List<Integer>, ItemStack>();
private DynEMC() { private DynEMC() {
@ -19,13 +33,24 @@ public class DynEMC {
return dynEMC; return dynEMC;
} }
public void populateBlackList() {
// List of ids to blacklist, more to clean up here
int[] blackints = {7,8,9,10,11,14,15,16,21,26,34,36,43,51,52,55,56,59,60,62,63,64,68,71,73,74,75,83,90,92,93,94,95,97,104,105,115,117,118,119,120,124,125,127,129,132,137,140,141,142,144,149,150,153};
for (int i : blackints) {
idBlackList.add(i);
}
}
public void init() { public void init() {
populateBlackList();
ArrayList<ItemStack> subItems = new ArrayList<ItemStack>(); ArrayList<ItemStack> subItems = new ArrayList<ItemStack>();
for (int i = 0; i < Item.itemsList.length; i++) { for (int i = 0; i < Item.itemsList.length; i++) {
if (Item.itemsList[i] != null) { if ((Item.itemsList[i] != null) && (!idBlackList.contains(i))) {
if (Item.itemsList[i].getHasSubtypes()) { if (Item.itemsList[i].getHasSubtypes()) {
subItems.clear(); subItems.clear();
@ -33,8 +58,9 @@ public class DynEMC {
for (ItemStack itemStack : subItems) { for (ItemStack itemStack : subItems) {
if (itemStack != null) { if (itemStack != null) {
if (!discoveredItemStacks.contains(itemStack)) { List idMeta = Arrays.asList(itemStack.itemID, itemStack.getItemDamage());
discoveredItemStacks.add(itemStack); if (!discoveredItems.containsKey(idMeta)) {
discoveredItems.put(idMeta, itemStack);
} }
} }
} }
@ -42,12 +68,33 @@ public class DynEMC {
else { else {
ItemStack itemStack = new ItemStack(Item.itemsList[i]); ItemStack itemStack = new ItemStack(Item.itemsList[i]);
List idMeta = Arrays.asList(itemStack.itemID, itemStack.getItemDamage());
if (!discoveredItemStacks.contains(itemStack)) { if (!discoveredItems.containsKey(idMeta)) {
discoveredItemStacks.add(itemStack); discoveredItems.put(idMeta, itemStack);
} }
} }
} }
} }
for (ItemStack itemStack : itemStackBlackList) {
List idMeta = Arrays.asList(itemStack.itemID, itemStack.getItemDamage());
if (discoveredItems.containsKey(idMeta)) {
discoveredItems.remove(idMeta);
}
}
for (ItemStack itemStack : discoveredItems.values()) {
ArrayList<IRecipe> recipes = RecipeHelper.getReverseRecipes(itemStack);
if (recipes.size() > 0) {
for (IRecipe recipe : recipes) {
//LogHelper.log(Level.INFO, StringUtil.toString(itemStack) + " <-- " + RecipeHelper.getRecipeInputs(recipe));
}
}
else {
LogHelper.log(Level.INFO, StringUtil.toString(itemStack));
}
}
} }
} }