diff --git a/ee3_common/com/pahimar/ee3/core/util/EnergyStack.java b/ee3_common/com/pahimar/ee3/core/util/EnergyStack.java index 04481a01..dc1c46ff 100644 --- a/ee3_common/com/pahimar/ee3/core/util/EnergyStack.java +++ b/ee3_common/com/pahimar/ee3/core/util/EnergyStack.java @@ -1,48 +1,48 @@ package com.pahimar.ee3.core.util; - public class EnergyStack { - + public static final String VANILLA_SMELTING_ENERGY_NAME = "vanillaFuelValueUnits"; public static final int VANILLA_SMELTING_ENERGY_THRESHOLD = 200; - + public String energyName; public int stackSize; - + public EnergyStack(String energyName, int stackSize) { - + this.energyName = energyName; this.stackSize = stackSize; } - + public EnergyStack() { - + this("", 0); } - + public EnergyStack(String energyName) { - + this(energyName, 1); } - + @Override public String toString() { + StringBuilder stringBuilder = new StringBuilder(); - + stringBuilder.append(String.format("%dxenergyStack.%s", stackSize, energyName)); - + return stringBuilder.toString(); } - + @Override public boolean equals(Object object) { - + if (!(object instanceof EnergyStack)) { return false; } - + EnergyStack energyStack = (EnergyStack) object; - + return (this.stackSize == energyStack.stackSize && this.energyName.equalsIgnoreCase(energyStack.energyName)); } diff --git a/ee3_common/com/pahimar/ee3/core/util/ItemUtil.java b/ee3_common/com/pahimar/ee3/core/util/ItemUtil.java index 83bc3f2b..467cffa3 100644 --- a/ee3_common/com/pahimar/ee3/core/util/ItemUtil.java +++ b/ee3_common/com/pahimar/ee3/core/util/ItemUtil.java @@ -32,38 +32,38 @@ public class ItemUtil { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(String.format("itemID: %d, metaData: %d, stackSize: %d, ", itemStack.itemID, itemStack.getItemDamage(), itemStack.stackSize)); - + if (itemStack.hasTagCompound()) { stringBuilder.append(String.format("nbtTagCompound: %s, ", itemStack.getTagCompound().toString())); } - + stringBuilder.append(String.format("itemName: %s, className: %s ", itemStack.getItemName(), itemStack.getItem().getClass().toString())); return stringBuilder.toString(); } /** - * Compares two ItemStacks for equality, testing itemID, metaData, stackSize, and their NBTTagCompounds (if they are present) + * Compares two ItemStacks for equality, testing itemID, metaData, + * stackSize, and their NBTTagCompounds (if they are present) * * @param first - * The first ItemStack being tested for equality + * The first ItemStack being tested for equality * @param second - * The second ItemStack being tested for equality - * @return - * true if the two ItemStacks are equivalent, false otherwise + * The second ItemStack being tested for equality + * @return true if the two ItemStacks are equivalent, false otherwise */ public static boolean compare(ItemStack first, ItemStack second) { - + // Check to see if either argument is null if ((first != null) && (second != null)) { // Check the item IDs if (first.itemID == second.itemID) { // Check the meta data - + if ((first.getItemDamage() == OreDictionary.WILDCARD_VALUE) || (second.getItemDamage() == OreDictionary.WILDCARD_VALUE)) { //return true; } - + if (first.getItemDamage() == second.getItemDamage()) { // Check the stack size if (first.stackSize == second.stackSize) { diff --git a/ee3_common/com/pahimar/ee3/core/util/LogHelper.java b/ee3_common/com/pahimar/ee3/core/util/LogHelper.java index 5bfe0ece..7cb52574 100644 --- a/ee3_common/com/pahimar/ee3/core/util/LogHelper.java +++ b/ee3_common/com/pahimar/ee3/core/util/LogHelper.java @@ -31,42 +31,42 @@ public class LogHelper { } public static void severe(String message) { - + log(Level.SEVERE, message); } - + public static void debug(String message) { - + log(Level.WARNING, "[DEBUG] " + message); } - + public static void warning(String message) { - + log(Level.WARNING, message); } - + public static void info(String message) { - + log(Level.INFO, message); } - + public static void config(String message) { - + log(Level.CONFIG, message); } - + public static void fine(String message) { - + log(Level.FINE, message); } - + public static void finer(String message) { - + log(Level.FINER, message); } - + public static void finest(String message) { - + log(Level.FINEST, message); } } diff --git a/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java b/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java index 8d1fae07..1e38f935 100644 --- a/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java +++ b/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java @@ -30,39 +30,41 @@ import cpw.mods.fml.common.registry.GameRegistry; public class RecipeHelper { /** - * Discovers all instances of ItemStacks with wild card meta values in the vanilla Crafting Manager + * Discovers all instances of ItemStacks with wild card meta values in the + * vanilla Crafting Manager * - * @return A list of CustomWrappedStacks that contains all wild card meta ItemStacks in the vanilla Crafting Manager + * @return A list of CustomWrappedStacks that contains all wild card meta + * ItemStacks in the vanilla Crafting Manager */ public static ArrayList populateWildCards() { - + ArrayList wildCards = new ArrayList(); - + for (Object recipe : CraftingManager.getInstance().getRecipeList()) { - + if (recipe instanceof IRecipe) { - + if (((IRecipe) recipe).getRecipeOutput() instanceof ItemStack) { - + CustomWrappedStack recipeOutput = new CustomWrappedStack(((IRecipe) recipe).getRecipeOutput()); ArrayList recipeInputs = RecipeHelper.getRecipeInputs((IRecipe) recipe); ItemStack itemStack = null; - + if (recipeOutput.getWrappedStack() instanceof ItemStack) { - + itemStack = (ItemStack) recipeOutput.getWrappedStack(); - + if (itemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE && !wildCards.contains(recipeOutput)) { wildCards.add(recipeOutput); } } - + for (CustomWrappedStack inputStack : recipeInputs) { - + if (inputStack.getWrappedStack() instanceof ItemStack) { - + itemStack = (ItemStack) inputStack.getWrappedStack(); - + if (itemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE && !wildCards.contains(inputStack)) { wildCards.add(inputStack); } @@ -71,10 +73,10 @@ public class RecipeHelper { } } } - + return wildCards; } - + /** * Returns a list of elements that constitute the input in a crafting recipe * @@ -83,11 +85,9 @@ public class RecipeHelper { * @return List of elements that constitute the input of the given IRecipe. * Could be an ItemStack or an Arraylist */ - @SuppressWarnings({ "rawtypes" }) public static ArrayList getRecipeInputs(IRecipe recipe) { ArrayList recipeInputs = new ArrayList(); - OreStack oreStack = null; if (recipe instanceof ShapedRecipes) { @@ -117,20 +117,7 @@ public class RecipeHelper { /* * If the element is a list, then it is an OreStack */ - if (shapedOreRecipe.getInput()[i] instanceof ArrayList) { - ArrayList shapedOreRecipeList = (ArrayList) shapedOreRecipe.getInput()[i]; - - if (!shapedOreRecipeList.isEmpty()) { - - oreStack = new OreStack((ItemStack) shapedOreRecipeList.get(0)); - - recipeInputs.add(new CustomWrappedStack(oreStack)); - } - } - /* - * Else it is possibly an ItemStack - */ - else if (shapedOreRecipe.getInput()[i] instanceof ItemStack) { + if (shapedOreRecipe.getInput()[i] instanceof ArrayList || shapedOreRecipe.getInput()[i] instanceof ItemStack) { recipeInputs.add(new CustomWrappedStack(shapedOreRecipe.getInput()[i])); } } @@ -140,17 +127,7 @@ public class RecipeHelper { ShapelessOreRecipe shapelessOreRecipe = (ShapelessOreRecipe) recipe; for (Object object : shapelessOreRecipe.getInput()) { - if (object instanceof ArrayList) { - ArrayList shapelessOreRecipeList = (ArrayList) object; - - if (!shapelessOreRecipeList.isEmpty()) { - - oreStack = new OreStack((ItemStack) shapelessOreRecipeList.get(0)); - - recipeInputs.add(new CustomWrappedStack(oreStack)); - } - } - else if (object instanceof ItemStack) { + if (object instanceof ArrayList || object instanceof ItemStack) { recipeInputs.add(new CustomWrappedStack(object)); } } @@ -158,41 +135,41 @@ public class RecipeHelper { return recipeInputs; } - + public static ArrayList getCollatedRecipeInputs(IRecipe recipe) { - + return ItemUtil.collateStacks(getRecipeInputs(recipe)); } - + public static ArrayList getReverseRecipes(CustomWrappedStack wrappedStack) { - + ArrayList reverseRecipeList = new ArrayList(); - + @SuppressWarnings("unchecked") ArrayList recipeList = new ArrayList(CraftingManager.getInstance().getRecipeList()); - + for (IRecipe recipe : recipeList) { - + if (recipe.getRecipeOutput() != null) { - + if (wrappedStack.getWrappedStack() instanceof ItemStack) { - + if (ItemUtil.compare((ItemStack) wrappedStack.getWrappedStack(), recipe.getRecipeOutput())) { reverseRecipeList.add(recipe); } } else if (wrappedStack.getWrappedStack() instanceof OreStack) { - + if (OreDictionary.getOreID(recipe.getRecipeOutput()) != -1) { // TODO Generalize comparison of OreStacks and OreStacks|ItemStacks - if (OreDictionary.getOreID(((OreStack)wrappedStack.getWrappedStack()).oreName) == OreDictionary.getOreID(recipe.getRecipeOutput())) { + if (OreDictionary.getOreID(((OreStack) wrappedStack.getWrappedStack()).oreName) == OreDictionary.getOreID(recipe.getRecipeOutput())) { reverseRecipeList.add(recipe); } } } } } - + return reverseRecipeList; } diff --git a/ee3_common/com/pahimar/ee3/core/util/TransmutationHelper.java b/ee3_common/com/pahimar/ee3/core/util/TransmutationHelper.java index 02323209..a62d2584 100644 --- a/ee3_common/com/pahimar/ee3/core/util/TransmutationHelper.java +++ b/ee3_common/com/pahimar/ee3/core/util/TransmutationHelper.java @@ -52,10 +52,9 @@ public class TransmutationHelper { if (currentBlock != null) { meta = currentBlock.damageDropped(meta); - currentBlockStack = new ItemStack(id, 1, meta); - + if (previousBlockStack == null) { previousBlockStack = currentBlockStack; targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage()); diff --git a/ee3_common/com/pahimar/ee3/emc/DynEMC.java b/ee3_common/com/pahimar/ee3/emc/DynEMC.java index b1db557f..feed6e3a 100644 --- a/ee3_common/com/pahimar/ee3/emc/DynEMC.java +++ b/ee3_common/com/pahimar/ee3/emc/DynEMC.java @@ -12,6 +12,7 @@ import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.oredict.OreDictionary; +import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.pahimar.ee3.core.util.LogHelper; import com.pahimar.ee3.core.util.OreStack; @@ -22,6 +23,7 @@ import com.pahimar.ee3.item.CustomWrappedStack; import com.pahimar.ee3.item.crafting.RecipeRegistry; import com.pahimar.ee3.item.crafting.RecipesPotions; import com.pahimar.ee3.item.crafting.RecipesSmelting; +import com.pahimar.ee3.item.crafting.RecipesVanilla; public class DynEMC { @@ -50,47 +52,39 @@ public class DynEMC { private void init() { RecipeRegistry recipeManager = RecipeRegistry.getInstance(); - - Set keySet = null; - Iterator keySetIter = null; - CustomWrappedStack key = null; - - /* Add Potions */ - Multimap> potionRecipes = RecipesPotions.getPotionRecipes(); - keySet = potionRecipes.keySet(); - keySetIter = keySet.iterator(); - key = null; - - while (keySetIter.hasNext()) { - key = keySetIter.next(); + Multimap> recipes = HashMultimap.create(); + Set recipeKeySet = null; + Iterator recipeKeySetIterator = null; + CustomWrappedStack recipeOutput = null; - for (List potionInputs : potionRecipes.get(key)) { - recipeManager.addRecipe(key, potionInputs); + // Add potion recipes + recipes.putAll(RecipesPotions.getPotionRecipes()); + + // Add smelting recipes in the vanilla smelting manager + recipes.putAll(RecipesSmelting.getSmeltingRecipes()); + + // Add recipes in the vanilla crafting manager + recipes.putAll(RecipesVanilla.getVanillaRecipes()); + + // Add recipes gathered via IMC + // TODO Gather IMC recipes + + // Add items that have no recipe + + // Iterate through every recipe in the map, and add them to the registry + recipeKeySet = recipes.keySet(); + recipeKeySetIterator = recipeKeySet.iterator(); + recipeOutput = null; + + while (recipeKeySetIterator.hasNext()) { + recipeOutput = recipeKeySetIterator.next(); + + for (List recipeInputs : recipes.get(recipeOutput)) { + recipeManager.addRecipe(recipeOutput, recipeInputs); } } - - /* Add Smelting */ - Multimap> smeltingRecipes = RecipesSmelting.getSmeltingRecipes(); - keySet = smeltingRecipes.keySet(); - keySetIter = keySet.iterator(); - key = null; - - while (keySetIter.hasNext()) { - key = keySetIter.next(); - - for (List smeltingInputs : smeltingRecipes.get(key)) { - recipeManager.addRecipe(key, smeltingInputs); - } - } - - /* Add vanilla crafting */ - - /* Add recipes sent via IMC */ - - /* Add all other items that don't have some method of crafting */ - LogHelper.debug(recipeManager.toString()); } diff --git a/ee3_common/com/pahimar/ee3/emc/EmcBlackList.java b/ee3_common/com/pahimar/ee3/emc/EmcBlackList.java index f041a4d5..df6dde22 100644 --- a/ee3_common/com/pahimar/ee3/emc/EmcBlackList.java +++ b/ee3_common/com/pahimar/ee3/emc/EmcBlackList.java @@ -23,16 +23,16 @@ public class EmcBlackList { public static EmcBlackList getInstance() { if (emcBlackList == null) { - + emcBlackList = new EmcBlackList(); emcBlackList.init(); } - + return emcBlackList; } - + public List getBlackListStacks() { - + return stackBlackList; } @@ -54,18 +54,17 @@ public class EmcBlackList { this.add(new ItemStack(block.blockID, 1, OreDictionary.WILDCARD_VALUE)); } - + public void add(int id, int meta) { - + this.add(new ItemStack(id, 1, meta)); } - + public void add(int id) { - + this.add(id, OreDictionary.WILDCARD_VALUE); } - - + public boolean contains(ItemStack itemStack) { if (itemStack != null) { @@ -84,14 +83,14 @@ public class EmcBlackList { return this.contains(new ItemStack(block.blockID, 1, OreDictionary.WILDCARD_VALUE)); } - + public boolean contains(int id, int meta) { - + return this.contains(new ItemStack(id, 1, meta)); } - + public boolean contains(int id) { - + return this.contains(id, OreDictionary.WILDCARD_VALUE); } @@ -113,19 +112,19 @@ public class EmcBlackList { this.remove(new ItemStack(block.blockID, 1, OreDictionary.WILDCARD_VALUE)); } - + public void remove(int id, int meta) { - + this.remove(new ItemStack(id, 1, meta)); } - + public void remove(int id) { - + this.remove(id, OreDictionary.WILDCARD_VALUE); } - + private void init() { - + add(Block.bed); add(Block.pistonExtension); add(Block.pistonMoving); diff --git a/ee3_common/com/pahimar/ee3/emc/EmcComponent.java b/ee3_common/com/pahimar/ee3/emc/EmcComponent.java index 0f193d48..13c6fc9b 100644 --- a/ee3_common/com/pahimar/ee3/emc/EmcComponent.java +++ b/ee3_common/com/pahimar/ee3/emc/EmcComponent.java @@ -1,47 +1,46 @@ package com.pahimar.ee3.emc; - public class EmcComponent { - + private final EmcType emcType; private final float percentage; - + public EmcComponent(EmcType emcType, float percentage) { - + this.emcType = emcType; this.percentage = percentage; } - + public EmcType getEmcType() { - + return emcType; } - + public float getPercentage() { - + return percentage; } - + @Override public boolean equals(Object object) { - + if (!(object instanceof EmcComponent)) { - + return false; } - + EmcComponent emcBreakDown = (EmcComponent) object; - + return ((this.emcType == emcBreakDown.emcType) && (this.percentage == emcBreakDown.percentage)); } - + @Override public String toString() { - + StringBuilder stringBuilder = new StringBuilder(); - + stringBuilder.append(String.format("", emcType, (percentage * 100))); - + return stringBuilder.toString(); } } diff --git a/ee3_common/com/pahimar/ee3/emc/EmcType.java b/ee3_common/com/pahimar/ee3/emc/EmcType.java index 4ff92c2d..9630fe8c 100644 --- a/ee3_common/com/pahimar/ee3/emc/EmcType.java +++ b/ee3_common/com/pahimar/ee3/emc/EmcType.java @@ -1,6 +1,5 @@ package com.pahimar.ee3.emc; - public enum EmcType { CORPOREAL, KINETIC, TEMPORAL, ESSENTIA, AMORPHOUS, VOID, OMNI; } diff --git a/ee3_common/com/pahimar/ee3/emc/EmcValue.java b/ee3_common/com/pahimar/ee3/emc/EmcValue.java index 48b45153..204b328b 100644 --- a/ee3_common/com/pahimar/ee3/emc/EmcValue.java +++ b/ee3_common/com/pahimar/ee3/emc/EmcValue.java @@ -16,10 +16,11 @@ public class EmcValue { private float value, recoveryPercentage; private List emcComponents; - + public EmcValue() { - value = 0F;; + value = 0F; + ; recoveryPercentage = 1F; emcComponents = new ArrayList(); } @@ -37,9 +38,9 @@ public class EmcValue { this.recoveryPercentage = recoveryPercentage; emcComponents = new ArrayList(); } - + public EmcValue(float value, float recoveryPercentage, List emcComponents) { - + this.value = value; this.recoveryPercentage = recoveryPercentage; this.emcComponents = emcComponents; @@ -61,7 +62,7 @@ public class EmcValue { } public EmcComponent getComponent(EmcType emcType) { - + for (EmcComponent emcComponent : emcComponents) { if (emcComponent.getEmcType().equals(emcType)) { return emcComponent; @@ -70,15 +71,15 @@ public class EmcValue { return null; } - + public boolean containsEmcType(EmcType emcType) { - + for (EmcComponent emcComponent : emcComponents) { if (emcComponent.getEmcType().equals(emcType)) { return true; } } - + return false; } @@ -91,60 +92,60 @@ public class EmcValue { this.recoveryPercentage = recoveryPercentage; } - + public void addEmcComponent(EmcComponent emcComponent) { - + if (!containsEmcType(emcComponent.getEmcType())) { emcComponents.add(emcComponent); } } - + public void addEmcComponent(EmcType emcType, float percentage) { - + addEmcComponent(new EmcComponent(emcType, percentage)); } - + @Override public boolean equals(Object object) { - + if (!(object instanceof EmcValue)) { return false; } - + EmcValue emcValue = (EmcValue) object; - + if (value == emcValue.value) { if (recoveryPercentage == emcValue.recoveryPercentage) { return emcComponents.equals(emcValue.getComponents()); } } - + return false; } @Override public String toString() { - + StringBuilder stringBuilder = new StringBuilder(); - + stringBuilder.append(String.format("EMC Value: %s, Recovery Percentage: %s, ", value, (recoveryPercentage * 100))); - + for (EmcComponent emcComponent : emcComponents) { stringBuilder.append(String.format("%s ", emcComponent)); } - + return stringBuilder.toString(); } - + @Override public int hashCode() { - + int hashCode = 1; - + hashCode = 37 * hashCode + Float.floatToIntBits(value); hashCode = 37 * hashCode + Float.floatToIntBits(recoveryPercentage); hashCode = 37 * hashCode + emcComponents.hashCode(); - + return hashCode; } } diff --git a/ee3_common/com/pahimar/ee3/emc/EquivalencyGroup.java b/ee3_common/com/pahimar/ee3/emc/EquivalencyGroup.java index bb7e42e2..724988aa 100644 --- a/ee3_common/com/pahimar/ee3/emc/EquivalencyGroup.java +++ b/ee3_common/com/pahimar/ee3/emc/EquivalencyGroup.java @@ -15,11 +15,11 @@ public class EquivalencyGroup { equivalentItems = new ArrayList(); } - + public EquivalencyGroup(List equivalentItems) { - + this.equivalentItems = new ArrayList(); - + for (ItemStack itemStack : equivalentItems) { this.equivalentItems.add(new CustomWrappedStack(itemStack)); } @@ -51,9 +51,9 @@ public class EquivalencyGroup { equivalentItems.add(customWrappedStack); } } - + public void setEquivalentItems(List equivalentItems) { - + this.equivalentItems = equivalentItems; } @@ -90,7 +90,7 @@ public class EquivalencyGroup { public String toString() { StringBuilder stringBuilder = new StringBuilder(); - + stringBuilder.append("Equivalent Group Members: "); for (CustomWrappedStack customWrappedStack : equivalentItems) { stringBuilder.append(String.format("%s ", customWrappedStack)); diff --git a/ee3_common/com/pahimar/ee3/emc/graph/WeightedEdge.java b/ee3_common/com/pahimar/ee3/emc/graph/WeightedEdge.java index 9451c53d..9b7d97ed 100644 --- a/ee3_common/com/pahimar/ee3/emc/graph/WeightedEdge.java +++ b/ee3_common/com/pahimar/ee3/emc/graph/WeightedEdge.java @@ -30,26 +30,26 @@ public class WeightedEdge { this.target = target; } - + @Override public boolean equals(Object object) { - + if (!(object instanceof WeightedEdge)) { return false; } - + WeightedEdge edge = (WeightedEdge) object; - + return ((this.weight == edge.weight) && (target.equals(edge.target))); } - + @Override public String toString() { - + StringBuilder stringBuilder = new StringBuilder(); - + stringBuilder.append(String.format("Weight: %s, Target: %s ", weight, target)); - + return stringBuilder.toString(); } } diff --git a/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java b/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java index eebc1887..fe9cdaf7 100644 --- a/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java +++ b/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java @@ -19,7 +19,7 @@ import com.pahimar.ee3.lib.Strings; * */ public class ContainerAlchemicalBag extends Container { - + private final int BAG_INVENTORY_ROWS = 4; private final int BAG_INVENTORY_COLUMNS = 13; @@ -63,7 +63,7 @@ public class ContainerAlchemicalBag extends Container { } } } - + @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { diff --git a/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java b/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java index 923b56b9..8d410a94 100644 --- a/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java +++ b/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java @@ -57,42 +57,47 @@ public class ContainerAludel extends Container { Slot slot = (Slot) inventorySlots.get(slotIndex); if (slot != null && slot.getHasStack()) { - + ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); /** - * If we are shift-clicking an item out of the Aludel's container, attempt to put it in the first available slot in the - * player's inventory + * If we are shift-clicking an item out of the Aludel's container, + * attempt to put it in the first available slot in the player's + * inventory */ if (slotIndex < TileAludel.INVENTORY_SIZE) { - + if (!this.mergeItemStack(slotItemStack, TileAludel.INVENTORY_SIZE, inventorySlots.size(), false)) { return null; } } else { - + /** - * If the stack being shift-clicked into the Aludel's container is a fuel, first try to put it in the fuel slot. - * If it cannot be merged into the fuel slot, try to put it in the input slot. + * If the stack being shift-clicked into the Aludel's container + * is a fuel, first try to put it in the fuel slot. If it cannot + * be merged into the fuel slot, try to put it in the input + * slot. */ if (TileEntityFurnace.isItemFuel(slotItemStack)) { if (!this.mergeItemStack(slotItemStack, TileAludel.FUEL_INVENTORY_INDEX, TileAludel.INPUT_INVENTORY_INDEX, false)) { return null; } } - + /** - * If the stack being shift-clicked into the Aludel's container is a dust, first try to put it in the dust slot. - * If it cannot be merged into the dust slot, try to put it in the input slot. + * If the stack being shift-clicked into the Aludel's container + * is a dust, first try to put it in the dust slot. If it cannot + * be merged into the dust slot, try to put it in the input + * slot. */ else if (slotItemStack.getItem() instanceof ItemAlchemicalDust) { if (!this.mergeItemStack(slotItemStack, TileAludel.DUST_INVENTORY_INDEX, TileAludel.OUTPUT_INVENTORY_INDEX, false)) { return null; } } - + /** * Finally, attempt to put stack into the input slot */ diff --git a/ee3_common/com/pahimar/ee3/inventory/ContainerCalcinator.java b/ee3_common/com/pahimar/ee3/inventory/ContainerCalcinator.java index 35e22867..550c4b50 100644 --- a/ee3_common/com/pahimar/ee3/inventory/ContainerCalcinator.java +++ b/ee3_common/com/pahimar/ee3/inventory/ContainerCalcinator.java @@ -24,7 +24,7 @@ public class ContainerCalcinator extends Container { // Add the fuel slot to the container this.addSlotToContainer(new Slot(calcinator, TileCalcinator.FUEL_INVENTORY_INDEX, 56, 62)); - + // Add the input slot to the container this.addSlotToContainer(new Slot(calcinator, TileCalcinator.INPUT_INVENTORY_INDEX, 56, 17)); @@ -57,32 +57,35 @@ public class ContainerCalcinator extends Container { Slot slot = (Slot) inventorySlots.get(slotIndex); if (slot != null && slot.getHasStack()) { - + ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); /** - * If we are shift-clicking an item out of the Aludel's container, attempt to put it in the first available slot in the - * player's inventory + * If we are shift-clicking an item out of the Aludel's container, + * attempt to put it in the first available slot in the player's + * inventory */ if (slotIndex < TileCalcinator.INVENTORY_SIZE) { - + if (!this.mergeItemStack(slotItemStack, TileCalcinator.INVENTORY_SIZE, inventorySlots.size(), false)) { return null; } } else { - + /** - * If the stack being shift-clicked into the Aludel's container is a fuel, first try to put it in the fuel slot. - * If it cannot be merged into the fuel slot, try to put it in the input slot. + * If the stack being shift-clicked into the Aludel's container + * is a fuel, first try to put it in the fuel slot. If it cannot + * be merged into the fuel slot, try to put it in the input + * slot. */ if (TileEntityFurnace.isItemFuel(slotItemStack)) { if (!this.mergeItemStack(slotItemStack, TileCalcinator.FUEL_INVENTORY_INDEX, TileCalcinator.OUTPUT_INVENTORY_INDEX, false)) { return null; } } - + /** * Finally, attempt to put stack into the input slot */ diff --git a/ee3_common/com/pahimar/ee3/inventory/ContainerGlassBell.java b/ee3_common/com/pahimar/ee3/inventory/ContainerGlassBell.java index b36de8aa..603e2f2c 100644 --- a/ee3_common/com/pahimar/ee3/inventory/ContainerGlassBell.java +++ b/ee3_common/com/pahimar/ee3/inventory/ContainerGlassBell.java @@ -47,17 +47,16 @@ public class ContainerGlassBell extends Container { @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { - + ItemStack itemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); if (slotIndex < TileGlassBell.INVENTORY_SIZE) { - + if (!this.mergeItemStack(slotItemStack, 1, inventorySlots.size(), true)) { return null; } diff --git a/ee3_common/com/pahimar/ee3/item/CustomWrappedStack.java b/ee3_common/com/pahimar/ee3/item/CustomWrappedStack.java index 1e979a91..8bf3a384 100644 --- a/ee3_common/com/pahimar/ee3/item/CustomWrappedStack.java +++ b/ee3_common/com/pahimar/ee3/item/CustomWrappedStack.java @@ -1,11 +1,14 @@ package com.pahimar.ee3.item; +import java.util.ArrayList; + import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import com.pahimar.ee3.core.util.EnergyStack; import com.pahimar.ee3.core.util.ItemUtil; import com.pahimar.ee3.core.util.OreStack; +import com.pahimar.ee3.lib.Reference; public class CustomWrappedStack { @@ -37,11 +40,11 @@ public class CustomWrappedStack { * If the ItemStack does not exist in the OreDictionary, wrap it as * an ItemStack */ - if (OreDictionary.getOreID(itemStack) == -1) { - this.itemStack = itemStack; + if (OreDictionary.getOreID(itemStack) == Reference.ORE_DICTIONARY_NOT_FOUND) { + this.itemStack = itemStack.copy(); oreStack = null; energyStack = null; - stackSize = itemStack.stackSize; + stackSize = this.itemStack.stackSize; this.itemStack.stackSize = 1; } /* @@ -67,6 +70,29 @@ public class CustomWrappedStack { stackSize = oreStack.stackSize; oreStack.stackSize = 1; } + else if (object instanceof ArrayList) { + + itemStack = null; + + ArrayList objectList = (ArrayList) object; + + if (!objectList.isEmpty()) { + for (Object listElement : objectList) { + if (listElement instanceof ItemStack) { + ItemStack stack = (ItemStack) listElement; + + if (OreDictionary.getOreID(stack) != Reference.ORE_DICTIONARY_NOT_FOUND) { + oreStack = new OreStack(stack); + stackSize = oreStack.stackSize; + oreStack.stackSize = 1; + break; + } + } + } + } + + energyStack = null; + } /* * Or we are given an EnergyStack to wrap */ @@ -170,17 +196,9 @@ public class CustomWrappedStack { public String toString() { StringBuilder stringBuilder = new StringBuilder(); - + if (itemStack != null) { - - stringBuilder.append(String.format("itemID: %d, metaData: %d, stackSize: %d, ", itemStack.itemID, itemStack.getItemDamage(), stackSize)); - - if (itemStack.hasTagCompound()) { - stringBuilder.append(String.format("nbtTagCompound: %s, ", itemStack.getTagCompound().toString())); - } - - stringBuilder.append(String.format("itemName: %s, className: %s ", itemStack.getItemName(), itemStack.getItem().getClass().toString())); - + stringBuilder.append(String.format("%sxitemStack[%s:%s:%s:%s]", this.stackSize, itemStack.itemID, itemStack.getItemDamage(), itemStack.getItemName(), itemStack.getItem().getClass().getCanonicalName())); } else if (oreStack != null) { stringBuilder.append(String.format("%dxoreDictionary.%s", stackSize, oreStack.oreName)); diff --git a/ee3_common/com/pahimar/ee3/item/ItemMiniumStone.java b/ee3_common/com/pahimar/ee3/item/ItemMiniumStone.java index bcd64878..c0f8c20e 100644 --- a/ee3_common/com/pahimar/ee3/item/ItemMiniumStone.java +++ b/ee3_common/com/pahimar/ee3/item/ItemMiniumStone.java @@ -64,11 +64,11 @@ public class ItemMiniumStone extends ItemEE public ItemStack getContainerItemStack(ItemStack itemStack) { ItemStack copiedStack = itemStack.copy(); - + copiedStack.setItemDamage(copiedStack.getItemDamage() + 1); - + // Hacky hacky hack hack - copiedStack.stackSize = 1; + copiedStack.stackSize = 1; return copiedStack; } diff --git a/ee3_common/com/pahimar/ee3/item/ItemPhilosophersStone.java b/ee3_common/com/pahimar/ee3/item/ItemPhilosophersStone.java index ab3c0f8d..717cf1a4 100644 --- a/ee3_common/com/pahimar/ee3/item/ItemPhilosophersStone.java +++ b/ee3_common/com/pahimar/ee3/item/ItemPhilosophersStone.java @@ -71,9 +71,9 @@ public class ItemPhilosophersStone extends ItemEE public ItemStack getContainerItemStack(ItemStack itemStack) { ItemStack copiedStack = itemStack.copy(); - + copiedStack.setItemDamage(copiedStack.getItemDamage() + 1); - + // Hacky hacky hack hack copiedStack.stackSize = 1; diff --git a/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java b/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java index d99c2477..9a79dadb 100644 --- a/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java +++ b/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java @@ -139,36 +139,31 @@ public class RecipeRegistry { } } } - + if (!recipeMap.containsEntry(recipeOutput, collatedStacks)) { recipeMap.put(recipeOutput, collatedStacks); } } - + public int size() { - + return recipeMap.size(); } - + @Override public String toString() { - + StringBuilder stringBuilder = new StringBuilder(); - + for (CustomWrappedStack key : recipeMap.keySet()) { - Iterator> recipeIterator = recipeMap.get(key).iterator(); - - while (recipeIterator.hasNext()) { - List values = recipeIterator.next(); - stringBuilder.append(String.format("Recipe Output: %s, Recipe Input: %s", key.toString(), values.toString())); - - if (recipeIterator.hasNext()) { - stringBuilder.append("\n"); - } + Collection> recipeMappings = recipeMap.get(key); + + for (List recipeList : recipeMappings) { + stringBuilder.append(String.format("Recipe Output: %s, Recipe Input: %s\n", key.toString(), recipeList.toString())); } } - + return stringBuilder.toString(); } } diff --git a/ee3_common/com/pahimar/ee3/item/crafting/RecipesVanilla.java b/ee3_common/com/pahimar/ee3/item/crafting/RecipesVanilla.java index 44a18b6f..ea9acf32 100644 --- a/ee3_common/com/pahimar/ee3/item/crafting/RecipesVanilla.java +++ b/ee3_common/com/pahimar/ee3/item/crafting/RecipesVanilla.java @@ -3,8 +3,13 @@ package com.pahimar.ee3.item.crafting; import java.util.ArrayList; import java.util.List; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; + import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; +import com.pahimar.ee3.core.util.RecipeHelper; import com.pahimar.ee3.item.CustomWrappedStack; public class RecipesVanilla { @@ -25,9 +30,19 @@ public class RecipesVanilla { private static void init() { vanillaRecipes = HashMultimap.create(); - } - private static void discoverItems() { + for (Object recipeObject : CraftingManager.getInstance().getRecipeList()) { + if (recipeObject instanceof IRecipe) { + + IRecipe recipe = (IRecipe) recipeObject; + ItemStack recipeOutput = recipe.getRecipeOutput(); + + if (recipeOutput != null) { + ArrayList recipeInputs = RecipeHelper.getRecipeInputs(recipe); + vanillaRecipes.put(new CustomWrappedStack(recipeOutput), recipeInputs); + } + } + } } } diff --git a/ee3_common/com/pahimar/ee3/lib/Reference.java b/ee3_common/com/pahimar/ee3/lib/Reference.java index c07e3f29..4a8bd425 100644 --- a/ee3_common/com/pahimar/ee3/lib/Reference.java +++ b/ee3_common/com/pahimar/ee3/lib/Reference.java @@ -27,4 +27,6 @@ public class Reference { public static final String CLIENT_PROXY_CLASS = "com.pahimar.ee3.core.proxy.ClientProxy"; public static final int VERSION_CHECK_ATTEMPTS = 3; + public static final int ORE_DICTIONARY_NOT_FOUND = -1; + }