More work on more intelligent recipe input collation (and swapping of wild card metas). More work still to be done
This commit is contained in:
parent
5f7ea23a4f
commit
a42a52971f
2 changed files with 58 additions and 6 deletions
|
@ -138,10 +138,20 @@ public class CustomWrappedStack {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
if (itemStack != null) {
|
if (itemStack != null) {
|
||||||
return ItemUtil.toString(itemStack);
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
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()));
|
||||||
|
|
||||||
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
else if (oreStack != null) {
|
else if (oreStack != null) {
|
||||||
return oreStack.toString();
|
return stackSize + "xoreDictionary." + oreStack.oreName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -2,14 +2,17 @@ package com.pahimar.ee3.item.crafting;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
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 net.minecraft.item.crafting.IRecipe;
|
||||||
|
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.pahimar.ee3.core.util.ItemUtil;
|
||||||
import com.pahimar.ee3.core.util.LogHelper;
|
import com.pahimar.ee3.core.util.LogHelper;
|
||||||
import com.pahimar.ee3.core.util.OreStack;
|
import com.pahimar.ee3.core.util.OreStack;
|
||||||
import com.pahimar.ee3.core.util.RecipeHelper;
|
import com.pahimar.ee3.core.util.RecipeHelper;
|
||||||
|
@ -80,8 +83,9 @@ public class RecipeRegistry {
|
||||||
ArrayList<CustomWrappedStack> collatedStacks = new ArrayList<CustomWrappedStack>();
|
ArrayList<CustomWrappedStack> collatedStacks = new ArrayList<CustomWrappedStack>();
|
||||||
|
|
||||||
CustomWrappedStack wrappedInputStack = null;
|
CustomWrappedStack wrappedInputStack = null;
|
||||||
|
boolean found = false;
|
||||||
|
|
||||||
LogHelper.debug("Recipe Output: " + recipeOutput.toString() + ", size: " + recipeOutput.getStackSize());
|
LogHelper.debug("Recipe Output: " + recipeOutput.toString());
|
||||||
LogHelper.debug("Recipe Inputs: " + recipeInputs.toString());
|
LogHelper.debug("Recipe Inputs: " + recipeInputs.toString());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,18 +102,56 @@ public class RecipeRegistry {
|
||||||
wrappedInputStack = (CustomWrappedStack) object;
|
wrappedInputStack = (CustomWrappedStack) object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wildCardList.contains(wrappedInputStack)) {
|
||||||
|
Iterator<CustomWrappedStack> wildIter = wildCardList.iterator();
|
||||||
|
while (wildIter.hasNext()) {
|
||||||
|
CustomWrappedStack wildCard = wildIter.next();
|
||||||
|
if (wildCard.equals(wrappedInputStack)) {
|
||||||
|
wrappedInputStack = wildCard;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collatedStacks.size() == 0) {
|
||||||
|
collatedStacks.add(wrappedInputStack);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
found = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < collatedStacks.size(); i++) {
|
||||||
|
if (collatedStacks.get(i) != null) {
|
||||||
|
if (wrappedInputStack.getWrappedStack() instanceof ItemStack && collatedStacks.get(i).getWrappedStack() instanceof ItemStack) {
|
||||||
|
if (ItemUtil.compare((ItemStack) wrappedInputStack.getWrappedStack(), (ItemStack) collatedStacks.get(i).getWrappedStack())) {
|
||||||
|
collatedStacks.get(i).setStackSize(collatedStacks.get(i).getStackSize() + wrappedInputStack.getStackSize());
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (wrappedInputStack.getWrappedStack() instanceof OreStack && collatedStacks.get(i).getWrappedStack() instanceof OreStack) {
|
||||||
|
if (OreStack.compareStacks((OreStack) wrappedInputStack.getWrappedStack(), (OreStack) collatedStacks.get(i).getWrappedStack())) {
|
||||||
|
collatedStacks.get(i).setStackSize(collatedStacks.get(i).getStackSize() + wrappedInputStack.getStackSize());
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
collatedStacks.add(wrappedInputStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Once we have a collated set of inputs for the given output, check to see if we have it registered already and if not add it to the recipeMap
|
||||||
for (CustomWrappedStack collatedStack : collatedStacks) {
|
for (CustomWrappedStack collatedStack : collatedStacks) {
|
||||||
|
LogHelper.debug("Collated Recipe Input: " + collatedStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogHelper.debug("Collated Recipe Inputs: " + collatedStacks.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Temporary for testing, remove this later
|
// TODO Temporary for testing, remove this later
|
||||||
static {
|
static {
|
||||||
recipeRegistry = new RecipeRegistry();
|
recipeRegistry = new RecipeRegistry();
|
||||||
CustomWrappedStack recipeOutput = new CustomWrappedStack(new ItemStack(Item.stick));
|
CustomWrappedStack recipeOutput = new CustomWrappedStack(new ItemStack(61,1,0));
|
||||||
List<IRecipe> recipes = RecipeHelper.getReverseRecipes(recipeOutput);
|
List<IRecipe> recipes = RecipeHelper.getReverseRecipes(recipeOutput);
|
||||||
|
|
||||||
for (IRecipe recipe : recipes) {
|
for (IRecipe recipe : recipes) {
|
||||||
|
|
Loading…
Reference in a new issue