Aludel work

This commit is contained in:
pahimar 2014-01-07 18:42:29 -05:00
parent 46057f06bb
commit 9602bbf353
10 changed files with 175 additions and 71 deletions

View file

@ -8,6 +8,7 @@ import com.pahimar.ee3.lib.Compare;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
@ -106,6 +107,11 @@ public class OreStack implements Comparable<OreStack>
return gsonSerializer.toJson(this);
}
public static OreStack getOreStackFromList(Object... objects)
{
return getOreStackFromList(Arrays.asList(objects));
}
public static OreStack getOreStackFromList(List<?> objectList)
{
for (Object listElement : objectList)

View file

@ -22,7 +22,6 @@ import java.text.DecimalFormat;
@SideOnly(Side.CLIENT)
public class ItemTooltipEventHandler
{
private static boolean debug = true;
private static DecimalFormat emcDecimalFormat = new DecimalFormat("#.###");
@ForgeSubscribe(priority = EventPriority.LOWEST)
@ -32,7 +31,6 @@ public class ItemTooltipEventHandler
{
WrappedStack stack = new WrappedStack(event.itemStack);
event.toolTip.add(String.format("id: %s, Meta: %s", event.itemStack.itemID, event.itemStack.getItemDamage()));
if (EmcRegistry.getInstance().hasEmcValue(stack))
{
EmcValue emcValue = EmcRegistry.getInstance().getEmcValue(stack);

View file

@ -180,7 +180,7 @@ public class EmcValuesDefault
/* Equivalent Exchange 3 */
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 0)), new EmcValue(1));
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 1)), new EmcValue(256));
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 1)), new EmcValue(64));
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 2)), new EmcValue(2048));
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 3)), new EmcValue(8192));
}

View file

@ -3,9 +3,10 @@ package com.pahimar.ee3.handler;
import com.pahimar.ee3.configuration.ConfigurationSettings;
import com.pahimar.ee3.helper.ItemStackNBTHelper;
import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
import com.pahimar.ee3.item.crafting.RecipesEquivalentExchange;
import com.pahimar.ee3.item.crafting.RecipesTransmutationStones;
import com.pahimar.ee3.item.crafting.RecipesVanilla;
import com.pahimar.ee3.lib.Strings;
import com.pahimar.ee3.recipe.RecipesAludel;
import cpw.mods.fml.common.ICraftingHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.entity.player.EntityPlayer;
@ -31,8 +32,11 @@ public class CraftingHandler implements ICraftingHandler
CraftingManager.getInstance().getRecipeList().add(new RecipesAlchemicalBagDyes());
// Register our recipes
RecipesEquivalentExchange.init();
RecipesVanilla.init();
RecipesTransmutationStones.init();
RecipesAludel.getInstance();
RecipesAludel.getInstance().debugDumpMap();
}
@Override

View file

@ -76,7 +76,7 @@ public class EmcHelper
}
}
// If we are dealing with a "tool" (container item), assume it's value is 0 (since it won't be used up in the recipe)
else if (itemStack.getItem().getContainerItemStack(itemStack) != null)
else if (itemStack.getItem() != null && itemStack.getItem().getContainerItemStack(itemStack) != null)
{
wrappedStackValue = new EmcValue(0);
}

View file

@ -44,11 +44,11 @@ public class LogHelper
{
if (object != null)
{
log(Level.WARNING, String.format("[DEBUG] %s", object.toString()));
log(Level.INFO, String.format("[DEBUG] %s", object.toString()));
}
else
{
log(Level.WARNING, "[DEBUG] null");
log(Level.INFO, "[DEBUG] null");
}
}

View file

@ -8,7 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class RecipesEquivalentExchange
public class RecipesVanilla
{
public static void init()
{

View file

@ -15,5 +15,6 @@ public abstract class CommonProxy implements IProxy
GameRegistry.registerTileEntity(TileAlchemicalChestMedium.class, "tile." + Strings.ALCHEMICAL_CHEST_NAME + "Medium");
GameRegistry.registerTileEntity(TileAlchemicalChestLarge.class, "tile." + Strings.ALCHEMICAL_CHEST_NAME + "Large");
GameRegistry.registerTileEntity(TileGlassBell.class, "tile." + Strings.GLASS_BELL_NAME);
GameRegistry.registerTileEntity(TileResearchStation.class, "tile." + Strings.RESEARCH_STATION_NAME);
}
}

