Organizing imports, cleaning up formatting, and lots of work on recipe registry in prep for building the new DynEMC graph structure
This commit is contained in:
parent
fa838f34bc
commit
1591f537c3
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<CustomWrappedStack> populateWildCards() {
|
||||
|
||||
|
||||
ArrayList<CustomWrappedStack> wildCards = new ArrayList<CustomWrappedStack>();
|
||||
|
||||
|
||||
for (Object recipe : CraftingManager.getInstance().getRecipeList()) {
|
||||
|
||||
|
||||
if (recipe instanceof IRecipe) {
|
||||
|
||||
|
||||
if (((IRecipe) recipe).getRecipeOutput() instanceof ItemStack) {
|
||||
|
||||
|
||||
CustomWrappedStack recipeOutput = new CustomWrappedStack(((IRecipe) recipe).getRecipeOutput());
|
||||
ArrayList<CustomWrappedStack> 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<CustomWrappedStack> getRecipeInputs(IRecipe recipe) {
|
||||
|
||||
ArrayList<CustomWrappedStack> recipeInputs = new ArrayList<CustomWrappedStack>();
|
||||
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<CustomWrappedStack> getCollatedRecipeInputs(IRecipe recipe) {
|
||||
|
||||
|
||||
return ItemUtil.collateStacks(getRecipeInputs(recipe));
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<IRecipe> getReverseRecipes(CustomWrappedStack wrappedStack) {
|
||||
|
||||
|
||||
ArrayList<IRecipe> reverseRecipeList = new ArrayList<IRecipe>();
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<IRecipe> recipeList = new ArrayList<IRecipe>(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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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<CustomWrappedStack> keySet = null;
|
||||
Iterator<CustomWrappedStack> keySetIter = null;
|
||||
CustomWrappedStack key = null;
|
||||
|
||||
/* Add Potions */
|
||||
Multimap<CustomWrappedStack, List<CustomWrappedStack>> potionRecipes = RecipesPotions.getPotionRecipes();
|
||||
|
||||
keySet = potionRecipes.keySet();
|
||||
keySetIter = keySet.iterator();
|
||||
key = null;
|
||||
|
||||
while (keySetIter.hasNext()) {
|
||||
key = keySetIter.next();
|
||||
Multimap<CustomWrappedStack, List<CustomWrappedStack>> recipes = HashMultimap.create();
|
||||
Set<CustomWrappedStack> recipeKeySet = null;
|
||||
Iterator<CustomWrappedStack> recipeKeySetIterator = null;
|
||||
CustomWrappedStack recipeOutput = null;
|
||||
|
||||
for (List<CustomWrappedStack> 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<CustomWrappedStack> recipeInputs : recipes.get(recipeOutput)) {
|
||||
recipeManager.addRecipe(recipeOutput, recipeInputs);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add Smelting */
|
||||
Multimap<CustomWrappedStack, List<CustomWrappedStack>> smeltingRecipes = RecipesSmelting.getSmeltingRecipes();
|
||||
|
||||
keySet = smeltingRecipes.keySet();
|
||||
keySetIter = keySet.iterator();
|
||||
key = null;
|
||||
|
||||
while (keySetIter.hasNext()) {
|
||||
key = keySetIter.next();
|
||||
|
||||
for (List<CustomWrappedStack> 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());
|
||||
}
|
||||
|
||||
|
|
|
@ -23,16 +23,16 @@ public class EmcBlackList {
|
|||
public static EmcBlackList getInstance() {
|
||||
|
||||
if (emcBlackList == null) {
|
||||
|
||||
|
||||
emcBlackList = new EmcBlackList();
|
||||
emcBlackList.init();
|
||||
}
|
||||
|
||||
|
||||
return emcBlackList;
|
||||
}
|
||||
|
||||
|
||||
public List<CustomWrappedStack> 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);
|
||||
|
|
|
@ -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("<EMC Type: %s, Percentage: %s>", emcType, (percentage * 100)));
|
||||
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.pahimar.ee3.emc;
|
||||
|
||||
|
||||
public enum EmcType {
|
||||
CORPOREAL, KINETIC, TEMPORAL, ESSENTIA, AMORPHOUS, VOID, OMNI;
|
||||
}
|
||||
|
|
|
@ -16,10 +16,11 @@ public class EmcValue {
|
|||
|
||||
private float value, recoveryPercentage;
|
||||
private List<EmcComponent> emcComponents;
|
||||
|
||||
|
||||
public EmcValue() {
|
||||
|
||||
value = 0F;;
|
||||
value = 0F;
|
||||
;
|
||||
recoveryPercentage = 1F;
|
||||
emcComponents = new ArrayList<EmcComponent>();
|
||||
}
|
||||
|
@ -37,9 +38,9 @@ public class EmcValue {
|
|||
this.recoveryPercentage = recoveryPercentage;
|
||||
emcComponents = new ArrayList<EmcComponent>();
|
||||
}
|
||||
|
||||
|
||||
public EmcValue(float value, float recoveryPercentage, List<EmcComponent> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ public class EquivalencyGroup {
|
|||
|
||||
equivalentItems = new ArrayList<CustomWrappedStack>();
|
||||
}
|
||||
|
||||
|
||||
public EquivalencyGroup(List<ItemStack> equivalentItems) {
|
||||
|
||||
|
||||
this.equivalentItems = new ArrayList<CustomWrappedStack>();
|
||||
|
||||
|
||||
for (ItemStack itemStack : equivalentItems) {
|
||||
this.equivalentItems.add(new CustomWrappedStack(itemStack));
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ public class EquivalencyGroup {
|
|||
equivalentItems.add(customWrappedStack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setEquivalentItems(List<CustomWrappedStack> 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));
|
||||
|
|
|
@ -30,26 +30,26 @@ public class WeightedEdge<T> {
|
|||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<List<CustomWrappedStack>> recipeIterator = recipeMap.get(key).iterator();
|
||||
|
||||
while (recipeIterator.hasNext()) {
|
||||
List<CustomWrappedStack> values = recipeIterator.next();
|
||||
stringBuilder.append(String.format("Recipe Output: %s, Recipe Input: %s", key.toString(), values.toString()));
|
||||
|
||||
if (recipeIterator.hasNext()) {
|
||||
stringBuilder.append("\n");
|
||||
}
|
||||
Collection<List<CustomWrappedStack>> recipeMappings = recipeMap.get(key);
|
||||
|
||||
for (List<CustomWrappedStack> recipeList : recipeMappings) {
|
||||
stringBuilder.append(String.format("Recipe Output: %s, Recipe Input: %s\n", key.toString(), recipeList.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<CustomWrappedStack> recipeInputs = RecipeHelper.getRecipeInputs(recipe);
|
||||
vanillaRecipes.put(new CustomWrappedStack(recipeOutput), recipeInputs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue