RecipeAludel now supports OreDictionary input stacks. Also, added grouping (non-localized) to the EMC tooltip

This commit is contained in:
pahimar 2014-02-01 12:02:30 -05:00
parent 75dd447044
commit e8b63a28d6
4 changed files with 69 additions and 17 deletions

View file

@ -22,7 +22,7 @@ import java.text.DecimalFormat;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class ItemTooltipEventHandler public class ItemTooltipEventHandler
{ {
private static DecimalFormat emcDecimalFormat = new DecimalFormat("#.###"); private static DecimalFormat emcDecimalFormat = new DecimalFormat("###,###,###,###,###.###");
@ForgeSubscribe(priority = EventPriority.LOWEST) @ForgeSubscribe(priority = EventPriority.LOWEST)
public void handleItemTooltipEvent(ItemTooltipEvent event) public void handleItemTooltipEvent(ItemTooltipEvent event)

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3.item.crafting; package com.pahimar.ee3.item.crafting;
import com.pahimar.ee3.api.OreStack;
import com.pahimar.ee3.api.WrappedStack; import com.pahimar.ee3.api.WrappedStack;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
@ -10,24 +11,44 @@ import java.util.List;
public class RecipeAludel public class RecipeAludel
{ {
private ItemStack recipeOutput; private ItemStack recipeOutput;
private ItemStack inputStack; // TODO Allow this to match on OreDictionary items (so all wood works, rather than just vanilla wood) private WrappedStack inputStack;
private ItemStack dustStack; private ItemStack dustStack;
public RecipeAludel(ItemStack recipeOutput, ItemStack inputStack, ItemStack dustStack) public RecipeAludel(ItemStack recipeOutput, ItemStack inputStack, ItemStack dustStack)
{ {
this.recipeOutput = recipeOutput; this.recipeOutput = recipeOutput.copy();
this.inputStack = inputStack; this.inputStack = new WrappedStack(inputStack);
this.dustStack = dustStack; this.dustStack = dustStack.copy();
}
public RecipeAludel(ItemStack recipeOutput, OreStack inputStack, ItemStack dustStack)
{
this.recipeOutput = recipeOutput.copy();
this.inputStack = new WrappedStack(inputStack);
this.dustStack = dustStack.copy();
} }
public boolean matches(RecipeAludel recipeAludel) public boolean matches(RecipeAludel recipeAludel)
{ {
return compareItemStacks(this.recipeOutput, recipeAludel.recipeOutput) && compareItemStacks(this.inputStack, recipeAludel.inputStack) && compareItemStacks(this.dustStack, recipeAludel.dustStack); return compareItemStacks(this.recipeOutput, recipeAludel.recipeOutput) && matches(recipeAludel.inputStack, recipeAludel.dustStack);
} }
public boolean matches(ItemStack inputStack, ItemStack dustStack) public boolean matches(ItemStack inputStack, ItemStack dustStack)
{ {
return compareItemStacks(this.inputStack, inputStack) && compareItemStacks(this.dustStack, dustStack); if (OreDictionary.getOreID(inputStack) != -1)
{
if (matches(new WrappedStack(new OreStack(inputStack)), dustStack))
{
return matches(new WrappedStack(new OreStack(inputStack)), dustStack);
}
}
return matches(new WrappedStack(inputStack), dustStack);
}
public boolean matches(WrappedStack inputStack, ItemStack dustStack)
{
return compareStacks(this.inputStack, inputStack) && compareItemStacks(this.dustStack, dustStack);
} }
public ItemStack getRecipeOutput() public ItemStack getRecipeOutput()
@ -35,9 +56,9 @@ public class RecipeAludel
return this.recipeOutput; return this.recipeOutput;
} }
public ItemStack[] getRecipeInputs() public WrappedStack[] getRecipeInputs()
{ {
return new ItemStack[]{inputStack, dustStack}; return new WrappedStack[]{inputStack, new WrappedStack(dustStack)};
} }
public List<WrappedStack> getRecipeInputsAsWrappedStacks() public List<WrappedStack> getRecipeInputsAsWrappedStacks()
@ -65,6 +86,31 @@ public class RecipeAludel
return String.format("Output: %s, Input: %s, Dust: %s", recipeOutput, inputStack, dustStack); return String.format("Output: %s, Input: %s, Dust: %s", recipeOutput, inputStack, dustStack);
} }
private static boolean compareStacks(WrappedStack wrappedStack1, WrappedStack wrappedStack2)
{
if (wrappedStack1 != null && wrappedStack1.getWrappedStack() != null && wrappedStack2 != null && wrappedStack2.getWrappedStack() != null)
{
if (wrappedStack1.getWrappedStack() instanceof ItemStack && wrappedStack2.getWrappedStack() instanceof ItemStack)
{
ItemStack itemStack1 = (ItemStack) wrappedStack1.getWrappedStack();
itemStack1.stackSize = wrappedStack1.getStackSize();
ItemStack itemStack2 = (ItemStack) wrappedStack2.getWrappedStack();
itemStack2.stackSize = wrappedStack2.getStackSize();
return compareItemStacks(itemStack1, itemStack2);
}
else if (wrappedStack1.getWrappedStack() instanceof OreStack && wrappedStack2.getWrappedStack() instanceof OreStack)
{
if (((OreStack) wrappedStack1.getWrappedStack()).oreName.equalsIgnoreCase(((OreStack) wrappedStack2.getWrappedStack()).oreName))
{
return wrappedStack2.getStackSize() >= wrappedStack1.getStackSize();
}
}
}
return false;
}
private static boolean compareItemStacks(ItemStack itemStack1, ItemStack itemStack2) private static boolean compareItemStacks(ItemStack itemStack1, ItemStack itemStack2)
{ {
if (itemStack1 != null && itemStack2 != null) if (itemStack1 != null && itemStack2 != null)

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3.recipe; package com.pahimar.ee3.recipe;
import com.pahimar.ee3.api.OreStack;
import com.pahimar.ee3.block.ModBlocks; import com.pahimar.ee3.block.ModBlocks;
import com.pahimar.ee3.helper.LogHelper; import com.pahimar.ee3.helper.LogHelper;
import com.pahimar.ee3.item.ModItems; import com.pahimar.ee3.item.ModItems;
@ -57,14 +58,14 @@ public class RecipesAludel
aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedCloth.blockID, 1, 2), new ItemStack(Block.cloth.blockID, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust.itemID, 1, 3)); aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedCloth.blockID, 1, 2), new ItemStack(Block.cloth.blockID, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust.itemID, 1, 3));
// Infused Wood // Infused Wood
aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedWood.blockID, 1, 0), new ItemStack(Block.wood.blockID, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust.itemID, 4, 1)); aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedWood.blockID, 1, 0), new OreStack("logWood"), new ItemStack(ModItems.alchemicalDust.itemID, 4, 1));
aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedWood.blockID, 1, 1), new ItemStack(Block.wood.blockID, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust.itemID, 4, 2)); aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedWood.blockID, 1, 1), new OreStack("logWood"), new ItemStack(ModItems.alchemicalDust.itemID, 4, 2));
aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedWood.blockID, 1, 2), new ItemStack(Block.wood.blockID, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust.itemID, 4, 3)); aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedWood.blockID, 1, 2), new OreStack("logWood"), new ItemStack(ModItems.alchemicalDust.itemID, 4, 3));
// Infused Planks // Infused Planks
aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedPlanks.blockID, 1, 0), new ItemStack(Block.planks.blockID, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust.itemID, 1, 1)); aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedPlanks.blockID, 1, 0), new OreStack("plankWood"), new ItemStack(ModItems.alchemicalDust.itemID, 1, 1));
aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedPlanks.blockID, 1, 1), new ItemStack(Block.planks.blockID, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust.itemID, 1, 2)); aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedPlanks.blockID, 1, 1), new OreStack("plankWood"), new ItemStack(ModItems.alchemicalDust.itemID, 1, 2));
aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedPlanks.blockID, 1, 2), new ItemStack(Block.planks.blockID, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust.itemID, 1, 3)); aludelRegistry.addRecipe(new ItemStack(ModBlocks.infusedPlanks.blockID, 1, 2), new OreStack("plankWood"), new ItemStack(ModItems.alchemicalDust.itemID, 1, 3));
// Minium Stone // Minium Stone
aludelRegistry.addRecipe(new ItemStack(ModItems.miniumStone), new ItemStack(ModItems.inertStone), new ItemStack(ModItems.alchemicalDust.itemID, 8, 3)); aludelRegistry.addRecipe(new ItemStack(ModItems.miniumStone), new ItemStack(ModItems.inertStone), new ItemStack(ModItems.alchemicalDust.itemID, 8, 3));
@ -75,6 +76,11 @@ public class RecipesAludel
addRecipe(new RecipeAludel(recipeOutput, recipeInputStack, recipeInputDust)); addRecipe(new RecipeAludel(recipeOutput, recipeInputStack, recipeInputDust));
} }
public void addRecipe(ItemStack recipeOutput, OreStack recipeInputStack, ItemStack recipeInputDust)
{
addRecipe(new RecipeAludel(recipeOutput, recipeInputStack, recipeInputDust));
}
public void addRecipe(RecipeAludel recipeAludel) public void addRecipe(RecipeAludel recipeAludel)
{ {
if (!aludelRecipes.contains(recipeAludel)) if (!aludelRecipes.contains(recipeAludel))

View file

@ -331,8 +331,8 @@ public class TileAludel extends TileEE implements IInventory
inventory[OUTPUT_INVENTORY_INDEX].stackSize += recipe.getRecipeOutput().stackSize; inventory[OUTPUT_INVENTORY_INDEX].stackSize += recipe.getRecipeOutput().stackSize;
} }
decrStackSize(INPUT_INVENTORY_INDEX, recipe.getRecipeInputs()[0].stackSize); decrStackSize(INPUT_INVENTORY_INDEX, recipe.getRecipeInputs()[0].getStackSize());
decrStackSize(DUST_INVENTORY_INDEX, recipe.getRecipeInputs()[1].stackSize); decrStackSize(DUST_INVENTORY_INDEX, recipe.getRecipeInputs()[1].getStackSize());
} }
} }