Working on some recipe stuff now

This commit is contained in:
pahimar 2013-09-28 15:00:28 -04:00
parent 9b1643ced3
commit 3ecb68f17d
6 changed files with 109 additions and 13 deletions

View file

@ -1,5 +1,5 @@
#Mon, 23 Sep 2013 15:00:03 -0400
minecraft_version=1.6.4
forge_version=9.11.0.886
forge_version=9.11.0.891
mod_version=pre2a
build_number=26

View file

@ -23,13 +23,10 @@ import com.pahimar.ee3.core.handlers.PlayerDestroyItemHandler;
import com.pahimar.ee3.core.handlers.VersionCheckTickHandler;
import com.pahimar.ee3.core.handlers.WorldTransmutationHandler;
import com.pahimar.ee3.core.proxy.CommonProxy;
import com.pahimar.ee3.core.util.EnergyStack;
import com.pahimar.ee3.core.util.LogHelper;
import com.pahimar.ee3.core.util.VersionHelper;
import com.pahimar.ee3.creativetab.CreativeTabEE3;
import com.pahimar.ee3.emc.DynEMC;
import com.pahimar.ee3.emc.EmcRegistry;
import com.pahimar.ee3.item.CustomWrappedStack;
import com.pahimar.ee3.item.ModItems;
import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
import com.pahimar.ee3.lib.InterModComms;
@ -178,9 +175,7 @@ public class EquivalentExchange3 {
// Initialize the DynEMC system
DynEMC dynEMC = DynEMC.getInstance();
//dynEMC.printDebugDump();
LogHelper.debug(EmcRegistry.getInstance().getEmcValue(new CustomWrappedStack(new EnergyStack(EnergyStack.VANILLA_SMELTING_ENERGY_NAME))));
dynEMC.printDebugDump();
}
@EventHandler

View file

@ -48,6 +48,17 @@ public class EnergyStack implements Comparable<EnergyStack> {
return false;
}
}
public static boolean compareEnergyNames(EnergyStack energyStack1, EnergyStack energyStack2) {
if (energyStack1 != null && energyStack2 != null) {
if ((energyStack1.energyName != null) && (energyStack2.energyName != null)) {
return energyStack1.energyName.equalsIgnoreCase(energyStack2.energyName);
}
}
return false;
}
@Override
public int compareTo(EnergyStack energyStack) {

View file

@ -1,5 +1,7 @@
package com.pahimar.ee3.emc;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -51,10 +53,10 @@ public class DynEMC {
Set<CustomWrappedStack> recipeKeySet = recipeMappings.keySet();
Iterator<CustomWrappedStack> recipeKeySetIterator = recipeKeySet.iterator();
CustomWrappedStack recipeOutput = null;
while (recipeKeySetIterator.hasNext()) {
recipeOutput = recipeKeySetIterator.next();
CustomWrappedStack recipeOutput = recipeKeySetIterator.next();
for (List<CustomWrappedStack> recipeInputs : recipeMappings.get(recipeOutput)) {
@ -87,13 +89,17 @@ public class DynEMC {
LogHelper.debug("");
for (Node<CustomWrappedStack> node : graph.getAllNodes()) {
List<Node<CustomWrappedStack>> nodes = new ArrayList<Node<CustomWrappedStack>>();
nodes.addAll(graph.getAllNodes());
Collections.sort(nodes);
for (Node<CustomWrappedStack> node : nodes) {
LogHelper.debug("Node: " + node);
LogHelper.debug("Edges FROM Node");
LogHelper.debug("Edges FROM this Node:");
for (WeightedDirectedEdge<CustomWrappedStack> fromEdge : graph.edgesFrom(node)) {
LogHelper.debug(" * " + fromEdge);
}
LogHelper.debug("Edges TO Node");
LogHelper.debug("Edges TO this Node:");
for (WeightedDirectedEdge<CustomWrappedStack> toEdge : graph.edgesTo(node)) {
LogHelper.debug(" * " + toEdge);
}

View file

@ -341,7 +341,7 @@ public class CustomWrappedStack implements Comparable<CustomWrappedStack> {
}
}
private static OreStack getOreStackFromList(ArrayList<?> objectList) {
private OreStack getOreStackFromList(ArrayList<?> objectList) {
for (Object listElement : objectList) {
if (listElement instanceof ItemStack) {

View file

@ -0,0 +1,84 @@
package com.pahimar.ee3.item.crafting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.item.ItemStack;
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.item.CustomWrappedStack;
public class CustomWrappedRecipe {
public CustomWrappedStack output;
public List<CustomWrappedStack> inputs;
public CustomWrappedRecipe(Object output, List<?> inputs) {
this.output = new CustomWrappedStack(output);
this.inputs = collateInputStacks(inputs);
}
public CustomWrappedRecipe(Object output, Object... inputs) {
this(output, Arrays.asList(inputs));
}
private List<CustomWrappedStack> collateInputStacks(List<?> uncollatedStacks) {
List<CustomWrappedStack> collatedStacks = new ArrayList<CustomWrappedStack>();
CustomWrappedStack stack = null;
boolean found = false;
for (Object object : uncollatedStacks) {
found = false;
if (CustomWrappedStack.canBeWrapped(object)) {
stack = new CustomWrappedStack(object);
if (collatedStacks.isEmpty()) {
collatedStacks.add(stack);
}
else {
for (int i = 0; i < collatedStacks.size(); i++) {
if (collatedStacks.get(i).getWrappedStack() != null) {
if (stack.getWrappedStack() instanceof ItemStack && collatedStacks.get(i).getWrappedStack() instanceof ItemStack) {
if (ItemUtil.compare((ItemStack) stack.getWrappedStack(), (ItemStack) collatedStacks.get(i).getWrappedStack())) {
collatedStacks.get(i).setStackSize(collatedStacks.get(i).getStackSize() + stack.getStackSize());
found = true;
}
}
else if (stack.getWrappedStack() instanceof OreStack && collatedStacks.get(i).getWrappedStack() instanceof OreStack) {
if (OreStack.compareOreNames((OreStack) stack.getWrappedStack(), (OreStack) collatedStacks.get(i).getWrappedStack())) {
collatedStacks.get(i).setStackSize(collatedStacks.get(i).getStackSize() + stack.getStackSize());
found = true;
}
}
else if (stack.getWrappedStack() instanceof EnergyStack && collatedStacks.get(i).getWrappedStack() instanceof EnergyStack) {
if (EnergyStack.compareEnergyNames((EnergyStack) stack.getWrappedStack(), (EnergyStack) collatedStacks.get(i).getWrappedStack())) {
collatedStacks.get(i).setStackSize(collatedStacks.get(i).getStackSize() + stack.getStackSize());
found = true;
}
}
}
}
if (!found) {
collatedStacks.add(stack);
}
}
}
}
return collatedStacks;
}
}