diff --git a/ee3_common/com/pahimar/ee3/core/handlers/InterModCommsHandler.java b/ee3_common/com/pahimar/ee3/core/handlers/InterModCommsHandler.java deleted file mode 100644 index 4c137770..00000000 --- a/ee3_common/com/pahimar/ee3/core/handlers/InterModCommsHandler.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.pahimar.ee3.core.handlers; - -import java.util.List; -import java.util.Map; - -import net.minecraft.nbt.NBTTagCompound; - -import com.pahimar.ee3.core.util.LogHelper; -import com.pahimar.ee3.emc.EmcBlackList; -import com.pahimar.ee3.item.CustomWrappedStack; -import com.pahimar.ee3.item.crafting.RecipeRegistry; -import com.pahimar.ee3.lib.InterModComms; -import com.pahimar.ee3.nbt.NBTHelper; - -import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; -import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; - -public class InterModCommsHandler { - - public static void processIMCMessages(IMCEvent event) { - - for (IMCMessage imcMessage : event.getMessages()) { - - if (imcMessage.getMessageType() == NBTTagCompound.class) { - - if (imcMessage.key.equalsIgnoreCase(InterModComms.ADD_RECIPE)) { - processAddRecipeMessage(imcMessage); - } - else if (imcMessage.key.equalsIgnoreCase(InterModComms.ADD_BLACKLIST_ENTRY)) { - processAddBlackListMessage(imcMessage); - } - else if (imcMessage.key.equalsIgnoreCase(InterModComms.REMOVE_BLACKLIST_ENTRY)) { - processRemoveBlackListMessage(imcMessage); - } - else if (imcMessage.key.equalsIgnoreCase(InterModComms.SET_EMC_VALUE)) { - processSetEmcValueMessage(imcMessage); - } - } - else { - LogHelper.severe("[IMC] Mod '" + imcMessage.getSender() + "' sent a message with key '" + imcMessage.key + "' with an invalid argument type (received " + imcMessage.getMessageType().getSimpleName() + ", expected NBTTagCompound)"); - } - } - } - - private static void processAddRecipeMessage(IMCMessage imcMessage) { - - NBTTagCompound encodedRecipe = imcMessage.getNBTValue(); - - Map> decodedRecipe = NBTHelper.decodeRecipeFromNBT(encodedRecipe); - - if (!decodedRecipe.isEmpty()) { - for (CustomWrappedStack key : decodedRecipe.keySet()) { - RecipeRegistry.getInstance().addRecipe(key, decodedRecipe.get(key)); - LogHelper.info("[IMC] Mod '" + imcMessage.getSender() + "' added recipe with output '" + key.toString() + "' and inputs '" + decodedRecipe.get(key) + "'"); - } - } - else { - LogHelper.severe("[IMC] Mod '" + imcMessage.getSender() + "' attempting to add a NBT encoded recipe to the recipe registry, but the encoded recipe is invalid"); - } - } - - private static void processAddBlackListMessage(IMCMessage imcMessage) { - - NBTTagCompound encodedStack = imcMessage.getNBTValue(); - - CustomWrappedStack decodedStack = NBTHelper.decodeStackFromNBT(encodedStack); - - if (decodedStack != null) { - if (EmcBlackList.getInstance().add(decodedStack)) { - LogHelper.info("[IMC] Mod '" + imcMessage.getSender() + "' added object '" + decodedStack.toString() + "' to the EMC blacklist"); - } - else { - LogHelper.severe("[IMC] Mod '" + imcMessage.getSender() + "' attempted to add an object to the EMC blacklist that already existed"); - } - } - } - - private static void processRemoveBlackListMessage(IMCMessage imcMessage) { - - NBTTagCompound encodedStack = imcMessage.getNBTValue(); - - CustomWrappedStack decodedStack = NBTHelper.decodeStackFromNBT(encodedStack); - - if (decodedStack != null) { - if (EmcBlackList.getInstance().remove(decodedStack)) { - LogHelper.info("[IMC] Mod '" + imcMessage.getSender() + "' removed object '" + decodedStack.toString() + "' from the EMC blacklist"); - } - else { - LogHelper.severe("[IMC] Mod '" + imcMessage.getSender() + "' attempted to remove an object to the EMC blacklist that was not present"); - } - } - } - - private static void processSetEmcValueMessage(IMCMessage imcMessage) { - - // TODO Set an EMC Value via IMC - } -} diff --git a/ee3_common/com/pahimar/ee3/core/util/EnergyStack.java b/ee3_common/com/pahimar/ee3/core/util/EnergyStack.java deleted file mode 100644 index dc1c46ff..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/EnergyStack.java +++ /dev/null @@ -1,49 +0,0 @@ -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)); - } - -} diff --git a/ee3_common/com/pahimar/ee3/core/util/GeneralHelper.java b/ee3_common/com/pahimar/ee3/core/util/GeneralHelper.java deleted file mode 100644 index fc3cb7c0..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/GeneralHelper.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.pahimar.ee3.core.util; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.IMob; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -/** - * Equivalent-Exchange-3 - * - * GeneralHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class GeneralHelper { - - public static ItemStack convertObjectToItemStack(Object obj) { - - if (obj instanceof Item) - return new ItemStack((Item) obj); - else if (obj instanceof Block) - return new ItemStack((Block) obj); - else if (obj instanceof ItemStack) - return (ItemStack) obj; - else - return null; - } - - public static Object[] convertSingleStackToPluralStacks(ItemStack stack) { - - ArrayList list = new ArrayList(); - ItemStack currentStack; - - for (int i = 0; i < stack.stackSize; i++) { - currentStack = new ItemStack(stack.itemID, 1, stack.getItemDamage()); - list.add(currentStack); - } - - return list.toArray(); - } - - public static boolean isHostileEntity(EntityLivingBase entity) { - - if (entity instanceof IMob) - return true; - else - return false; - } - -} diff --git a/ee3_common/com/pahimar/ee3/core/util/ItemUtil.java b/ee3_common/com/pahimar/ee3/core/util/ItemUtil.java deleted file mode 100644 index d9b4f22d..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/ItemUtil.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.pahimar.ee3.core.util; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.oredict.OreDictionary; - -import com.pahimar.ee3.item.ModItems; -import com.pahimar.ee3.lib.Colours; -import com.pahimar.ee3.lib.Strings; -import com.pahimar.ee3.nbt.NBTHelper; - -/** - * Equivalent-Exchange-3 - * - * ItemDropHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class ItemUtil { - - private static double rand; - - public static String toString(ItemStack itemStack) { - - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.append("ItemStack("); - - if (itemStack != null) { - - stringBuilder.append(String.format("%s", encodeItemStackAsString(itemStack))); - - if (itemStack.hasTagCompound()) { - stringBuilder.append(String.format("%s%s", Strings.TOKEN_DELIMITER, NBTHelper.encodeNBTAsString((itemStack.getTagCompound())))); - } - } - else { - stringBuilder.append("null"); - } - - stringBuilder.append(")"); - - return stringBuilder.toString(); - } - - public static String encodeItemStackAsString(ItemStack itemStack) { - - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.append(String.format("%s%s%s", itemStack.itemID, Strings.TOKEN_DELIMITER, itemStack.getItemDamage())); - - return stringBuilder.toString(); - } - - public static ItemStack decodeItemStackFromString(String encodedItemStack) { - - ItemStack decodedItemStack = null; - - final int UNDEFINED = -1; - final int ERROR = -2; - - int itemId = UNDEFINED; - int meta = UNDEFINED; - - String[] splitString = encodedItemStack.split(Strings.TOKEN_DELIMITER); - - // Grab itemId - if (splitString.length >= 1) { - - try { - itemId = Integer.parseInt(splitString[0]); - } catch (NumberFormatException e) { - itemId = ERROR; - } - } - - // Grab meta - if (splitString.length >= 2) { - - try { - meta = Integer.parseInt(splitString[1]); - } catch (NumberFormatException e) { - meta = ERROR; - } - } - - if (meta == UNDEFINED) { - meta = OreDictionary.WILDCARD_VALUE; - } - - if (itemId != UNDEFINED && itemId != ERROR) { - if (meta != ERROR) { - decodedItemStack = new ItemStack(itemId, 1, meta); - } - } - - return decodedItemStack; - } - - /** - * 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 - * @param second - * 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) { - // If at least one of the ItemStacks has a NBTTagCompound, test for equality - if (first.hasTagCompound() || second.hasTagCompound()) { - - // If one of the stacks has a tag compound, but not both, they are not equal - if (!(first.hasTagCompound() && second.hasTagCompound())) { - return false; - } - // Otherwise, they both have tag compounds and we need to test them for equality - else { - return first.getTagCompound().equals(second.getTagCompound()); - } - } - // Otherwise, they must be equal if we have gotten this far (item IDs, meta data, and stack size all match) - else { - return true; - } - } - } - } - } - - return false; - } - - public static boolean hasColor(ItemStack itemStack) { - - return !itemStack.hasTagCompound() ? false : !itemStack.getTagCompound().hasKey(Strings.NBT_ITEM_DISPLAY) ? false : itemStack.getTagCompound().getCompoundTag(Strings.NBT_ITEM_DISPLAY).hasKey(Strings.NBT_ITEM_COLOR); - } - - public static int getColor(ItemStack itemStack) { - - NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); - - if (nbtTagCompound == null) - return Integer.parseInt(Colours.PURE_WHITE, 16); - else { - - NBTTagCompound displayTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY); - return displayTagCompound == null ? Integer.parseInt(Colours.PURE_WHITE, 16) : displayTagCompound.hasKey(Strings.NBT_ITEM_COLOR) ? displayTagCompound.getInteger(Strings.NBT_ITEM_COLOR) : Integer.parseInt(Colours.PURE_WHITE, 16); - } - } - - public static void setColor(ItemStack itemStack, int color) { - - if (itemStack != null) { - - NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); - - if (nbtTagCompound == null) { - - nbtTagCompound = new NBTTagCompound(); - itemStack.setTagCompound(nbtTagCompound); - } - - NBTTagCompound colourTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY); - - if (!nbtTagCompound.hasKey(Strings.NBT_ITEM_DISPLAY)) { - nbtTagCompound.setCompoundTag(Strings.NBT_ITEM_DISPLAY, colourTagCompound); - } - - colourTagCompound.setInteger(Strings.NBT_ITEM_COLOR, color); - } - } - - public static void dropMiniumShard(EntityPlayer player, EntityLivingBase entity) { - - if (GeneralHelper.isHostileEntity(entity)) { - rand = Math.random(); - - if (rand < 0.15d) { - entity.dropItem(ModItems.miniumShard.itemID, 1); - } - } - } - -} diff --git a/ee3_common/com/pahimar/ee3/core/util/KeyBindingUtil.java b/ee3_common/com/pahimar/ee3/core/util/KeyBindingUtil.java deleted file mode 100644 index b4bbf975..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/KeyBindingUtil.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.pahimar.ee3.core.util; - -import java.util.ArrayList; - -import net.minecraft.client.settings.KeyBinding; - -import com.pahimar.ee3.configuration.ConfigurationSettings; - -/** - * Equivalent-Exchange-3 - * - * KeyBindingHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class KeyBindingUtil { - - public static ArrayList keyBindingsList; - public static ArrayList isRepeatingList; - - public static void addKeyBinding(String name, int value) { - - if (keyBindingsList == null) { - keyBindingsList = new ArrayList(); - } - - keyBindingsList.add(new KeyBinding(name, value)); - } - - public static void addIsRepeating(boolean value) { - - if (isRepeatingList == null) { - isRepeatingList = new ArrayList(); - } - - isRepeatingList.add(value); - } - - public static KeyBinding[] gatherKeyBindings() { - - return keyBindingsList.toArray(new KeyBinding[keyBindingsList.size()]); - } - - public static boolean[] gatherIsRepeating() { - - boolean[] isRepeating = new boolean[isRepeatingList.size()]; - - for (int x = 0; x < isRepeating.length; x++) { - isRepeating[x] = isRepeatingList.get(x).booleanValue(); - } - - return isRepeating; - } - - // TODO Still not ideal, won't work for every case. Specifically, make it context sensitive - public static boolean isClientSided(String keybinding) { - - if (keybinding.equalsIgnoreCase(ConfigurationSettings.KEYBINDING_TOGGLE)) - return true; - else - return false; - } -} diff --git a/ee3_common/com/pahimar/ee3/core/util/LocalizationUtil.java b/ee3_common/com/pahimar/ee3/core/util/LocalizationUtil.java deleted file mode 100644 index 44a840b8..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/LocalizationUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.pahimar.ee3.core.util; - -import cpw.mods.fml.common.registry.LanguageRegistry; - -/** - * Equivalent-Exchange-3 - * - * LocalizationHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class LocalizationUtil { - - /*** - * Simple test to determine if a specified file name represents a XML file - * or not - * - * @param fileName - * String representing the file name of the file in question - * @return True if the file name represents a XML file, false otherwise - */ - public static boolean isXMLLanguageFile(String fileName) { - - return fileName.endsWith(".xml"); - } - - /*** - * Returns the locale from file name - * - * @param fileName - * String representing the file name of the file in question - * @return String representation of the locale snipped from the file name - */ - public static String getLocaleFromFileName(String fileName) { - - return fileName.substring(fileName.lastIndexOf('/') + 1, fileName.lastIndexOf('.')); - } - - public static String getLocalizedString(String key) { - - return LanguageRegistry.instance().getStringLocalization(key); - } - -} diff --git a/ee3_common/com/pahimar/ee3/core/util/LogHelper.java b/ee3_common/com/pahimar/ee3/core/util/LogHelper.java deleted file mode 100644 index 7cb52574..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/LogHelper.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.pahimar.ee3.core.util; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.pahimar.ee3.lib.Reference; - -import cpw.mods.fml.common.FMLLog; - -/** - * Equivalent-Exchange-3 - * - * LogHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class LogHelper { - - private static Logger eeLogger = Logger.getLogger(Reference.MOD_ID); - - public static void init() { - - eeLogger.setParent(FMLLog.getLogger()); - } - - public static void log(Level logLevel, String message) { - - eeLogger.log(logLevel, message); - } - - 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); - } -} diff --git a/ee3_common/com/pahimar/ee3/core/util/OreStack.java b/ee3_common/com/pahimar/ee3/core/util/OreStack.java deleted file mode 100644 index da143c7e..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/OreStack.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.pahimar.ee3.core.util; - -import java.util.ArrayList; -import java.util.Comparator; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - -public class OreStack implements Comparator { - - public String oreName; - public int stackSize; - - public OreStack() { - - stackSize = 0; - oreName = null; - } - - public OreStack(String oreName, int stackSize) { - - this.oreName = oreName; - this.stackSize = stackSize; - } - - public OreStack(String oreName) { - - this(oreName, 1); - } - - public OreStack(int oreID) { - - this(OreDictionary.getOreName(oreID)); - } - - public OreStack(int oreID, int stackSize) { - - this(OreDictionary.getOreName(oreID), stackSize); - } - - public OreStack(ItemStack itemStack) { - - this(OreDictionary.getOreID(itemStack), itemStack.stackSize); - } - - public ArrayList getOres() { - - return OreDictionary.getOres(oreName); - } - - public int getOreID() { - - return OreDictionary.getOreID(oreName); - } - - @Override - public String toString() { - - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.append(String.format("%dxoreDictionary.%s", stackSize, oreName)); - - return stringBuilder.toString(); - } - - @Override - public boolean equals(Object object) { - - if (!(object instanceof OreStack)) - return false; - - OreStack oreStackObject = (OreStack) object; - - return stackSize == oreStackObject.stackSize && oreName.equals(oreStackObject.oreName); - } - - @Override - public int compare(OreStack oreStack1, OreStack oreStack2) { - - if (oreStack1 != null && oreStack2 != null) { - if (oreStack1.oreName.equals(oreStack2.oreName)) - return 0; - } - - return -1; - } - - public static boolean compareStacks(OreStack oreStack1, OreStack oreStack2) { - - return oreStack1.compareToStack(oreStack2); - } - - public boolean compareToStack(OreStack oreStack) { - - return compare(this, oreStack) == 0; - } -} diff --git a/ee3_common/com/pahimar/ee3/core/util/QualityHelper.java b/ee3_common/com/pahimar/ee3/core/util/QualityHelper.java deleted file mode 100644 index 72aab085..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/QualityHelper.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.pahimar.ee3.core.util; - -import net.minecraft.item.ItemStack; - -/** - * Equivalent-Exchange-3 - * - * QualityHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class QualityHelper { - - private static int[][] dustTable = { { 0, 0, 0, 1, 1, 1 }, { 0, 1, 1, 1, 2, 2 }, { 0, 1, 2, 2, 2, 2 }, { 1, 1, 2, 3, 3, 3 }, { 1, 2, 2, 3, 4, 4 }, { 1, 2, 2, 3, 4, 5 }, }; - - public static int getItemTierQuality(ItemStack item) { - - // TODO Return the 'Tier' level of the given ItemStack - return -1; - } - - public static int getFuelTierQuality(ItemStack fuel) { - - // TODO Return the 'Tier' level of the given ItemStack - return -1; - } - - public static int getDustTierQuality(ItemStack item, ItemStack fuel) { - - if (getItemTierQuality(item) >= 0 && getItemTierQuality(item) <= 5) { - if (getFuelTierQuality(fuel) >= 0 && getFuelTierQuality(fuel) <= 5) - return dustTable[getItemTierQuality(item)][getFuelTierQuality(fuel)]; - } - - return -1; - } - -} diff --git a/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java b/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java deleted file mode 100644 index 8e616bf9..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/RecipeHelper.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.pahimar.ee3.core.util; - -import java.util.ArrayList; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.ShapedRecipes; -import net.minecraft.item.crafting.ShapelessRecipes; -import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.ShapedOreRecipe; -import net.minecraftforge.oredict.ShapelessOreRecipe; - -import com.pahimar.ee3.item.CustomWrappedStack; - -/** - * Equivalent-Exchange-3 - * - * RecipeHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class RecipeHelper { - - /** - * 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 - */ - public static ArrayList populateWildCards() { - - ArrayList wildCards = new ArrayList(); - - for (Object recipe : CraftingManager.getInstance().getRecipeList()) { - - if (recipe instanceof IRecipe) { - - if (((IRecipe) recipe).getRecipeOutput() instanceof ItemStack) { - - CustomWrappedStack recipeOutput = new CustomWrappedStack(((IRecipe) recipe).getRecipeOutput()); - ArrayList 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); - } - } - } - } - } - } - - return wildCards; - } - - /** - * Returns a list of elements that constitute the input in a crafting recipe - * - * @param recipe - * The IRecipe being examined - * @return List of elements that constitute the input of the given IRecipe. - * Could be an ItemStack or an Arraylist - */ - public static ArrayList getRecipeInputs(IRecipe recipe) { - - ArrayList recipeInputs = new ArrayList(); - - if (recipe instanceof ShapedRecipes) { - - ShapedRecipes shapedRecipe = (ShapedRecipes) recipe; - - for (int i = 0; i < shapedRecipe.recipeItems.length; i++) { - - if (shapedRecipe.recipeItems[i] instanceof ItemStack) { - - ItemStack itemStack = shapedRecipe.recipeItems[i].copy(); - - if (itemStack.stackSize > 1) { - itemStack.stackSize = 1; - } - - recipeInputs.add(new CustomWrappedStack(itemStack)); - } - } - } - else if (recipe instanceof ShapelessRecipes) { - - ShapelessRecipes shapelessRecipe = (ShapelessRecipes) recipe; - - for (Object object : shapelessRecipe.recipeItems) { - - if (object instanceof ItemStack) { - - ItemStack itemStack = ((ItemStack) object).copy(); - - if (itemStack.stackSize > 1) { - itemStack.stackSize = 1; - } - - recipeInputs.add(new CustomWrappedStack(itemStack)); - } - } - } - else if (recipe instanceof ShapedOreRecipe) { - - ShapedOreRecipe shapedOreRecipe = (ShapedOreRecipe) recipe; - - for (int i = 0; i < shapedOreRecipe.getInput().length; i++) { - - /* - * If the element is a list, then it is an OreStack - */ - if (shapedOreRecipe.getInput()[i] instanceof ArrayList) { - CustomWrappedStack oreStack = new CustomWrappedStack(shapedOreRecipe.getInput()[i]); - - if (oreStack.getWrappedStack() instanceof OreStack) { - recipeInputs.add(new CustomWrappedStack(shapedOreRecipe.getInput()[i])); - } - } - else if (shapedOreRecipe.getInput()[i] instanceof ItemStack) { - - ItemStack itemStack = ((ItemStack) shapedOreRecipe.getInput()[i]).copy(); - - if (itemStack.stackSize > 1) { - itemStack.stackSize = 1; - } - - recipeInputs.add(new CustomWrappedStack(itemStack)); - } - } - } - else if (recipe instanceof ShapelessOreRecipe) { - - ShapelessOreRecipe shapelessOreRecipe = (ShapelessOreRecipe) recipe; - - for (Object object : shapelessOreRecipe.getInput()) { - - if (object instanceof ArrayList) { - recipeInputs.add(new CustomWrappedStack(object)); - } - else if (object instanceof ItemStack) { - - ItemStack itemStack = ((ItemStack) object).copy(); - - if (itemStack.stackSize > 1) { - itemStack.stackSize = 1; - } - - recipeInputs.add(new CustomWrappedStack(itemStack)); - } - } - } - - return recipeInputs; - } -} diff --git a/ee3_common/com/pahimar/ee3/core/util/ResourceLocationHelper.java b/ee3_common/com/pahimar/ee3/core/util/ResourceLocationHelper.java deleted file mode 100644 index 148c51da..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/ResourceLocationHelper.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.pahimar.ee3.core.util; - -import com.pahimar.ee3.lib.Reference; - -import net.minecraft.util.ResourceLocation; - -public class ResourceLocationHelper { - - public static ResourceLocation getResourceLocation(String path) { - - return new ResourceLocation(Reference.MOD_ID.toLowerCase(), path); - } -} diff --git a/ee3_common/com/pahimar/ee3/core/util/TransmutationHelper.java b/ee3_common/com/pahimar/ee3/core/util/TransmutationHelper.java deleted file mode 100644 index a62d2584..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/TransmutationHelper.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.pahimar.ee3.core.util; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import com.pahimar.ee3.core.handlers.EquivalencyHandler; - -/** - * Equivalent-Exchange-3 - * - * TransmutationHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class TransmutationHelper { - - public static ItemStack previousBlockStack = null; - public static ItemStack currentBlockStack = null; - public static ItemStack targetBlockStack = null; - - public static boolean transmuteInWorld(World world, EntityPlayer player, ItemStack stack, int x, int y, int z, int targetID, int targetMeta) { - - if (Block.blocksList[targetID] != null) { - world.setBlock(x, y, z, targetID, targetMeta, 2); - return true; - } - - return false; - } - - public static String formatTargetBlockInfo(ItemStack targetBlock) { - - if (targetBlock != null) - return TransmutationHelper.targetBlockStack.itemID + ":" + TransmutationHelper.targetBlockStack.getItemDamage(); - else - return ""; - } - - public static void updateTargetBlock(World world, int x, int y, int z) { - - int id = world.getBlockId(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - Block currentBlock = Block.blocksList[id]; - - if (currentBlock != null) { - meta = currentBlock.damageDropped(meta); - - currentBlockStack = new ItemStack(id, 1, meta); - - if (previousBlockStack == null) { - previousBlockStack = currentBlockStack; - targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage()); - } - else { - if (!EquivalencyHandler.instance().areEquivalent(TransmutationHelper.previousBlockStack, currentBlockStack)) { - previousBlockStack = currentBlockStack; - targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage()); - } - } - } - } - - public static ItemStack getNextBlock(int id, int meta) { - - ArrayList list = EquivalencyHandler.instance().getEquivalencyList(id, meta); - - ItemStack nextStack = null; - - if (list != null) - return getNextBlock(id, meta, id, meta); - return nextStack; - } - - private static ItemStack getNextBlock(int id, int meta, int origId, int origMeta) { - - ArrayList list = EquivalencyHandler.instance().getEquivalencyList(id, meta); - - ItemStack nextStack = null; - - if (list != null) { - nextStack = EquivalencyHandler.instance().getNextInList(id, meta); - nextStack.stackSize = 1; - - /* - * If the current item is the same as the original one we started - * with, then we have recursed through the entire list and not found - * a next block so return the original. This is the "base case" for - * the recursion. - */ - if (nextStack.itemID == origId && nextStack.getItemDamage() == origMeta) - return nextStack; - else { - if (nextStack.getItem() instanceof ItemBlock) - return nextStack; - else - return getNextBlock(nextStack.itemID, nextStack.getItemDamage(), origId, origMeta); - } - } - - // In the event the list is null, return null - return nextStack; - } - - public static ItemStack getPreviousBlock(int itemID, int meta) { - - ArrayList list = EquivalencyHandler.instance().getEquivalencyList(itemID, meta); - - ItemStack prevStack = null; - - if (list != null) - return getPreviousBlock(itemID, meta, itemID, meta); - return prevStack; - } - - private static ItemStack getPreviousBlock(int id, int meta, int origId, int origMeta) { - - ArrayList list = EquivalencyHandler.instance().getEquivalencyList(id, meta); - - ItemStack prevStack = null; - if (list != null) { - prevStack = EquivalencyHandler.instance().getPrevInList(id, meta); - prevStack.stackSize = 1; - - if (prevStack.itemID == origId && prevStack.getItemDamage() == origMeta) - return prevStack; - else { - if (prevStack.getItem() instanceof ItemBlock) - return prevStack; - else - return getPreviousBlock(prevStack.itemID, prevStack.getItemDamage(), origId, origMeta); - } - } - - // In the event the list is null, return null - return prevStack; - } - -} diff --git a/ee3_common/com/pahimar/ee3/core/util/VersionHelper.java b/ee3_common/com/pahimar/ee3/core/util/VersionHelper.java deleted file mode 100644 index 1631b601..00000000 --- a/ee3_common/com/pahimar/ee3/core/util/VersionHelper.java +++ /dev/null @@ -1,224 +0,0 @@ -package com.pahimar.ee3.core.util; - -import java.io.InputStream; -import java.net.URL; -import java.util.Properties; - -import net.minecraftforge.common.Configuration; - -import com.pahimar.ee3.configuration.ConfigurationHandler; -import com.pahimar.ee3.configuration.ConfigurationSettings; -import com.pahimar.ee3.lib.Colours; -import com.pahimar.ee3.lib.Reference; -import com.pahimar.ee3.lib.Strings; - -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.LanguageRegistry; - -/** - * Equivalent-Exchange-3 - * - * VersionHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class VersionHelper implements Runnable { - - private static VersionHelper instance = new VersionHelper(); - - // The (publicly available) remote version number authority file - private static final String REMOTE_VERSION_XML_FILE = "https://raw.github.com/pahimar/Equivalent-Exchange-3/master/version.xml"; - - public static Properties remoteVersionProperties = new Properties(); - - // All possible results of the remote version number check - public static final byte UNINITIALIZED = 0; - public static final byte CURRENT = 1; - public static final byte OUTDATED = 2; - public static final byte ERROR = 3; - public static final byte FINAL_ERROR = 4; - public static final byte MC_VERSION_NOT_FOUND = 5; - - // Var to hold the result of the remote version check, initially set to uninitialized - private static byte result = UNINITIALIZED; - public static String remoteVersion = null; - public static String remoteUpdateLocation = null; - - /*** - * Checks the version of the currently running instance of the mod against - * the remote version authority, and sets the result of the check - * appropriately - */ - public static void checkVersion() { - - InputStream remoteVersionRepoStream = null; - result = UNINITIALIZED; - - try { - URL remoteVersionURL = new URL(REMOTE_VERSION_XML_FILE); - remoteVersionRepoStream = remoteVersionURL.openStream(); - remoteVersionProperties.loadFromXML(remoteVersionRepoStream); - - String remoteVersionProperty = remoteVersionProperties.getProperty(Loader.instance().getMCVersionString()); - - if (remoteVersionProperty != null) { - String[] remoteVersionTokens = remoteVersionProperty.split("\\|"); - - if (remoteVersionTokens.length >= 2) { - remoteVersion = remoteVersionTokens[0]; - remoteUpdateLocation = remoteVersionTokens[1]; - } - else { - result = ERROR; - } - - if (remoteVersion != null) { - if (!ConfigurationSettings.LAST_DISCOVERED_VERSION.equalsIgnoreCase(remoteVersion)) { - ConfigurationHandler.set(Configuration.CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME, remoteVersion); - } - - if (remoteVersion.equalsIgnoreCase(getVersionForCheck())) { - result = CURRENT; - } - else { - result = OUTDATED; - } - } - - } - else { - result = MC_VERSION_NOT_FOUND; - } - } - catch (Exception e) { - } - finally { - if (result == UNINITIALIZED) { - result = ERROR; - } - - try { - if (remoteVersionRepoStream != null) { - remoteVersionRepoStream.close(); - } - } - catch (Exception ex) { - } - } - } - - private static String getVersionForCheck() { - - String[] versionTokens = Reference.VERSION_NUMBER.split(" "); - - if (versionTokens.length >= 1) - return versionTokens[0]; - else - return Reference.VERSION_NUMBER; - } - - public static void logResult() { - - if (result == CURRENT || result == OUTDATED) { - LogHelper.info(getResultMessage()); - } - else { - LogHelper.warning(getResultMessage()); - } - } - - public static String getResultMessage() { - - if (result == UNINITIALIZED) - return LanguageRegistry.instance().getStringLocalization(Strings.UNINITIALIZED_MESSAGE); - else if (result == CURRENT) { - String returnString = LanguageRegistry.instance().getStringLocalization(Strings.CURRENT_MESSAGE); - returnString = returnString.replace("@REMOTE_MOD_VERSION@", remoteVersion); - returnString = returnString.replace("@MINECRAFT_VERSION@", Loader.instance().getMCVersionString()); - return returnString; - } - else if (result == OUTDATED && remoteVersion != null && remoteUpdateLocation != null) { - String returnString = LanguageRegistry.instance().getStringLocalization(Strings.OUTDATED_MESSAGE); - returnString = returnString.replace("@MOD_NAME@", Reference.MOD_NAME); - returnString = returnString.replace("@REMOTE_MOD_VERSION@", remoteVersion); - returnString = returnString.replace("@MINECRAFT_VERSION@", Loader.instance().getMCVersionString()); - returnString = returnString.replace("@MOD_UPDATE_LOCATION@", remoteUpdateLocation); - return returnString; - } - else if (result == OUTDATED && remoteVersion != null && remoteUpdateLocation != null) { - String returnString = LanguageRegistry.instance().getStringLocalization(Strings.OUTDATED_MESSAGE); - returnString = returnString.replace("@MOD_NAME@", Reference.MOD_NAME); - returnString = returnString.replace("@REMOTE_MOD_VERSION@", remoteVersion); - returnString = returnString.replace("@MINECRAFT_VERSION@", Loader.instance().getMCVersionString()); - returnString = returnString.replace("@MOD_UPDATE_LOCATION@", remoteUpdateLocation); - return returnString; - } - else if (result == ERROR) - return LanguageRegistry.instance().getStringLocalization(Strings.GENERAL_ERROR_MESSAGE); - else if (result == FINAL_ERROR) - return LanguageRegistry.instance().getStringLocalization(Strings.FINAL_ERROR_MESSAGE); - else if (result == MC_VERSION_NOT_FOUND) { - String returnString = LanguageRegistry.instance().getStringLocalization(Strings.MC_VERSION_NOT_FOUND); - returnString = returnString.replace("@MOD_NAME@", Reference.MOD_NAME); - returnString = returnString.replace("@MINECRAFT_VERSION@", Loader.instance().getMCVersionString()); - return returnString; - } - else { - result = ERROR; - return LanguageRegistry.instance().getStringLocalization(Strings.GENERAL_ERROR_MESSAGE); - } - } - - public static String getResultMessageForClient() { - - String returnString = LanguageRegistry.instance().getStringLocalization(Strings.OUTDATED_MESSAGE); - returnString = returnString.replace("@MOD_NAME@", Colours.TEXT_COLOUR_PREFIX_YELLOW + Reference.MOD_NAME + Colours.TEXT_COLOUR_PREFIX_WHITE); - returnString = returnString.replace("@REMOTE_MOD_VERSION@", Colours.TEXT_COLOUR_PREFIX_YELLOW + VersionHelper.remoteVersion + Colours.TEXT_COLOUR_PREFIX_WHITE); - returnString = returnString.replace("@MINECRAFT_VERSION@", Colours.TEXT_COLOUR_PREFIX_YELLOW + Loader.instance().getMCVersionString() + Colours.TEXT_COLOUR_PREFIX_WHITE); - returnString = returnString.replace("@MOD_UPDATE_LOCATION@", Colours.TEXT_COLOUR_PREFIX_YELLOW + VersionHelper.remoteUpdateLocation + Colours.TEXT_COLOUR_PREFIX_WHITE); - return returnString; - } - - public static byte getResult() { - - return result; - } - - @Override - public void run() { - - int count = 0; - - LogHelper.info(LanguageRegistry.instance().getStringLocalization(Strings.VERSION_CHECK_INIT_LOG_MESSAGE) + " " + REMOTE_VERSION_XML_FILE); - - try { - while (count < Reference.VERSION_CHECK_ATTEMPTS - 1 && (result == UNINITIALIZED || result == ERROR)) { - - checkVersion(); - count++; - logResult(); - - if (result == UNINITIALIZED || result == ERROR) { - Thread.sleep(10000); - } - } - - if (result == ERROR) { - result = FINAL_ERROR; - logResult(); - } - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - } - - public static void execute() { - - new Thread(instance).start(); - } - -} diff --git a/ee3_common/com/pahimar/ee3/emc/DynEMC.java b/ee3_common/com/pahimar/ee3/emc/DynEMC.java deleted file mode 100644 index f5891f8d..00000000 --- a/ee3_common/com/pahimar/ee3/emc/DynEMC.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.pahimar.ee3.emc; - -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Set; - -import com.google.common.collect.Multimap; -import com.pahimar.ee3.core.util.LogHelper; -import com.pahimar.ee3.emc.graph.WeightedDirectedGraph; -import com.pahimar.ee3.emc.graph.WeightedEdge; -import com.pahimar.ee3.item.CustomWrappedStack; -import com.pahimar.ee3.item.crafting.RecipeRegistry; - -public class DynEMC { - - private static DynEMC dynEMC = null; - - private RecipeRegistry recipeRegistry; - private WeightedDirectedGraph graph; - - private DynEMC() { - - recipeRegistry = RecipeRegistry.getInstance(); - graph = new WeightedDirectedGraph(); - - init(); - } - - public static DynEMC getInstance() { - - if (dynEMC == null) { - dynEMC = new DynEMC(); - } - - return dynEMC; - } - - private void init() { - - populateGraph(); - } - - private void populateGraph() { - - for (CustomWrappedStack discoveredStack : recipeRegistry.getDiscoveredStacks()) { - graph.addNode(discoveredStack); - } - - Multimap> recipeMappings = recipeRegistry.getRecipeMappings(); - - Set recipeKeySet = recipeMappings.keySet(); - Iterator recipeKeySetIterator = recipeKeySet.iterator(); - CustomWrappedStack recipeOutput = null; - - while (recipeKeySetIterator.hasNext()) { - recipeOutput = recipeKeySetIterator.next(); - - for (List recipeInputs : recipeMappings.get(recipeOutput)) { - - CustomWrappedStack unWrappedRecipeOutput = new CustomWrappedStack(recipeOutput.getWrappedStack()); - - if (graph.nodeExists(unWrappedRecipeOutput)) { - for (CustomWrappedStack recipeInput : recipeInputs) { - - // Unwrapped the wrapped stacks so that we actually find them in the graph - - CustomWrappedStack unWrappedRecipeInput = new CustomWrappedStack(recipeInput.getWrappedStack()); - - if (graph.nodeExists(unWrappedRecipeInput)) { - if (recipeOutput.getStackSize() != 0) { - try { - graph.addEdge(unWrappedRecipeOutput, unWrappedRecipeInput, (recipeInput.getStackSize() * 1.0f) / recipeOutput.getStackSize()); - } catch (NoSuchElementException e) { - LogHelper.severe(e.getLocalizedMessage()); - } - } - } - else { - LogHelper.debug("Recipe output '" + unWrappedRecipeOutput.toString() + "' exists in the crafting relationship graph"); - LogHelper.debug("Recipe input '" + unWrappedRecipeInput.toString() + "' does not exist in the crafting relationship graph"); - } - } - } - else { - LogHelper.debug("Recipe output '" + unWrappedRecipeOutput.toString() + "' does not exist in the crafting relationship graph"); - } - } - } - } - - public List getCriticalNodes() { - - return graph.getCriticalNodes(); - } - - public int size() { - - return graph.size(); - } - - public void printDebugDump() { - - LogHelper.debug("Total node count: " + graph.getAllNodes().size()); - LogHelper.debug("Critical node count: " + graph.getCriticalNodes().size()); - LogHelper.debug("Orphan node count: " + graph.getOrphanNodes().size()); - - List critsMinusOrphans = graph.getCriticalNodes(); - critsMinusOrphans.removeAll(graph.getOrphanNodes()); - - LogHelper.debug("[Critical - Orphans] node count: " + critsMinusOrphans.size()); - - LogHelper.debug("***** START NODES *****"); - Iterator nodeIter = graph.iterator(); - while (nodeIter.hasNext()) { - CustomWrappedStack node = nodeIter.next(); - LogHelper.debug("Node: " + node); - } - LogHelper.debug("***** END NODES *****"); - - LogHelper.debug("***** START EDGES FROM *****"); - nodeIter = graph.iterator(); - while (nodeIter.hasNext()) { - CustomWrappedStack node = nodeIter.next(); - Set> edgesFrom = graph.edgesFrom(node); - for (WeightedEdge edge : edgesFrom) { - LogHelper.debug("Crafting Output: " + node); - LogHelper.debug("Crafting Input: " + edge.getTarget()); - LogHelper.debug("Weight: " + edge.getWeight()); - LogHelper.debug(""); - } - } - LogHelper.debug("***** END EDGES FROM *****"); - - LogHelper.debug("***** START EDGES TO *****"); - nodeIter = graph.iterator(); - while (nodeIter.hasNext()) { - CustomWrappedStack node = nodeIter.next(); - Set> edgesTo = graph.edgesTo(node); - Iterator> edgeIter = edgesTo.iterator(); - while (edgeIter.hasNext()) { - WeightedEdge edge = edgeIter.next(); - LogHelper.debug("From: " + node); - LogHelper.debug("To: " + edge.getTarget()); - LogHelper.debug("Weight: " + edge.getWeight()); - LogHelper.debug(""); - } - } - LogHelper.debug("***** END EDGES TO *****"); - } - - @Override - public String toString() { - - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.append(String.format("DynEMC Node Count: %s", graph.size())); - - return stringBuilder.toString(); - } -} diff --git a/ee3_common/com/pahimar/ee3/emc/EmcBlackList.java b/ee3_common/com/pahimar/ee3/emc/EmcBlackList.java deleted file mode 100644 index 0e64eb56..00000000 --- a/ee3_common/com/pahimar/ee3/emc/EmcBlackList.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.pahimar.ee3.emc; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.Block; - -import com.pahimar.ee3.item.CustomWrappedStack; - -public class EmcBlackList { - - private static EmcBlackList emcBlackList = null; - - private ArrayList stackBlackList = new ArrayList(); - - private EmcBlackList() { - - } - - public static EmcBlackList getInstance() { - - if (emcBlackList == null) { - - emcBlackList = new EmcBlackList(); - emcBlackList.init(); - } - - return emcBlackList; - } - - public List getBlackList() { - - return stackBlackList; - } - - public boolean add(Object object) { - - boolean wasAdded = false; - - if (CustomWrappedStack.canBeWrapped(object)) { - - CustomWrappedStack wrappedStack = new CustomWrappedStack(object); - wrappedStack.setStackSize(1); - - if (!stackBlackList.contains(wrappedStack)) { - stackBlackList.add(wrappedStack); - wasAdded = true; - } - } - - return wasAdded; - } - - public boolean contains(Object object) { - - if (CustomWrappedStack.canBeWrapped(object)) { - - CustomWrappedStack wrappedStack = new CustomWrappedStack(object); - wrappedStack.setStackSize(1); - - return stackBlackList.contains(wrappedStack); - } - - return false; - } - - public boolean remove(Object object) { - - boolean wasRemoved = false; - - if (CustomWrappedStack.canBeWrapped(object)) { - - CustomWrappedStack wrappedStack = new CustomWrappedStack(object); - wrappedStack.setStackSize(1); - - if (stackBlackList.contains(wrappedStack)) { - stackBlackList.remove(wrappedStack); - wasRemoved = true; - } - } - - return wasRemoved; - } - - private void init() { - - add(Block.bed); - add(Block.pistonExtension); - add(Block.pistonMoving); - add(Block.mobSpawner); - add(Block.redstoneWire); - add(Block.crops); - add(Block.furnaceBurning); - add(Block.signPost); - add(Block.doorWood); - add(Block.signWall); - add(Block.doorIron); - add(Block.torchRedstoneIdle); - add(Block.reed); - add(Block.portal); - add(Block.cake); - add(Block.redstoneRepeaterIdle); - add(Block.redstoneRepeaterActive); - add(Block.lockedChest); - add(Block.pumpkinStem); - add(Block.melonStem); - add(Block.netherStalk); - add(Block.brewingStand); - add(Block.cauldron); - add(Block.endPortal); - add(Block.redstoneLampActive); - add(Block.commandBlock); - add(Block.carrot); - add(Block.potato); - add(Block.skull); - add(Block.redstoneComparatorIdle); - add(Block.redstoneComparatorActive); - } -} diff --git a/ee3_common/com/pahimar/ee3/emc/EmcComponent.java b/ee3_common/com/pahimar/ee3/emc/EmcComponent.java deleted file mode 100644 index 13c6fc9b..00000000 --- a/ee3_common/com/pahimar/ee3/emc/EmcComponent.java +++ /dev/null @@ -1,46 +0,0 @@ -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("", emcType, (percentage * 100))); - - return stringBuilder.toString(); - } -} diff --git a/ee3_common/com/pahimar/ee3/emc/EmcDefaultValues.java b/ee3_common/com/pahimar/ee3/emc/EmcDefaultValues.java deleted file mode 100644 index cac65ca2..00000000 --- a/ee3_common/com/pahimar/ee3/emc/EmcDefaultValues.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.pahimar.ee3.emc; - -import java.util.HashMap; -import java.util.List; - -import com.pahimar.ee3.item.CustomWrappedStack; - -public class EmcDefaultValues { - - private static HashMap> defaultEmcValues = new HashMap>(); - - public static void init() { - - } -} diff --git a/ee3_common/com/pahimar/ee3/emc/EmcMap.java b/ee3_common/com/pahimar/ee3/emc/EmcMap.java deleted file mode 100644 index 548ce166..00000000 --- a/ee3_common/com/pahimar/ee3/emc/EmcMap.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.pahimar.ee3.emc; - -import java.util.HashMap; - -import com.pahimar.ee3.item.CustomWrappedStack; - -public class EmcMap { - - private static EmcMap emcMap = null; - - private HashMap emcMappings; - - private EmcMap() { - - emcMappings = new HashMap(); - } - - public static EmcMap getInstance() { - - if (emcMap == null) { - emcMap = new EmcMap(); - } - - return emcMap; - } - - public EmcValue getEmcValue(Object object) { - - EmcValue emcValue = null; - - if (CustomWrappedStack.canBeWrapped(object)) { - return emcMappings.get(new CustomWrappedStack(object)); - } - - return emcValue; - } -} diff --git a/ee3_common/com/pahimar/ee3/emc/EmcType.java b/ee3_common/com/pahimar/ee3/emc/EmcType.java deleted file mode 100644 index 9630fe8c..00000000 --- a/ee3_common/com/pahimar/ee3/emc/EmcType.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.pahimar.ee3.emc; - -public enum EmcType { - CORPOREAL, KINETIC, TEMPORAL, ESSENTIA, AMORPHOUS, VOID, OMNI; -} diff --git a/ee3_common/com/pahimar/ee3/emc/EmcValue.java b/ee3_common/com/pahimar/ee3/emc/EmcValue.java deleted file mode 100644 index 19f02442..00000000 --- a/ee3_common/com/pahimar/ee3/emc/EmcValue.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.pahimar.ee3.emc; - -import java.util.ArrayList; -import java.util.List; - -import com.pahimar.ee3.lib.Strings; - -/** - * Equivalent-Exchange-3 - * - * EMCEntry - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class EmcValue { - - private float value, recoveryPercentage; - private List emcComponents; - - public EmcValue() { - - value = 0F; - recoveryPercentage = 1F; - emcComponents = new ArrayList(); - } - - public EmcValue(float value) { - - this.value = value; - recoveryPercentage = 1F; - emcComponents = new ArrayList(); - } - - public EmcValue(float value, float recoveryPercentage) { - - this.value = value; - this.recoveryPercentage = recoveryPercentage; - emcComponents = new ArrayList(); - } - - public EmcValue(float value, float recoveryPercentage, List emcComponents) { - - this.value = value; - this.recoveryPercentage = recoveryPercentage; - this.emcComponents = emcComponents; - } - - public float getValue() { - - return value; - } - - public float getRecoveryPercentage() { - - return recoveryPercentage; - } - - public List getComponents() { - - return emcComponents; - } - - public EmcComponent getComponent(EmcType emcType) { - - for (EmcComponent emcComponent : emcComponents) { - if (emcComponent.getEmcType().equals(emcType)) { - return emcComponent; - } - } - - return null; - } - - public boolean containsEmcType(EmcType emcType) { - - for (EmcComponent emcComponent : emcComponents) { - if (emcComponent.getEmcType().equals(emcType)) { - return true; - } - } - - return false; - } - - public void setValue(float cost) { - - this.value = cost; - } - - public void setRecoveryPercentage(float recoveryPercentage) { - - 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("V:%s", value)); - stringBuilder.append(Strings.TOKEN_DELIMITER); - stringBuilder.append(String.format("RP:%s", recoveryPercentage)); - stringBuilder.append(Strings.TOKEN_DELIMITER); - stringBuilder.append("["); - - for (int i = 0; i < emcComponents.size(); i++) { - if (i > 0) { - stringBuilder.append(Strings.TOKEN_DELIMITER); - } - stringBuilder.append(String.format("%s:%s", emcComponents.get(i).getEmcType(), emcComponents.get(i).getPercentage())); - } - - stringBuilder.append("]"); - - 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; - } -} diff --git a/ee3_common/com/pahimar/ee3/emc/EquivalencyGroup.java b/ee3_common/com/pahimar/ee3/emc/EquivalencyGroup.java deleted file mode 100644 index 724988aa..00000000 --- a/ee3_common/com/pahimar/ee3/emc/EquivalencyGroup.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.pahimar.ee3.emc; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import com.pahimar.ee3.item.CustomWrappedStack; - -public class EquivalencyGroup { - - private List equivalentItems; - - public EquivalencyGroup() { - - equivalentItems = new ArrayList(); - } - - public EquivalencyGroup(List equivalentItems) { - - this.equivalentItems = new ArrayList(); - - for (ItemStack itemStack : equivalentItems) { - this.equivalentItems.add(new CustomWrappedStack(itemStack)); - } - } - - public List getMembers() { - - return equivalentItems; - } - - public boolean containsMember(ItemStack itemStack) { - - return containsMember(new CustomWrappedStack(itemStack)); - } - - public boolean containsMember(CustomWrappedStack customWrappedStack) { - - return equivalentItems.contains(customWrappedStack); - } - - public void addMember(ItemStack itemStack) { - - this.addMember(new CustomWrappedStack(itemStack)); - } - - public void addMember(CustomWrappedStack customWrappedStack) { - - if (!containsMember(customWrappedStack)) { - equivalentItems.add(customWrappedStack); - } - } - - public void setEquivalentItems(List equivalentItems) { - - this.equivalentItems = equivalentItems; - } - - public void removeMember(ItemStack itemStack) { - - removeMember(new CustomWrappedStack(itemStack)); - } - - public void removeMember(CustomWrappedStack customWrappedStack) { - - while (containsMember(customWrappedStack)) { - equivalentItems.remove(customWrappedStack); - } - } - - public void clearMembers() { - - equivalentItems = new ArrayList(); - } - - @Override - public boolean equals(Object object) { - - if (!(object instanceof EquivalencyGroup)) { - return false; - } - - EquivalencyGroup equivalencyGroup = (EquivalencyGroup) object; - - return (equivalentItems.equals(equivalencyGroup.equivalentItems)); - } - - @Override - public String toString() { - - StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.append("Equivalent Group Members: "); - for (CustomWrappedStack customWrappedStack : equivalentItems) { - stringBuilder.append(String.format("%s ", customWrappedStack)); - } - - return stringBuilder.toString(); - } - - @Override - public int hashCode() { - - int hashCode = 1; - - for (CustomWrappedStack customWrappedStack : equivalentItems) { - hashCode = 37 * hashCode + customWrappedStack.hashCode(); - } - - return hashCode; - } -} diff --git a/ee3_common/com/pahimar/ee3/emc/graph/WeightedDirectedGraph.java b/ee3_common/com/pahimar/ee3/emc/graph/WeightedDirectedGraph.java deleted file mode 100644 index 59e39bce..00000000 --- a/ee3_common/com/pahimar/ee3/emc/graph/WeightedDirectedGraph.java +++ /dev/null @@ -1,272 +0,0 @@ -package com.pahimar.ee3.emc.graph; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.logging.Logger; - -import com.pahimar.ee3.core.util.LogHelper; - -public class WeightedDirectedGraph implements Iterable { - - private final Map>> graph = new HashMap>>(); - private List orderedNodes = new ArrayList(); - - public boolean addNode(T node) { - - // Ignore nodes already added - if (graph.containsKey(node)) - return false; - - orderedNodes.add(node); - graph.put(node, new TreeSet>(new Comparator>() { - - @Override - public int compare(WeightedEdge o1, WeightedEdge o2) { - - return orderedNodes.indexOf(o1.getTarget()) - orderedNodes.indexOf(o2.getTarget()); - } - })); - - return true; - } - - public void addEdge(T from, T to) { - - addEdge(from, to, 1); - } - - public void addEdge(T from, T to, float weight) { - - if (!(graph.containsKey(from) && graph.containsKey(to))) { - if (!graph.containsKey(from)) { - LogHelper.severe("From node doesn't exist: " + from.toString()); - LogHelper.severe("To node: " + to.toString()); - } - if (!graph.containsKey(to)) { - LogHelper.severe("From node: " + from.toString()); - LogHelper.severe("To node doesn't exist: " + to.toString()); - } - throw new NoSuchElementException("Missing nodes from graph"); - } - - // If a directed edge of the same weight doesn't already exist, add the new edge - if (!edgeExists(from, to, weight)) { - graph.get(from).add(new WeightedEdge(weight, to)); - } - } - - public boolean edgeExists(T from, T to) { - - if (!(graph.containsKey(from) && graph.containsKey(to))) - throw new NoSuchElementException("Missing nodes from graph"); - - Iterator> edgeIterator = graph.get(from).iterator(); - - while (edgeIterator.hasNext()) { - if (edgeIterator.next().getTarget().equals(to)) - return true; - } - - return false; - } - - public boolean edgeExists(T from, T to, float weight) { - - if (!(graph.containsKey(from) && graph.containsKey(to))) { - if (!graph.containsKey(from)) { - LOGGER.severe("From node doesn't exist: " + from.toString()); - LOGGER.severe("To node: " + to.toString()); - } - if (!graph.containsKey(to)) { - LOGGER.severe("To node doesn't exist: " + to.toString()); - LOGGER.severe("From node: " + from.toString()); - } - throw new NoSuchElementException("Missing nodes from graph"); - } - - return graph.get(from).contains(new WeightedEdge(weight, to)); - } - - public boolean nodeExists(T node) { - - return graph.containsKey(node); - } - - public Set> edgesFrom(T from) { - - if (!graph.containsKey(from)) - throw new NoSuchElementException("Missing node from graph"); - - return Collections.unmodifiableSortedSet(graph.get(from)); - } - - public Set> edgesTo(T to) { - - if (!graph.containsKey(to)) - throw new NoSuchElementException("Missing node from graph"); - - Set> edgesTo = new TreeSet>(new Comparator>() { - - @Override - public int compare(WeightedEdge o1, WeightedEdge o2) { - - return o1.hashCode() - o2.hashCode(); - } - }); - - for (T node : graph.keySet()) { - if (!node.equals(to)) { - Set> edgesFrom = edgesFrom(node); - - for (WeightedEdge fromEdge : edgesFrom) { - if (fromEdge.getTarget().equals(to)) { - edgesTo.add(new WeightedEdge(fromEdge.getWeight(), node)); - } - } - } - } - - return Collections.unmodifiableSet(edgesTo); - } - - public void removeNode(T node) { - - if (!graph.containsKey(node)) - throw new NoSuchElementException("Missing node from graph"); - - // Remove all edges from and to the node - removeAllEdgesFrom(node); - removeAllEdgesTo(node); - - // Remove the node - graph.remove(node); - } - - public void removeEdge(T from, T to) { - - removeEdge(from, to, 1); - } - - public void removeEdge(T from, T to, float weight) { - - if (!(graph.containsKey(from) && graph.containsKey(to))) - throw new NoSuchElementException("Missing nodes from graph"); - - graph.get(from).remove(new WeightedEdge(weight, to)); - } - - public void removeAllEdgesFrom(T node) { - - if (!graph.containsKey(node)) - throw new NoSuchElementException("Missing node from graph"); - - graph.get(node).clear(); - } - - public void removeAllEdgesTo(T node) { - - if (!graph.containsKey(node)) - throw new NoSuchElementException("Missing node from graph"); - - for (T aNode : graph.keySet()) { - Set> edgesFrom = edgesFrom(aNode); - - for (WeightedEdge fromEdge : edgesFrom) { - if (fromEdge.getTarget().equals(node)) { - graph.get(aNode).remove(fromEdge); - } - } - } - } - - public void removeAllEdgesBetween(T firstNode, T secondNode) { - - if (!(graph.containsKey(firstNode) && graph.containsKey(secondNode))) - throw new NoSuchElementException("Missing nodes from graph"); - - for (WeightedEdge edgeFrom : edgesFrom(firstNode)) { - if (edgeFrom.getTarget().equals(secondNode)) { - graph.get(firstNode).remove(edgeFrom); - } - } - - for (WeightedEdge edgeFrom : edgesFrom(secondNode)) { - if (edgeFrom.getTarget().equals(firstNode)) { - graph.get(secondNode).remove(edgeFrom); - } - } - } - - public List getAllNodes() { - - return orderedNodes; - } - - public List getCriticalNodes() { - - ArrayList criticalNodes = new ArrayList(); - - Iterator nodeIter = orderedNodes.iterator(); - - while (nodeIter.hasNext()) { - T currentNode = nodeIter.next(); - - if (this.edgesFrom(currentNode).size() == 0) { - criticalNodes.add(currentNode); - } - } - - return criticalNodes; - } - - public List getOrphanNodes() { - - ArrayList orphanedNodes = new ArrayList(); - - Iterator nodeIter = orderedNodes.iterator(); - - while (nodeIter.hasNext()) { - T currentNode = nodeIter.next(); - - if (this.edgesFrom(currentNode).size() == 0 && this.edgesTo(currentNode).size() == 0) { - orphanedNodes.add(currentNode); - } - } - - return orphanedNodes; - } - - @Override - public Iterator iterator() { - - return orderedNodes.iterator(); - } - - public int size() { - - return graph.size(); - } - - public boolean isEmpty() { - - return graph.isEmpty(); - } - - @Override - public String toString() { - - return graph.toString(); - } - - private static final Logger LOGGER = Logger.getLogger(WeightedDirectedGraph.class.getName()); - -} diff --git a/ee3_common/com/pahimar/ee3/emc/graph/WeightedEdge.java b/ee3_common/com/pahimar/ee3/emc/graph/WeightedEdge.java deleted file mode 100644 index 9b7d97ed..00000000 --- a/ee3_common/com/pahimar/ee3/emc/graph/WeightedEdge.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.pahimar.ee3.emc.graph; - -public class WeightedEdge { - - private float weight; - private T target; - - public WeightedEdge(float weight, T target) { - - this.weight = weight; - this.target = target; - } - - public float getWeight() { - - return weight; - } - - public T getTarget() { - - return target; - } - - public void setWeight(float weight) { - - this.weight = weight; - } - - public void setTarget(T target) { - - 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(); - } -} diff --git a/ee3_common/com/pahimar/ee3/item/CustomWrappedStack.java b/ee3_common/com/pahimar/ee3/item/CustomWrappedStack.java deleted file mode 100644 index 60923788..00000000 --- a/ee3_common/com/pahimar/ee3/item/CustomWrappedStack.java +++ /dev/null @@ -1,290 +0,0 @@ -package com.pahimar.ee3.item; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -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 { - - private int stackSize; - private ItemStack itemStack; - private OreStack oreStack; - private EnergyStack energyStack; - - /** - * Creates a new CustomWrappedStack object which wraps the given input. - * Valid inputs would be ItemStacks or OreStacks. If something other than an - * ItemStack or an OreStack is used as input, nothing is wrapped and the - * size of the wrapped stack is set to -1 to indicate an invalid wrapped - * stack. - * - * @param object - * The newly created wrapped stack object - */ - public CustomWrappedStack(Object object) { - - /* - * If we are given an Item or a Block, convert it to an ItemStack for further inspection - */ - if (object instanceof Item) { - object = new ItemStack((Item) object); - } - else if (object instanceof Block) { - object = new ItemStack((Block) object); - } - - /* - * We are given an ItemStack to wrap - */ - if (object instanceof ItemStack) { - - ItemStack itemStack = (ItemStack) object; - - /* - * If the ItemStack does not exist in the OreDictionary, wrap it as - * an ItemStack - */ - if (OreDictionary.getOreID(itemStack) == Reference.ORE_DICTIONARY_NOT_FOUND) { - this.itemStack = itemStack.copy(); - oreStack = null; - energyStack = null; - stackSize = this.itemStack.stackSize; - this.itemStack.stackSize = 1; - } - /* - * Else the ItemStack exists in the OreDictionary, so wrap it as an - * OreStack instead of an ItemStack - */ - else { - this.itemStack = null; - oreStack = new OreStack(itemStack); - energyStack = null; - stackSize = oreStack.stackSize; - oreStack.stackSize = 1; - } - } - /* - * Or we are given an OreStack to wrap - */ - else if (object instanceof OreStack) { - - itemStack = null; - oreStack = (OreStack) object; - energyStack = null; - 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 - */ - else if (object instanceof EnergyStack) { - itemStack = null; - oreStack = null; - energyStack = (EnergyStack) object; - stackSize = energyStack.stackSize; - energyStack.stackSize = 1; - } - else if (object instanceof CustomWrappedStack) { - CustomWrappedStack wrappedStack = (CustomWrappedStack) object; - - itemStack = wrappedStack.itemStack; - oreStack = wrappedStack.oreStack; - energyStack = wrappedStack.energyStack; - stackSize = wrappedStack.stackSize; - } - /* - * Else, we are given something we cannot wrap - */ - else { - stackSize = -1; - } - } - - /** - * Returns the stack size of the wrapped stack, or -1 if we wrapped an - * invalid input - * - * @return The size of the wrapped stack - */ - public int getStackSize() { - - return stackSize; - } - - /** - * Sets the size of the wrapped stack - * - * @param stackSize - * The new size of the wrapped stack - */ - public void setStackSize(int stackSize) { - - this.stackSize = stackSize; - } - - /** - * Returns the wrapped stack - * - * @return The wrapped ItemStack, OreStack, or EnergyStack, or null if - * something other than an ItemStack, OreStack, or EnergyStack was - * used to create this object - */ - public Object getWrappedStack() { - - if (itemStack != null) { - return itemStack; - } - else if (oreStack != null) { - return oreStack; - } - else if (energyStack != null) { - return energyStack; - } - - return null; - } - - @Override - public boolean equals(Object object) { - - if (!(object instanceof CustomWrappedStack)) - return false; - - CustomWrappedStack customWrappedStack = (CustomWrappedStack) object; - - if (itemStack != null) { - if (customWrappedStack.itemStack != null) - return ItemUtil.compare(itemStack, customWrappedStack.itemStack) && stackSize == customWrappedStack.itemStack.stackSize; - else if (customWrappedStack.oreStack != null) { - for (ItemStack oreDictItemStack : OreDictionary.getOres(customWrappedStack.oreStack.oreName)) { - if (ItemUtil.compare(itemStack, oreDictItemStack) && stackSize == customWrappedStack.stackSize) - return true; - } - } - } - else if (oreStack != null) { - if (customWrappedStack.itemStack != null) { - for (ItemStack oreDictItemStack : OreDictionary.getOres(oreStack.oreName)) { - if (ItemUtil.compare(customWrappedStack.itemStack, oreDictItemStack) && stackSize == customWrappedStack.stackSize) - return true; - } - } - else if (customWrappedStack.oreStack != null) - return oreStack.oreName.equalsIgnoreCase(customWrappedStack.oreStack.oreName) && stackSize == customWrappedStack.stackSize; - } - else if (energyStack != null) { - if (customWrappedStack.energyStack != null) { - return energyStack.energyName.equalsIgnoreCase(customWrappedStack.energyStack.energyName) && stackSize == customWrappedStack.stackSize; - } - } - - return false; - } - - @Override - public String toString() { - - StringBuilder stringBuilder = new StringBuilder(); - - if (itemStack != null) { - 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)); - } - else if (energyStack != null) { - stringBuilder.append(String.format("%dxenergyStack.%s", stackSize, energyStack.energyName)); - } - else { - stringBuilder.append("null"); - } - - return stringBuilder.toString(); - } - - public String encodeAsPropertyKey() { - - StringBuilder stringBuilder = new StringBuilder(); - - if (itemStack != null) { - 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)); - } - else if (energyStack != null) { - stringBuilder.append(String.format("%dxenergyStack.%s", stackSize, energyStack.energyName)); - } - - return stringBuilder.toString(); - } - - @Override - public int hashCode() { - - int hashCode = 1; - - hashCode = 37 * hashCode + stackSize; - - if (itemStack != null) { - hashCode = 37 * hashCode + itemStack.itemID; - - if (itemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) { - hashCode = 37 * hashCode; - } - else { - hashCode = 37 * hashCode + itemStack.getItemDamage(); - } - - try { - hashCode = 37 * hashCode + itemStack.getItemName().hashCode(); - } catch (ArrayIndexOutOfBoundsException e) { - - } - } - else if (oreStack != null) { - hashCode = 37 * hashCode + oreStack.oreName.hashCode(); - } - else if (energyStack != null) { - hashCode = 37 * hashCode + energyStack.energyName.hashCode(); - } - - return hashCode; - } - - public static boolean canBeWrapped(Object object) { - - return (object instanceof CustomWrappedStack || object instanceof ItemStack || object instanceof OreStack || object instanceof EnergyStack || object instanceof Item || object instanceof Block); - } -} diff --git a/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java b/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java deleted file mode 100644 index 48079f93..00000000 --- a/ee3_common/com/pahimar/ee3/item/crafting/RecipeRegistry.java +++ /dev/null @@ -1,301 +0,0 @@ -package com.pahimar.ee3.item.crafting; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -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.core.util.RecipeHelper; -import com.pahimar.ee3.item.CustomWrappedStack; - -public class RecipeRegistry { - - private static RecipeRegistry recipeRegistry = null; - - private Multimap> recipeMap; - private ArrayList discoveredStacks; - private ArrayList recipelessStacks; - private List wildCardStacks; - - private RecipeRegistry() { - - recipeMap = HashMultimap.create(); - wildCardStacks = RecipeHelper.populateWildCards(); - discoveredStacks = new ArrayList(); - recipelessStacks = new ArrayList(); - } - - public static RecipeRegistry getInstance() { - - if (recipeRegistry == null) { - recipeRegistry = new RecipeRegistry(); - recipeRegistry.init(); - } - - return recipeRegistry; - } - - private void init() { - - Multimap> recipes = HashMultimap.create(); - - // 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 - - // Populate the discovered stacks list with all stacks that we are involved in a recipe we are aware of - discoverStacks(recipes); - - // Add items that have no recipe, using the list of discovered stacks to determine if it's in a recipe or not - for (CustomWrappedStack stack : recipelessStacks) { - recipes.put(stack, new ArrayList()); - } - - // Iterate through every recipe in the map, and add them to the registry - Set recipeKeySet = recipes.keySet(); - Iterator recipeKeySetIterator = recipeKeySet.iterator(); - CustomWrappedStack recipeOutput = null; - - while (recipeKeySetIterator.hasNext()) { - recipeOutput = recipeKeySetIterator.next(); - - for (List recipeInputs : recipes.get(recipeOutput)) { - addRecipe(recipeOutput, recipeInputs); - } - } - } - - private void discoverStacks(Multimap> recipes) { - - Set recipeKeySet = recipes.keySet(); - Iterator recipeKeySetIterator = recipeKeySet.iterator(); - CustomWrappedStack recipeOutput = null; - - // Discover all stacks involved in the recipes we know about - while (recipeKeySetIterator.hasNext()) { - recipeOutput = recipeKeySetIterator.next(); - - if (!discoveredStacks.contains(new CustomWrappedStack(recipeOutput.getWrappedStack())) && recipeOutput.getWrappedStack() != null) { - discoveredStacks.add(new CustomWrappedStack(recipeOutput.getWrappedStack())); - } - - for (List recipeInputs : recipes.get(recipeOutput)) { - for (CustomWrappedStack recipeInput : recipeInputs) { - - CustomWrappedStack unwrappedRecipeInput = new CustomWrappedStack(recipeInput.getWrappedStack()); - - if (!discoveredStacks.contains(unwrappedRecipeInput) && recipeInput.getWrappedStack() != null) { - discoveredStacks.add(unwrappedRecipeInput); - } - } - } - } - - CustomWrappedStack customWrappedStack; - - // Discover all stacks from the vanilla Items array - for (int i = 0; i < Item.itemsList.length; i++) { - - if (Item.itemsList[i] != null) { - - if (Item.itemsList[i].getHasSubtypes()) { - - for (int meta = 0; meta < 16; meta++) { - - customWrappedStack = new CustomWrappedStack(new ItemStack(Item.itemsList[i].itemID, 1, meta)); - - if (!discoveredStacks.contains(customWrappedStack)) { - discoveredStacks.add(customWrappedStack); - } - } - } - else { - - customWrappedStack = new CustomWrappedStack(new ItemStack(Item.itemsList[i])); - - if (!discoveredStacks.contains(customWrappedStack)) { - discoveredStacks.add(customWrappedStack); - } - } - } - } - - /* - * For every stack we have discovered, check to see if we know a recipe for it. If we don't - * and we haven't already added it to the recipeless stack list, add it to the recipeless stack - * list - */ - for (CustomWrappedStack discoveredStack : discoveredStacks) { - - if (recipes.get(discoveredStack).size() == 0 && !recipelessStacks.contains(discoveredStack)) { - recipelessStacks.add(discoveredStack); - } - } - } - - public boolean hasRecipe(CustomWrappedStack customWrappedStack) { - - return recipeMap.containsKey(customWrappedStack); - } - - public boolean hasRecipe(ItemStack itemStack) { - - return hasRecipe(new CustomWrappedStack(itemStack)); - } - - public int countRecipesFor(CustomWrappedStack customWrappedStack) { - - Collection> keys = recipeMap.get(customWrappedStack); - - return keys.size(); - } - - public int countRecipesFor(ItemStack itemStack) { - - return countRecipesFor(new CustomWrappedStack(itemStack)); - } - - public Collection> getRecipesFor(CustomWrappedStack customWrappedStack) { - - return recipeMap.get(customWrappedStack); - } - - public Collection> getRecipesFor(ItemStack itemStack) { - - return getRecipesFor(new CustomWrappedStack(itemStack)); - } - - /* - * Item: Item (Output) <- { ... } - */ - public void addRecipe(CustomWrappedStack recipeOutput, List recipeInputs) { - - ArrayList collatedStacks = new ArrayList(); - - CustomWrappedStack wrappedInputStack = null; - boolean found = false; - - /** - * For every input in the input list, check to see if we have discovered - * it already - If we have, add it to the one we already have - If we - * have not, add it to the collection of discovered items - */ - for (Object object : recipeInputs) { - - if (object instanceof ItemStack || object instanceof OreStack) { - wrappedInputStack = new CustomWrappedStack(object); - } - else if (object instanceof CustomWrappedStack) { - wrappedInputStack = (CustomWrappedStack) object; - } - - if (wildCardStacks.contains(wrappedInputStack)) { - Iterator wildIter = wildCardStacks.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; - } - } - else if (wrappedInputStack.getWrappedStack() instanceof EnergyStack && collatedStacks.get(i).getWrappedStack() instanceof EnergyStack) { - if (((EnergyStack) wrappedInputStack.getWrappedStack()).energyName.equalsIgnoreCase(((EnergyStack) collatedStacks.get(i).getWrappedStack()).energyName)) { - collatedStacks.get(i).setStackSize(collatedStacks.get(i).getStackSize() + wrappedInputStack.getStackSize()); - found = true; - } - } - } - } - - if (!found) { - collatedStacks.add(wrappedInputStack); - } - } - } - - 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()) { - - Collection> recipeMappings = recipeMap.get(key); - - for (List recipeList : recipeMappings) { - stringBuilder.append(String.format("Recipe Output: %s, Recipe Input: %s\n", key.toString(), recipeList.toString())); - } - } - - return stringBuilder.toString(); - } - - public Multimap> getRecipeMappings() { - - return recipeMap; - } - - public List getDiscoveredStacks() { - - return discoveredStacks; - } - - public List getRecipelessStacks() { - - return recipelessStacks; - } - - public List getWildCardStacks() { - - return wildCardStacks; - } -} diff --git a/ee3_common/com/pahimar/ee3/item/crafting/RecipesPotions.java b/ee3_common/com/pahimar/ee3/item/crafting/RecipesPotions.java deleted file mode 100644 index c270bac9..00000000 --- a/ee3_common/com/pahimar/ee3/item/crafting/RecipesPotions.java +++ /dev/null @@ -1,292 +0,0 @@ -package com.pahimar.ee3.item.crafting; - -import java.util.Arrays; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import com.pahimar.ee3.item.CustomWrappedStack; - -public class RecipesPotions { - - private static Multimap> potionRecipes = null; - - private static CustomWrappedStack reagentWater = new CustomWrappedStack(new ItemStack(Block.waterStill)); - private static CustomWrappedStack reagentNetherWart = new CustomWrappedStack(new ItemStack(372, 1, 0)); - private static CustomWrappedStack reagentGlowstoneDust = new CustomWrappedStack(new ItemStack(Item.glowstone)); - private static CustomWrappedStack reagentRedstoneDust = new CustomWrappedStack(new ItemStack(331, 1, 0)); - private static CustomWrappedStack reagentGunpowder = new CustomWrappedStack(new ItemStack(Item.gunpowder)); - private static CustomWrappedStack reagentGoldenCarrot = new CustomWrappedStack(new ItemStack(Item.goldenCarrot)); - private static CustomWrappedStack reagentMagmaCream = new CustomWrappedStack(new ItemStack(Item.magmaCream)); - private static CustomWrappedStack reagentSugar = new CustomWrappedStack(new ItemStack(Item.sugar)); - private static CustomWrappedStack reagentGlisteringMelon = new CustomWrappedStack(new ItemStack(Item.speckledMelon)); - private static CustomWrappedStack reagentSpiderEye = new CustomWrappedStack(new ItemStack(Item.spiderEye)); - private static CustomWrappedStack reagentGhastTear = new CustomWrappedStack(new ItemStack(Item.ghastTear)); - private static CustomWrappedStack reagentFermentedSpiderEye = new CustomWrappedStack(new ItemStack(Item.fermentedSpiderEye)); - private static CustomWrappedStack reagentBlazePowder = new CustomWrappedStack(new ItemStack(Item.blazePowder)); - - private static CustomWrappedStack bottleWater = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 0)); - - private static CustomWrappedStack potionAwkward = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16)); - private static CustomWrappedStack potionThick = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 32)); - private static CustomWrappedStack potionMundane = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 128)); - private static CustomWrappedStack potionMundaneExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 64)); - private static CustomWrappedStack potionMundaneSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16512)); - private static CustomWrappedStack potionMundaneSplashExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16448)); - - private static CustomWrappedStack potionRegeneration = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8193)); - private static CustomWrappedStack potionRegenerationEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8225)); - private static CustomWrappedStack potionRegenerationExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8257)); - private static CustomWrappedStack potionRegenerationSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16385)); - private static CustomWrappedStack potionRegenerationSplashEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16417)); - private static CustomWrappedStack potionRegenerationSplashExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16449)); - - private static CustomWrappedStack potionSwiftness = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8194)); - private static CustomWrappedStack potionSwiftnessEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8226)); - private static CustomWrappedStack potionSwiftnessExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8258)); - private static CustomWrappedStack potionSwiftnessSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16386)); - private static CustomWrappedStack potionSwiftnessSplashEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16418)); - private static CustomWrappedStack potionSwiftnessSplashExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16450)); - - private static CustomWrappedStack potionFireResist = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8195)); - private static CustomWrappedStack potionFireResistExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8259)); - private static CustomWrappedStack potionFireResistSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16387)); - private static CustomWrappedStack potionFireResistSplashExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16451)); - - private static CustomWrappedStack potionPoison = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8196)); - private static CustomWrappedStack potionPoisonEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8228)); - private static CustomWrappedStack potionPoisonExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8260)); - private static CustomWrappedStack potionPoisonSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16388)); - private static CustomWrappedStack potionPoisonSplashEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16420)); - private static CustomWrappedStack potionPoisonSplashExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16452)); - - private static CustomWrappedStack potionHealing = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8197)); - private static CustomWrappedStack potionHealingEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8229)); - private static CustomWrappedStack potionHealingSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16389)); - private static CustomWrappedStack potionHealingSplashEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16421)); - - private static CustomWrappedStack potionNightVision = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8198)); - private static CustomWrappedStack potionNightVisionExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8262)); - private static CustomWrappedStack potionNightVisionSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16390)); - private static CustomWrappedStack potionNightVisionSplashExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16454)); - - private static CustomWrappedStack potionWeakness = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8200)); - private static CustomWrappedStack potionWeaknessExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8264)); - private static CustomWrappedStack potionWeaknessSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16392)); - private static CustomWrappedStack potionWeaknessSplashExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16456)); - - private static CustomWrappedStack potionStrength = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8201)); - private static CustomWrappedStack potionStrengthEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8233)); - private static CustomWrappedStack potionStrengthExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8265)); - private static CustomWrappedStack potionStrengthSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16393)); - private static CustomWrappedStack potionStrengthSplashEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16425)); - private static CustomWrappedStack potionStrengthSplashExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16457)); - - private static CustomWrappedStack potionSlowness = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8202)); - private static CustomWrappedStack potionSlownessExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8266)); - private static CustomWrappedStack potionSlownessSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16394)); - private static CustomWrappedStack potionSlownessSplashExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16458)); - - private static CustomWrappedStack potionHarming = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8204)); - private static CustomWrappedStack potionHarmingEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8236)); - private static CustomWrappedStack potionHarmingSplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16396)); - private static CustomWrappedStack potionHarmingSplashEnhanced = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16428)); - - private static CustomWrappedStack potionInvisibility = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8206)); - private static CustomWrappedStack potionInvisibilityExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 8270)); - private static CustomWrappedStack potionInvisibilitySplash = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16398)); - private static CustomWrappedStack potionInvisibilitySplashExtended = new CustomWrappedStack(new ItemStack(Item.potion.itemID, 1, 16462)); - - public static Multimap> getPotionRecipes() { - - if (potionRecipes == null) { - init(); - } - - return potionRecipes; - } - - private static void init() { - - potionRecipes = HashMultimap.create(); - - potionRecipes.put(bottleWater, Arrays.asList(reagentWater)); - - potionRecipes.put(potionAwkward, Arrays.asList(bottleWater, reagentNetherWart)); - - potionRecipes.put(potionNightVision, Arrays.asList(potionAwkward, reagentGoldenCarrot)); - potionRecipes.put(potionNightVision, Arrays.asList(potionNightVisionExtended, reagentGlowstoneDust)); - potionRecipes.put(potionNightVisionSplash, Arrays.asList(potionNightVisionSplashExtended, reagentGlowstoneDust)); - potionRecipes.put(potionNightVisionSplash, Arrays.asList(potionNightVision, reagentGunpowder)); - - potionRecipes.put(potionNightVisionExtended, Arrays.asList(potionNightVision, reagentRedstoneDust)); - potionRecipes.put(potionNightVisionSplashExtended, Arrays.asList(potionNightVisionSplash, reagentRedstoneDust)); - potionRecipes.put(potionNightVisionSplashExtended, Arrays.asList(potionNightVisionExtended, reagentGunpowder)); - - potionRecipes.put(potionInvisibility, Arrays.asList(potionNightVision, reagentFermentedSpiderEye)); - potionRecipes.put(potionInvisibility, Arrays.asList(potionInvisibilityExtended, reagentGlowstoneDust)); - potionRecipes.put(potionInvisibilitySplash, Arrays.asList(potionNightVisionSplash, reagentFermentedSpiderEye)); - potionRecipes.put(potionInvisibilitySplash, Arrays.asList(potionInvisibilitySplashExtended, reagentGlowstoneDust)); - potionRecipes.put(potionInvisibilitySplash, Arrays.asList(potionInvisibility, reagentGunpowder)); - - potionRecipes.put(potionInvisibilityExtended, Arrays.asList(potionInvisibility, reagentRedstoneDust)); - potionRecipes.put(potionInvisibilityExtended, Arrays.asList(potionNightVisionExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionInvisibilitySplashExtended, Arrays.asList(potionInvisibilitySplash, reagentRedstoneDust)); - potionRecipes.put(potionInvisibilitySplashExtended, Arrays.asList(potionNightVisionSplashExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionInvisibilitySplashExtended, Arrays.asList(potionInvisibilityExtended, reagentGunpowder)); - - potionRecipes.put(potionFireResist, Arrays.asList(potionAwkward, reagentMagmaCream)); - potionRecipes.put(potionFireResist, Arrays.asList(potionFireResistExtended, reagentGlowstoneDust)); - potionRecipes.put(potionFireResistSplash, Arrays.asList(potionFireResistSplashExtended, reagentGlowstoneDust)); - potionRecipes.put(potionFireResistSplash, Arrays.asList(potionFireResist, reagentGunpowder)); - - potionRecipes.put(potionFireResistExtended, Arrays.asList(potionFireResist, reagentRedstoneDust)); - potionRecipes.put(potionFireResistSplashExtended, Arrays.asList(potionFireResistSplash, reagentRedstoneDust)); - potionRecipes.put(potionFireResistSplashExtended, Arrays.asList(potionFireResistExtended, reagentGunpowder)); - - potionRecipes.put(potionSlowness, Arrays.asList(potionFireResist, reagentFermentedSpiderEye)); - potionRecipes.put(potionSlowness, Arrays.asList(potionSlownessExtended, reagentGlowstoneDust)); - potionRecipes.put(potionSlowness, Arrays.asList(potionSwiftness, reagentFermentedSpiderEye)); - potionRecipes.put(potionSlowness, Arrays.asList(potionSwiftnessExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionSlownessSplash, Arrays.asList(potionFireResistSplash, reagentFermentedSpiderEye)); - potionRecipes.put(potionSlownessSplash, Arrays.asList(potionSlownessSplashExtended, reagentGlowstoneDust)); - potionRecipes.put(potionSlownessSplash, Arrays.asList(potionSwiftnessSplash, reagentFermentedSpiderEye)); - potionRecipes.put(potionSlownessSplash, Arrays.asList(potionSwiftnessSplashExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionSlownessSplash, Arrays.asList(potionSlowness, reagentGunpowder)); - - potionRecipes.put(potionSlownessExtended, Arrays.asList(potionFireResistExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionSlownessExtended, Arrays.asList(potionSwiftnessEnhanced, reagentFermentedSpiderEye)); - potionRecipes.put(potionSlownessSplashExtended, Arrays.asList(potionFireResistSplashExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionSlownessSplashExtended, Arrays.asList(potionSwiftnessSplashEnhanced, reagentFermentedSpiderEye)); - potionRecipes.put(potionSlownessSplashExtended, Arrays.asList(potionSlownessExtended, reagentGunpowder)); - - potionRecipes.put(potionSwiftness, Arrays.asList(potionAwkward, reagentSugar)); - potionRecipes.put(potionSwiftnessSplash, Arrays.asList(potionSwiftness, reagentGunpowder)); - - potionRecipes.put(potionSwiftnessExtended, Arrays.asList(potionSwiftness, reagentRedstoneDust)); - potionRecipes.put(potionSwiftnessExtended, Arrays.asList(potionSwiftnessEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionSwiftnessSplashExtended, Arrays.asList(potionSwiftnessSplash, reagentRedstoneDust)); - potionRecipes.put(potionSwiftnessSplashExtended, Arrays.asList(potionSwiftnessSplashEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionSwiftnessSplashExtended, Arrays.asList(potionSwiftnessExtended, reagentGunpowder)); - - potionRecipes.put(potionSwiftnessEnhanced, Arrays.asList(potionSwiftness, reagentGlowstoneDust)); - potionRecipes.put(potionSwiftnessEnhanced, Arrays.asList(potionSwiftnessExtended, reagentGlowstoneDust)); - potionRecipes.put(potionSwiftnessSplashEnhanced, Arrays.asList(potionSwiftnessSplash, reagentGlowstoneDust)); - potionRecipes.put(potionSwiftnessSplashEnhanced, Arrays.asList(potionSwiftnessSplashExtended, reagentGlowstoneDust)); - potionRecipes.put(potionSwiftnessSplashEnhanced, Arrays.asList(potionSwiftnessEnhanced, reagentGunpowder)); - - potionRecipes.put(potionHealing, Arrays.asList(potionAwkward, reagentGlisteringMelon)); - potionRecipes.put(potionHealing, Arrays.asList(potionHealingEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionHealingSplash, Arrays.asList(potionHealingSplashEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionHealingSplash, Arrays.asList(potionHealing, reagentGunpowder)); - - potionRecipes.put(potionHealingEnhanced, Arrays.asList(potionHealing, reagentGlowstoneDust)); - potionRecipes.put(potionHealingSplashEnhanced, Arrays.asList(potionHealingSplash, reagentGlowstoneDust)); - potionRecipes.put(potionHealingSplashEnhanced, Arrays.asList(potionHealingEnhanced, reagentGunpowder)); - - potionRecipes.put(potionHarming, Arrays.asList(potionHealing, reagentFermentedSpiderEye)); - potionRecipes.put(potionHarming, Arrays.asList(potionPoison, reagentFermentedSpiderEye)); - potionRecipes.put(potionHarming, Arrays.asList(potionPoisonExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionHarming, Arrays.asList(potionHarmingEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionHarmingSplash, Arrays.asList(potionHealingSplash, reagentFermentedSpiderEye)); - potionRecipes.put(potionHarmingSplash, Arrays.asList(potionPoisonSplash, reagentFermentedSpiderEye)); - potionRecipes.put(potionHarmingSplash, Arrays.asList(potionPoisonSplashExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionHarmingSplash, Arrays.asList(potionHarmingSplashEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionHarmingSplash, Arrays.asList(potionHarming, reagentGunpowder)); - - potionRecipes.put(potionHarmingEnhanced, Arrays.asList(potionHealingEnhanced, reagentFermentedSpiderEye)); - potionRecipes.put(potionHarmingEnhanced, Arrays.asList(potionHarming, reagentGlowstoneDust)); - potionRecipes.put(potionHarmingEnhanced, Arrays.asList(potionPoisonEnhanced, reagentFermentedSpiderEye)); - potionRecipes.put(potionHarmingSplashEnhanced, Arrays.asList(potionHealingSplashEnhanced, reagentFermentedSpiderEye)); - potionRecipes.put(potionHarmingSplashEnhanced, Arrays.asList(potionHarmingSplash, reagentGlowstoneDust)); - potionRecipes.put(potionHarmingSplashEnhanced, Arrays.asList(potionPoisonSplashEnhanced, reagentFermentedSpiderEye)); - potionRecipes.put(potionHarmingSplashEnhanced, Arrays.asList(potionHarmingEnhanced, reagentGunpowder)); - - potionRecipes.put(potionPoison, Arrays.asList(potionAwkward, reagentSpiderEye)); - potionRecipes.put(potionPoisonSplash, Arrays.asList(potionPoison, reagentGunpowder)); - - potionRecipes.put(potionPoisonExtended, Arrays.asList(potionPoisonExtended, reagentRedstoneDust)); - potionRecipes.put(potionPoisonExtended, Arrays.asList(potionPoisonEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionPoisonSplashExtended, Arrays.asList(potionPoisonSplashExtended, reagentRedstoneDust)); - potionRecipes.put(potionPoisonSplashExtended, Arrays.asList(potionPoisonSplashEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionPoisonSplashExtended, Arrays.asList(potionPoisonExtended, reagentGunpowder)); - - potionRecipes.put(potionPoisonEnhanced, Arrays.asList(potionPoison, reagentGlowstoneDust)); - potionRecipes.put(potionPoisonEnhanced, Arrays.asList(potionPoisonExtended, reagentGlowstoneDust)); - potionRecipes.put(potionPoisonSplashEnhanced, Arrays.asList(potionPoisonSplash, reagentGlowstoneDust)); - potionRecipes.put(potionPoisonSplashEnhanced, Arrays.asList(potionPoisonSplashExtended, reagentGlowstoneDust)); - potionRecipes.put(potionPoisonSplashEnhanced, Arrays.asList(potionPoisonEnhanced, reagentGunpowder)); - - potionRecipes.put(potionRegeneration, Arrays.asList(potionAwkward, reagentGhastTear)); - potionRecipes.put(potionRegenerationSplash, Arrays.asList(potionRegeneration, reagentGunpowder)); - - potionRecipes.put(potionRegenerationExtended, Arrays.asList(potionRegeneration, reagentRedstoneDust)); - potionRecipes.put(potionRegenerationExtended, Arrays.asList(potionRegenerationEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionRegenerationSplashExtended, Arrays.asList(potionRegenerationSplash, reagentRedstoneDust)); - potionRecipes.put(potionRegenerationSplashExtended, Arrays.asList(potionRegenerationSplashEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionRegenerationSplashExtended, Arrays.asList(potionRegenerationExtended, reagentGunpowder)); - - potionRecipes.put(potionRegenerationEnhanced, Arrays.asList(potionRegeneration, reagentGlowstoneDust)); - potionRecipes.put(potionRegenerationEnhanced, Arrays.asList(potionRegenerationExtended, reagentGlowstoneDust)); - potionRecipes.put(potionRegenerationSplashEnhanced, Arrays.asList(potionRegenerationSplash, reagentGlowstoneDust)); - potionRecipes.put(potionRegenerationSplashEnhanced, Arrays.asList(potionRegenerationSplashExtended, reagentGlowstoneDust)); - potionRecipes.put(potionRegenerationSplashEnhanced, Arrays.asList(potionRegenerationEnhanced, reagentGunpowder)); - - potionRecipes.put(potionWeakness, Arrays.asList(potionAwkward, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeakness, Arrays.asList(potionRegeneration, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeakness, Arrays.asList(potionRegenerationEnhanced, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeakness, Arrays.asList(potionStrength, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeakness, Arrays.asList(potionStrengthEnhanced, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeakness, Arrays.asList(potionMundane, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeakness, Arrays.asList(potionWeaknessExtended, reagentGlowstoneDust)); - potionRecipes.put(potionWeaknessSplash, Arrays.asList(potionRegenerationSplash, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessSplash, Arrays.asList(potionRegenerationSplashEnhanced, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessSplash, Arrays.asList(potionStrengthSplash, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessSplash, Arrays.asList(potionStrengthSplashEnhanced, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessSplash, Arrays.asList(potionMundaneSplash, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessSplash, Arrays.asList(potionWeaknessSplashExtended, reagentGlowstoneDust)); - potionRecipes.put(potionWeaknessSplash, Arrays.asList(potionWeakness, reagentGunpowder)); - - potionRecipes.put(potionWeaknessExtended, Arrays.asList(potionWeakness, reagentRedstoneDust)); - potionRecipes.put(potionWeaknessExtended, Arrays.asList(potionRegenerationExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessExtended, Arrays.asList(potionStrengthExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessExtended, Arrays.asList(potionMundaneExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessSplashExtended, Arrays.asList(potionWeaknessSplash, reagentRedstoneDust)); - potionRecipes.put(potionWeaknessSplashExtended, Arrays.asList(potionRegenerationSplashExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessSplashExtended, Arrays.asList(potionStrengthSplashExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessSplashExtended, Arrays.asList(potionMundaneSplashExtended, reagentFermentedSpiderEye)); - potionRecipes.put(potionWeaknessSplashExtended, Arrays.asList(potionWeaknessExtended, reagentGunpowder)); - - potionRecipes.put(potionStrength, Arrays.asList(potionAwkward, reagentBlazePowder)); - potionRecipes.put(potionStrengthSplash, Arrays.asList(potionStrength, reagentGunpowder)); - - potionRecipes.put(potionStrengthEnhanced, Arrays.asList(potionStrength, reagentGlowstoneDust)); - potionRecipes.put(potionStrengthEnhanced, Arrays.asList(potionStrengthExtended, reagentGlowstoneDust)); - potionRecipes.put(potionStrengthSplashEnhanced, Arrays.asList(potionStrengthSplash, reagentGlowstoneDust)); - potionRecipes.put(potionStrengthSplashEnhanced, Arrays.asList(potionStrengthSplashExtended, reagentGlowstoneDust)); - potionRecipes.put(potionStrengthSplashEnhanced, Arrays.asList(potionStrengthEnhanced, reagentGunpowder)); - - potionRecipes.put(potionStrengthExtended, Arrays.asList(potionStrength, reagentRedstoneDust)); - potionRecipes.put(potionStrengthExtended, Arrays.asList(potionStrengthEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionStrengthSplashExtended, Arrays.asList(potionStrengthSplash, reagentRedstoneDust)); - potionRecipes.put(potionStrengthSplashExtended, Arrays.asList(potionStrengthSplashEnhanced, reagentRedstoneDust)); - potionRecipes.put(potionStrengthSplashExtended, Arrays.asList(potionStrengthExtended, reagentGunpowder)); - - potionRecipes.put(potionThick, Arrays.asList(bottleWater, reagentGlowstoneDust)); - - potionRecipes.put(potionMundane, Arrays.asList(bottleWater, reagentSugar)); - potionRecipes.put(potionMundane, Arrays.asList(bottleWater, reagentGlisteringMelon)); - potionRecipes.put(potionMundane, Arrays.asList(bottleWater, reagentSpiderEye)); - potionRecipes.put(potionMundane, Arrays.asList(bottleWater, reagentBlazePowder)); - potionRecipes.put(potionMundane, Arrays.asList(bottleWater, reagentMagmaCream)); - potionRecipes.put(potionMundane, Arrays.asList(bottleWater, reagentGhastTear)); - potionRecipes.put(potionMundaneSplash, Arrays.asList(potionMundane, reagentGunpowder)); - - potionRecipes.put(potionMundaneExtended, Arrays.asList(bottleWater, reagentRedstoneDust)); - potionRecipes.put(potionMundaneSplashExtended, Arrays.asList(potionMundaneExtended, reagentGunpowder)); - } -} diff --git a/ee3_common/com/pahimar/ee3/item/crafting/RecipesSmelting.java b/ee3_common/com/pahimar/ee3/item/crafting/RecipesSmelting.java deleted file mode 100644 index 21f3e7c0..00000000 --- a/ee3_common/com/pahimar/ee3/item/crafting/RecipesSmelting.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.pahimar.ee3.item.crafting; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.FurnaceRecipes; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import com.pahimar.ee3.core.util.EnergyStack; -import com.pahimar.ee3.item.CustomWrappedStack; - -public class RecipesSmelting { - - private static Multimap> smeltingRecipes = null; - - private static final CustomWrappedStack smeltingEnergy = new CustomWrappedStack(new EnergyStack(EnergyStack.VANILLA_SMELTING_ENERGY_NAME, EnergyStack.VANILLA_SMELTING_ENERGY_THRESHOLD)); - - public static Multimap> getSmeltingRecipes() { - - if (smeltingRecipes == null) { - init(); - } - - return smeltingRecipes; - } - - private static void init() { - - smeltingRecipes = HashMultimap.create(); - - @SuppressWarnings("unchecked") - Map smeltingList = FurnaceRecipes.smelting().getSmeltingList(); - Map, ItemStack> metaSmeltingList = FurnaceRecipes.smelting().getMetaSmeltingList(); - - for (Integer i : smeltingList.keySet()) { - smeltingRecipes.put(new CustomWrappedStack(smeltingList.get(i)), Arrays.asList(smeltingEnergy, new CustomWrappedStack(new ItemStack(i, 1, 0)))); - } - - for (List idMetaPair : metaSmeltingList.keySet()) { - if (idMetaPair.size() == 2) { - smeltingRecipes.put(new CustomWrappedStack(metaSmeltingList.get(idMetaPair)), Arrays.asList(smeltingEnergy, new CustomWrappedStack(new ItemStack(idMetaPair.get(0), 1, idMetaPair.get(1))))); - } - } - } -} diff --git a/ee3_common/com/pahimar/ee3/item/crafting/RecipesVanilla.java b/ee3_common/com/pahimar/ee3/item/crafting/RecipesVanilla.java deleted file mode 100644 index 5b504acb..00000000 --- a/ee3_common/com/pahimar/ee3/item/crafting/RecipesVanilla.java +++ /dev/null @@ -1,49 +0,0 @@ -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 { - - private static Multimap> vanillaRecipes = null; - - ArrayList discoveredItems = new ArrayList(); - - public static Multimap> getVanillaRecipes() { - - if (vanillaRecipes == null) { - init(); - } - - return vanillaRecipes; - } - - private static void init() { - - vanillaRecipes = HashMultimap.create(); - - for (Object recipeObject : CraftingManager.getInstance().getRecipeList()) { - - if (recipeObject instanceof IRecipe) { - - IRecipe recipe = (IRecipe) recipeObject; - ItemStack recipeOutput = recipe.getRecipeOutput(); - - if (recipeOutput != null) { - - ArrayList recipeInputs = RecipeHelper.getRecipeInputs(recipe); - vanillaRecipes.put(new CustomWrappedStack(recipeOutput), recipeInputs); - } - } - } - } -} diff --git a/ee3_common/com/pahimar/ee3/lib/InterModComms.java b/ee3_common/com/pahimar/ee3/lib/InterModComms.java deleted file mode 100644 index c4133e50..00000000 --- a/ee3_common/com/pahimar/ee3/lib/InterModComms.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.pahimar.ee3.lib; - -public class InterModComms { - - // Interacting with the Recipe Registry - public static final String ADD_RECIPE = "add-recipe"; - - // Interacting with the EMC BlackList - public static final String ADD_BLACKLIST_ENTRY = "add-blacklist-entry"; - public static final String REMOVE_BLACKLIST_ENTRY = "remove-blacklist-entry"; - - // Interacting with the EMC value mappings - public static final String SET_EMC_VALUE = "set-emc-value"; -} diff --git a/ee3_common/com/pahimar/ee3/nbt/NBTHelper.java b/ee3_common/com/pahimar/ee3/nbt/NBTHelper.java deleted file mode 100644 index 06e87be5..00000000 --- a/ee3_common/com/pahimar/ee3/nbt/NBTHelper.java +++ /dev/null @@ -1,508 +0,0 @@ -package com.pahimar.ee3.nbt; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagByte; -import net.minecraft.nbt.NBTTagByteArray; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagDouble; -import net.minecraft.nbt.NBTTagEnd; -import net.minecraft.nbt.NBTTagFloat; -import net.minecraft.nbt.NBTTagInt; -import net.minecraft.nbt.NBTTagIntArray; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagLong; -import net.minecraft.nbt.NBTTagShort; -import net.minecraft.nbt.NBTTagString; - -import com.pahimar.ee3.core.util.EnergyStack; -import com.pahimar.ee3.core.util.OreStack; -import com.pahimar.ee3.item.CustomWrappedStack; -import com.pahimar.ee3.lib.Strings; - -/** - * Equivalent-Exchange-3 - * - * NBTHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class NBTHelper { - - /** - * Encodes the given NBT object as a String - * @param nbtBase - * @return String encoding of the given NBT object - */ - public static String encodeNBTAsString(NBTBase nbtBase) { - - StringBuilder stringBuilder = new StringBuilder(); - - if (nbtBase != null) { - // Encode the name of the tag, and the type of the tag - stringBuilder.append(String.format("'%s':%s:", nbtBase.getName(), NBTBase.getTagName(nbtBase.getId()))); - - // Encode the value of the tag, depending on the type of the tag - switch (nbtBase.getId()) - { - case 0: { - stringBuilder.append(((NBTTagEnd) nbtBase).toString()); - break; - } - case 1: { - stringBuilder.append(String.format("%s", ((NBTTagByte) nbtBase).data)); - break; - } - case 2: { - stringBuilder.append(String.format("%s", ((NBTTagShort) nbtBase).data)); - break; - } - case 3: { - stringBuilder.append(String.format("%s", ((NBTTagInt) nbtBase).data)); - break; - } - case 4: { - stringBuilder.append(String.format("%s", ((NBTTagLong) nbtBase).data)); - break; - } - case 5: { - stringBuilder.append(String.format("%s", ((NBTTagFloat) nbtBase).data)); - break; - } - case 6: { - stringBuilder.append(String.format("%s", ((NBTTagDouble) nbtBase).data)); - break; - } - case 7: { - NBTTagByteArray byteArray = (NBTTagByteArray) nbtBase; - - stringBuilder.append("["); - - for (int i = 0; i < byteArray.byteArray.length; i++) { - stringBuilder.append(byteArray.byteArray[i]); - - if (i < byteArray.byteArray.length - 1) { - stringBuilder.append("|"); - } - } - - stringBuilder.append("]"); - - break; - } - case 8: { - stringBuilder.append(String.format("%s", ((NBTTagString) nbtBase).data)); - break; - } - case 9: { - NBTTagList tagList = (NBTTagList) nbtBase; - - stringBuilder.append("["); - - for (int i = 0; i < tagList.tagCount(); i++) { - Object tagObject = tagList.tagAt(i); - - if (tagObject instanceof NBTBase) { - stringBuilder.append(encodeNBTAsString((NBTBase) tagObject)); - } - - if (i < tagList.tagCount() - 1) { - stringBuilder.append("|"); - } - } - - stringBuilder.append("]"); - - break; - } - case 10: { - NBTTagCompound tagCompound = (NBTTagCompound) nbtBase; - - stringBuilder.append("["); - - Iterator tagIterator = tagCompound.getTags().iterator(); - - while (tagIterator.hasNext()) { - Object tagObject = tagIterator.next(); - - if (tagObject instanceof NBTBase) { - stringBuilder.append(encodeNBTAsString((NBTBase) tagObject)); - } - - if (tagIterator.hasNext()) { - stringBuilder.append("|"); - } - } - - stringBuilder.append("]"); - - break; - } - case 11: { - NBTTagIntArray intArray = (NBTTagIntArray) nbtBase; - - stringBuilder.append("["); - - for (int i = 0; i < intArray.intArray.length; i++) { - stringBuilder.append(intArray.intArray[i]); - - if (i < intArray.intArray.length - 1) { - stringBuilder.append("|"); - } - } - - stringBuilder.append("]"); - - break; - } - default: { - stringBuilder.append("UNKNOWN"); - break; - } - } - } - - return stringBuilder.toString(); - } - - // TODO Link this method to some API stuffs - public static NBTTagCompound encodeStackAsNBT(Object stackObject) { - - return encodeStackAsNBT("", stackObject); - } - - public static NBTTagCompound encodeStackAsNBT(String name, Object object) { - - NBTTagCompound encodedStack = new NBTTagCompound(name); - - if (CustomWrappedStack.canBeWrapped(object)) { - - CustomWrappedStack wrappedStack = new CustomWrappedStack(object); - - if (wrappedStack.getWrappedStack() instanceof ItemStack) { - - ItemStack itemStack = (ItemStack) wrappedStack.getWrappedStack(); - encodedStack.setString(Strings.NBT_ENCODED_ATTR_TYPE, Strings.NBT_ENCODED_ATTR_TYPE_ITEM); - itemStack.writeToNBT(encodedStack); - } - else if (wrappedStack.getWrappedStack() instanceof OreStack) { - OreStack oreStack = (OreStack) wrappedStack.getWrappedStack(); - - encodedStack.setString(Strings.NBT_ENCODED_ATTR_TYPE, Strings.NBT_ENCODED_ATTR_TYPE_ORE); - encodedStack.setString(Strings.NBT_ENCODED_ATTR_ORE_NAME, oreStack.oreName); - encodedStack.setShort(Strings.NBT_ENCODED_ATTR_SIZE, (short) wrappedStack.getStackSize()); - } - else if (wrappedStack.getWrappedStack() instanceof EnergyStack) { - EnergyStack energyStack = (EnergyStack) wrappedStack.getWrappedStack(); - - encodedStack.setString(Strings.NBT_ENCODED_ATTR_TYPE, Strings.NBT_ENCODED_ATTR_TYPE_ENERGY); - encodedStack.setString(Strings.NBT_ENCODED_ATTR_ENERGY_NAME, energyStack.energyName); - encodedStack.setShort(Strings.NBT_ENCODED_ATTR_SIZE, (short) wrappedStack.getStackSize()); - } - } - - return encodedStack; - } - - public static NBTTagCompound encodeRecipeAsNBT(Object recipeOutput, List recipeInputs) { - - NBTTagCompound encodedRecipe = new NBTTagCompound(); - - NBTTagCompound recipeOutputNBTCompound = encodeStackAsNBT(Strings.NBT_ENCODED_RECIPE_OUTPUT, recipeOutput); - NBTTagList recipeInputsNBTList = new NBTTagList(Strings.NBT_ENCODED_RECIPE_INPUTS); - - for (int i = 0; i < recipeInputs.size(); i++) { - recipeInputsNBTList.appendTag(encodeStackAsNBT(Strings.NBT_ENCODED_RECIPE_INPUT_PREFIX.concat(Integer.toString(i)), recipeInputs.get(i))); - } - - encodedRecipe.setCompoundTag(Strings.NBT_ENCODED_RECIPE_OUTPUT, recipeOutputNBTCompound); - encodedRecipe.setTag(Strings.NBT_ENCODED_RECIPE_INPUTS, recipeInputsNBTList); - - return encodedRecipe; - } - - /** - * - * @param encodedStack - * A NBTTagCompound containing the encoded information of either - * a ItemStack, OreStack, or EnergyStack - * @return A CustomWrappedStack containing the encoded stack provided in the - * NBTTagCompound (could be ItemStack, OreStack, or EnergyStack). - * Returns null in the event that no valid stack was able to be - * parsed from the encoded NBTTagCompound. - */ - public static CustomWrappedStack decodeStackFromNBT(NBTTagCompound encodedStack) { - - CustomWrappedStack decodedStack = null; - - // If the encoded tag compound is of type ItemStack, parse out the ItemStack info - if (encodedStack.hasKey(Strings.NBT_ENCODED_ATTR_TYPE)) { - if (encodedStack.getString(Strings.NBT_ENCODED_ATTR_TYPE).equalsIgnoreCase(Strings.NBT_ENCODED_ATTR_TYPE_ITEM)) { - - ItemStack itemStack = new ItemStack(0, 0, 0); - itemStack.readFromNBT(encodedStack); - decodedStack = new CustomWrappedStack(itemStack); - } - // Else if the encoded tag compound is of type OreStack, parse out the OreStack info - else if (encodedStack.getString(Strings.NBT_ENCODED_ATTR_TYPE).equalsIgnoreCase(Strings.NBT_ENCODED_ATTR_TYPE_ORE)) { - - if (encodedStack.hasKey(Strings.NBT_ENCODED_ATTR_ORE_NAME) && encodedStack.hasKey(Strings.NBT_ENCODED_ATTR_SIZE)) { - if ((encodedStack.getString(Strings.NBT_ENCODED_ATTR_ORE_NAME).length() > 0) && (encodedStack.getShort(Strings.NBT_ENCODED_ATTR_SIZE) >= 0)) { - decodedStack = new CustomWrappedStack(new OreStack(encodedStack.getString(Strings.NBT_ENCODED_ATTR_ORE_NAME), encodedStack.getShort(Strings.NBT_ENCODED_ATTR_SIZE))); - } - } - } - // Else if the encoded tag compound is of type EnergyStack, parse out the EnergyStack info - else if (encodedStack.getString(Strings.NBT_ENCODED_ATTR_TYPE).equalsIgnoreCase(Strings.NBT_ENCODED_ATTR_TYPE_ENERGY)) { - - if (encodedStack.hasKey(Strings.NBT_ENCODED_ATTR_ENERGY_NAME) && encodedStack.hasKey(Strings.NBT_ENCODED_ATTR_SIZE)) { - if ((encodedStack.getString(Strings.NBT_ENCODED_ATTR_ENERGY_NAME).length() > 0) && (encodedStack.getShort(Strings.NBT_ENCODED_ATTR_SIZE) >= 0)) { - decodedStack = new CustomWrappedStack(new EnergyStack(encodedStack.getString(Strings.NBT_ENCODED_ATTR_ENERGY_NAME), encodedStack.getShort(Strings.NBT_ENCODED_ATTR_SIZE))); - } - } - } - } - - /* - * This will only return non-null in the event that a proper - * ItemStack|OreStack|EnergyStack was decoded from the encoded - * NBTTagCompound - */ - return decodedStack; - } - - public static Map> decodeRecipeFromNBT(NBTTagCompound encodedRecipe) { - - HashMap> decodedRecipe = new HashMap>(); - - CustomWrappedStack recipeOutput = null; - ArrayList recipeInputs = new ArrayList(); - - CustomWrappedStack decodedStack = null; - NBTTagCompound encodedStack = null; - - // Decode the recipe output - if (encodedRecipe.hasKey(Strings.NBT_ENCODED_RECIPE_OUTPUT)) { - - decodedStack = decodeStackFromNBT(encodedRecipe.getCompoundTag(Strings.NBT_ENCODED_RECIPE_OUTPUT)); - - if (decodedStack != null) { - recipeOutput = decodedStack; - } - } - - // Decode the recipe inputs - if (encodedRecipe.hasKey("recipeInputs")) { - NBTTagList recipeInputsTagList = encodedRecipe.getTagList(Strings.NBT_ENCODED_RECIPE_INPUTS); - - for (int i = 0; i < recipeInputsTagList.tagCount(); i++) { - if (recipeInputsTagList.tagAt(i) instanceof NBTTagCompound) { - - encodedStack = (NBTTagCompound) recipeInputsTagList.tagAt(i); - decodedStack = decodeStackFromNBT(encodedStack); - - if (decodedStack != null) { - recipeInputs.add(decodedStack); - } - } - } - } - - // If we decoded both a recipe output and some inputs for it, add it to the map - if (recipeOutput != null && recipeInputs.size() > 0) { - decodedRecipe.put(recipeOutput, recipeInputs); - } - - return decodedRecipe; - } - - /** - * Initializes the NBT Tag Compound for the given ItemStack if it is null - * - * @param itemStack - * The ItemStack for which its NBT Tag Compound is being checked - * for initialization - */ - private static void initNBTTagCompound(ItemStack itemStack) { - - if (itemStack.stackTagCompound == null) { - itemStack.setTagCompound(new NBTTagCompound()); - } - } - - public static boolean hasTag(ItemStack itemStack, String keyName) { - - if (itemStack.stackTagCompound != null) - return itemStack.stackTagCompound.hasKey(keyName); - - return false; - } - - public static void removeTag(ItemStack itemStack, String keyName) { - - if (itemStack.stackTagCompound != null) { - itemStack.stackTagCompound.removeTag(keyName); - } - } - - // String - public static String getString(ItemStack itemStack, String keyName) { - - initNBTTagCompound(itemStack); - - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setString(itemStack, keyName, ""); - } - - return itemStack.stackTagCompound.getString(keyName); - } - - public static void setString(ItemStack itemStack, String keyName, String keyValue) { - - initNBTTagCompound(itemStack); - - itemStack.stackTagCompound.setString(keyName, keyValue); - } - - // boolean - public static boolean getBoolean(ItemStack itemStack, String keyName) { - - initNBTTagCompound(itemStack); - - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setBoolean(itemStack, keyName, false); - } - - return itemStack.stackTagCompound.getBoolean(keyName); - } - - public static void setBoolean(ItemStack itemStack, String keyName, boolean keyValue) { - - initNBTTagCompound(itemStack); - - itemStack.stackTagCompound.setBoolean(keyName, keyValue); - } - - // byte - public static byte getByte(ItemStack itemStack, String keyName) { - - initNBTTagCompound(itemStack); - - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setByte(itemStack, keyName, (byte) 0); - } - - return itemStack.stackTagCompound.getByte(keyName); - } - - public static void setByte(ItemStack itemStack, String keyName, byte keyValue) { - - initNBTTagCompound(itemStack); - - itemStack.stackTagCompound.setByte(keyName, keyValue); - } - - // short - public static short getShort(ItemStack itemStack, String keyName) { - - initNBTTagCompound(itemStack); - - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setShort(itemStack, keyName, (short) 0); - } - - return itemStack.stackTagCompound.getShort(keyName); - } - - public static void setShort(ItemStack itemStack, String keyName, short keyValue) { - - initNBTTagCompound(itemStack); - - itemStack.stackTagCompound.setShort(keyName, keyValue); - } - - // int - public static int getInt(ItemStack itemStack, String keyName) { - - initNBTTagCompound(itemStack); - - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setInteger(itemStack, keyName, 0); - } - - return itemStack.stackTagCompound.getInteger(keyName); - } - - public static void setInteger(ItemStack itemStack, String keyName, int keyValue) { - - initNBTTagCompound(itemStack); - - itemStack.stackTagCompound.setInteger(keyName, keyValue); - } - - // long - public static long getLong(ItemStack itemStack, String keyName) { - - initNBTTagCompound(itemStack); - - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setLong(itemStack, keyName, 0); - } - - return itemStack.stackTagCompound.getLong(keyName); - } - - public static void setLong(ItemStack itemStack, String keyName, long keyValue) { - - initNBTTagCompound(itemStack); - - itemStack.stackTagCompound.setLong(keyName, keyValue); - } - - // float - public static float getFloat(ItemStack itemStack, String keyName) { - - initNBTTagCompound(itemStack); - - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setFloat(itemStack, keyName, 0); - } - - return itemStack.stackTagCompound.getFloat(keyName); - } - - public static void setFloat(ItemStack itemStack, String keyName, float keyValue) { - - initNBTTagCompound(itemStack); - - itemStack.stackTagCompound.setFloat(keyName, keyValue); - } - - // double - public static double getDouble(ItemStack itemStack, String keyName) { - - initNBTTagCompound(itemStack); - - if (!itemStack.stackTagCompound.hasKey(keyName)) { - setDouble(itemStack, keyName, 0); - } - - return itemStack.stackTagCompound.getDouble(keyName); - } - - public static void setDouble(ItemStack itemStack, String keyName, double keyValue) { - - initNBTTagCompound(itemStack); - - itemStack.stackTagCompound.setDouble(keyName, keyValue); - } - -} diff --git a/ee3_common/com/pahimar/ee3/network/packet/PacketTileWithItemUpdate.java b/ee3_common/com/pahimar/ee3/network/packet/PacketTileWithItemUpdate.java deleted file mode 100644 index 0fc0193b..00000000 --- a/ee3_common/com/pahimar/ee3/network/packet/PacketTileWithItemUpdate.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.pahimar.ee3.network.packet; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import net.minecraft.network.INetworkManager; -import net.minecraftforge.common.ForgeDirection; - -import com.pahimar.ee3.EquivalentExchange3; -import com.pahimar.ee3.network.PacketTypeHandler; - -import cpw.mods.fml.common.network.Player; - -public class PacketTileWithItemUpdate extends PacketEE { - - public int x, y, z; - public byte orientation; - public byte state; - public String customName; - public int itemID, metaData, stackSize, color; - - public PacketTileWithItemUpdate() { - - super(PacketTypeHandler.TILE_WITH_ITEM, true); - } - - public PacketTileWithItemUpdate(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color) { - - super(PacketTypeHandler.TILE_WITH_ITEM, true); - this.x = x; - this.y = y; - this.z = z; - this.orientation = (byte) orientation.ordinal(); - this.state = state; - this.customName = customName; - this.itemID = itemID; - this.metaData = metaData; - this.stackSize = stackSize; - this.color = color; - } - - @Override - public void writeData(DataOutputStream data) throws IOException { - - data.writeInt(x); - data.writeInt(y); - data.writeInt(z); - data.writeByte(orientation); - data.writeByte(state); - data.writeUTF(customName); - data.writeInt(itemID); - data.writeInt(metaData); - data.writeInt(stackSize); - data.writeInt(color); - } - - @Override - public void readData(DataInputStream data) throws IOException { - - x = data.readInt(); - y = data.readInt(); - z = data.readInt(); - orientation = data.readByte(); - state = data.readByte(); - customName = data.readUTF(); - itemID = data.readInt(); - metaData = data.readInt(); - stackSize = data.readInt(); - color = data.readInt(); - } - - @Override - public void execute(INetworkManager manager, Player player) { - - EquivalentExchange3.proxy.handleTileWithItemPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName, itemID, metaData, stackSize, color); - } -}