View file

@ -1,62 +0,0 @@
package com.pahimar.ee3.recipe;
import com.pahimar.ee3.helper.ItemHelper;
import com.pahimar.ee3.item.ItemAlchemicalDust;
import net.minecraft.item.ItemStack;
import java.util.SortedMap;
import java.util.TreeMap;
public class AludelRecipes
{
private static AludelRecipes aludelRegistry = null;
// TODO Handle that the input stack could be an OreStack
private SortedMap<ItemStack, ItemStack[]> aludelRecipes;
private AludelRecipes()
{
init();
}
public AludelRecipes getInstance()
{
if (aludelRegistry == null)
{
aludelRegistry = new AludelRecipes();
}
return aludelRegistry;
}
private void init()
{
aludelRecipes = new TreeMap<ItemStack, ItemStack[]>(ItemHelper.comparator);
}
public void addRecipe(ItemStack recipeOutput, ItemStack recipeInputStack, ItemStack recipeInputDust)
{
if (!aludelRecipes.containsKey(recipeOutput) && recipeInputDust.getItem() instanceof ItemAlchemicalDust)
{
aludelRecipes.put(recipeOutput, new ItemStack[]{recipeInputStack, recipeInputDust});
}
}
public ItemStack getResult(ItemStack recipeInputStack, ItemStack recipeInputDust)
{
for (ItemStack recipeOutput : aludelRecipes.keySet())
{
if (ItemHelper.equals(aludelRecipes.get(recipeOutput)[0], recipeInputStack) && ItemHelper.equals(aludelRecipes.get(recipeOutput)[1], recipeInputDust))
{
return recipeOutput;
}
}
return null;
}
public SortedMap<ItemStack, ItemStack[]> getRecipeMap()
{
return aludelRecipes;
}
}

View file

@ -0,0 +1,157 @@
package com.pahimar.ee3.recipe;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.pahimar.ee3.api.OreStack;
import com.pahimar.ee3.api.WrappedStack;
import com.pahimar.ee3.helper.LogHelper;
import com.pahimar.ee3.item.ItemAlchemicalDust;
import com.pahimar.ee3.item.ModItems;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class RecipesAludel
{
private static RecipesAludel aludelRegistry = null;
// TODO Handle that the input stack could be an OreStack
private Multimap<WrappedStack, WrappedStack[]> aludelRecipes;
private RecipesAludel()
{
aludelRecipes = HashMultimap.create();
}
public static RecipesAludel getInstance()
{
if (aludelRegistry == null)
{
aludelRegistry = new RecipesAludel();
aludelRegistry.init();
}
return aludelRegistry;
}
private void init()
{
// Alchemical Coal
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 0), new ItemStack(Item.coal, 1, 0), new ItemStack(ModItems.alchemicalDust.itemID, 32, 1));
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 0), new ItemStack(Item.coal, 1, 0), new ItemStack(ModItems.alchemicalDust.itemID, 1, 2));
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 4, 0), new ItemStack(Item.coal, 4, 0), new ItemStack(ModItems.alchemicalDust.itemID, 1, 3));
// Mobius Fuel
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 1), new ItemStack(Item.coal, 1, 0), new ItemStack(ModItems.alchemicalDust.itemID, 7, 2));
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 1), new ItemStack(Item.coal, 1, 0), new ItemStack(ModItems.alchemicalDust.itemID, 2, 3));
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 1), new ItemStack(ModItems.alchemicalFuel.itemID, 1, 0), new ItemStack(ModItems.alchemicalDust.itemID, 7, 2));
// Aeternalis Fuel
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 2), new ItemStack(Item.coal, 1, 0), new ItemStack(ModItems.alchemicalDust.itemID, 64, 2));
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 2), new ItemStack(Item.coal, 1, 0), new ItemStack(ModItems.alchemicalDust.itemID, 16, 3));
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 2), new ItemStack(ModItems.alchemicalFuel.itemID, 1, 0), new ItemStack(ModItems.alchemicalDust.itemID, 63, 2));
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 2), new ItemStack(ModItems.alchemicalFuel.itemID, 1, 0), new ItemStack(ModItems.alchemicalDust.itemID, 16, 3));
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 2), new ItemStack(ModItems.alchemicalFuel.itemID, 1, 1), new ItemStack(ModItems.alchemicalDust.itemID, 56, 2));
aludelRegistry.addRecipe(new ItemStack(ModItems.alchemicalFuel.itemID, 1, 2), new ItemStack(ModItems.alchemicalFuel.itemID, 1, 1), new ItemStack(ModItems.alchemicalDust.itemID, 14, 3));
// Infused Cloth
// Infused Wood
// Infused Planks
}
public void addRecipe(ItemStack recipeOutput, Object recipeInputStack, ItemStack recipeInputDust)
{
WrappedStack wrappedInputStack = new WrappedStack(recipeInputStack);
if (recipeOutput != null && (wrappedInputStack.getWrappedStack() instanceof ItemStack || wrappedInputStack.getWrappedStack() instanceof OreStack) && recipeInputDust.getItem() instanceof ItemAlchemicalDust)
{
WrappedStack wrappedRecipeOutput = new WrappedStack(recipeOutput);
WrappedStack wrappedDustStack = new WrappedStack(recipeInputDust);
if (!aludelRecipes.containsKey(wrappedRecipeOutput))
{
boolean recipeInputsExistAlready = false;
for (WrappedStack outputStack : aludelRecipes.keySet())
{
if (!recipeInputsExistAlready)
{
for (WrappedStack[] recipeInputs : aludelRecipes.get(outputStack))
{
if (recipeInputs.length == 2 && !recipeInputsExistAlready)
{
if (recipeInputs[0].equals(wrappedInputStack) && recipeInputs[1].equals(wrappedDustStack))
{
recipeInputsExistAlready = true;
}
}
}
}
}
if (!recipeInputsExistAlready)
{
aludelRecipes.put(wrappedRecipeOutput, new WrappedStack[]{wrappedInputStack, wrappedDustStack});
}
else
{
LogHelper.warning(String.format("Failed to add - O: %s, I: %s, D: %s", wrappedRecipeOutput, wrappedInputStack, wrappedDustStack));
}
}
}
}
public ItemStack getResult(ItemStack recipeInputStack, ItemStack recipeInputDust)
{
OreStack possibleOreStack = OreStack.getOreStackFromList(recipeInputStack);
WrappedStack wrappedInputStack;
if (possibleOreStack != null)
{
wrappedInputStack = new WrappedStack(possibleOreStack);
}
else
{
wrappedInputStack = new WrappedStack(recipeInputStack);
}
WrappedStack wrappedDustStack = new WrappedStack(recipeInputDust);
if (wrappedInputStack.getWrappedStack() != null && wrappedDustStack.getWrappedStack() != null)
{
for (WrappedStack recipeOutput : aludelRecipes.keySet())
{
for (WrappedStack[] recipeInputs : aludelRecipes.get(recipeOutput))
{
if (recipeInputs.length == 2)
{
if (recipeInputs[0].equals(wrappedInputStack) && recipeInputs[1].equals(wrappedDustStack))
{
return (ItemStack) recipeOutput.getWrappedStack();
}
}
}
}
}
return null;
}
public Multimap<WrappedStack, WrappedStack[]> getRecipeMap()
{
return aludelRecipes;
}
public void debugDumpMap()
{
for (WrappedStack recipeOutput : aludelRecipes.keySet())
{
for (WrappedStack[] recipeInputs : aludelRecipes.get(recipeOutput))
{
LogHelper.debug(String.format("Output: %s, Input Stack: %s, Dust Stack: %s", recipeOutput, recipeInputs[0], recipeInputs[1]));
}
}
}
}