Thought I would have gotten more done at work today :)

This commit is contained in:
pahimar 2013-12-20 15:53:37 -05:00
parent f0b08b431f
commit 3be12ee169
8 changed files with 35 additions and 24 deletions

View file

@ -226,4 +226,8 @@ public class AddonIndustrialCraft2
return null; return null;
} }
/***
* TODO Investigate ways to scope out IC2 recipes and auto-add them
*/
} }

View file

@ -76,11 +76,12 @@ public class OreStack implements Comparable<OreStack>
* *
* @return The OreStack that was encoded as json, or null if a valid OreStack could not be decoded from given String * @return The OreStack that was encoded as json, or null if a valid OreStack could not be decoded from given String
*/ */
@SuppressWarnings("unused")
public static OreStack createFromJson(String jsonOreStack) public static OreStack createFromJson(String jsonOreStack)
{ {
try try
{ {
return (OreStack) gsonSerializer.fromJson(jsonOreStack, OreStack.class); return gsonSerializer.fromJson(jsonOreStack, OreStack.class);
} }
catch (JsonSyntaxException exception) catch (JsonSyntaxException exception)
{ {
@ -99,6 +100,7 @@ public class OreStack implements Comparable<OreStack>
* *
* @return Json serialized String of this OreStack * @return Json serialized String of this OreStack
*/ */
@SuppressWarnings("unused")
public String toJson() public String toJson()
{ {
return gsonSerializer.toJson(this); return gsonSerializer.toJson(this);

View file

@ -126,6 +126,6 @@ public class RecipeMapping implements JsonSerializer<RecipeMapping>, JsonDeseria
@Override @Override
public String toString() public String toString()
{ {
return String.format("Output: %s, Input: %s", outputWrappedStack, inputWrappedStacks); return String.format("RecipeMapping[Output: %s, Input: %s]", outputWrappedStack, inputWrappedStacks);
} }
} }

View file

@ -93,7 +93,7 @@ public class StackValueMapping implements JsonSerializer<StackValueMapping>, Jso
emcValue = new EmcValue().deserialize(jsonStackValueMapping.get("emcValue").getAsJsonObject(), type, context); emcValue = new EmcValue().deserialize(jsonStackValueMapping.get("emcValue").getAsJsonObject(), type, context);
} }
if (wrappedStack instanceof WrappedStack && emcValue instanceof EmcValue) if (wrappedStack != null && emcValue != null)
{ {
return new StackValueMapping(wrappedStack, emcValue); return new StackValueMapping(wrappedStack, emcValue);
} }

View file

@ -1,6 +1,7 @@
package com.pahimar.ee3.emc; package com.pahimar.ee3.emc;
import com.google.gson.*; import com.google.gson.*;
import com.pahimar.ee3.helper.LogHelper;
import com.pahimar.ee3.lib.Compare; import com.pahimar.ee3.lib.Compare;
import java.lang.reflect.Type; import java.lang.reflect.Type;
@ -17,7 +18,6 @@ import java.util.List;
*/ */
public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue>, JsonSerializer<EmcValue> public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue>, JsonSerializer<EmcValue>
{ {
// Gson serializer for serializing to/deserializing from json // Gson serializer for serializing to/deserializing from json
private static final Gson gsonSerializer = (new GsonBuilder()).registerTypeAdapter(EmcValue.class, new EmcValue()).create(); private static final Gson gsonSerializer = (new GsonBuilder()).registerTypeAdapter(EmcValue.class, new EmcValue()).create();
@ -25,44 +25,37 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
public EmcValue() public EmcValue()
{ {
this(new float[EmcType.TYPES.length]); this(new float[EmcType.TYPES.length]);
} }
public EmcValue(int value) public EmcValue(int value)
{ {
this((float) value); this((float) value);
} }
public EmcValue(float value) public EmcValue(float value)
{ {
this(value, EmcType.DEFAULT); this(value, EmcType.DEFAULT);
} }
public EmcValue(float value, EmcComponent component) public EmcValue(float value, EmcComponent component)
{ {
this(value, component.type); this(value, component.type);
} }
public EmcValue(int value, EmcType emcType) public EmcValue(int value, EmcType emcType)
{ {
this((float) value, emcType); this((float) value, emcType);
} }
public EmcValue(float value, EmcType emcType) public EmcValue(float value, EmcType emcType)
{ {
this.components = new float[EmcType.TYPES.length]; this.components = new float[EmcType.TYPES.length];
this.components[emcType.ordinal()] = value; this.components[emcType.ordinal()] = value;
} }
public EmcValue(float[] components) public EmcValue(float[] components)
{ {
this.components = components; this.components = components;
} }
@ -193,7 +186,11 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
} }
catch (JsonSyntaxException exception) catch (JsonSyntaxException exception)
{ {
// TODO Log something regarding the failed parse LogHelper.severe(exception.getMessage());
}
catch (JsonParseException exception)
{
LogHelper.severe(exception.getMessage());
} }
return null; return null;
@ -206,13 +203,11 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
*/ */
public String toJson() public String toJson()
{ {
return gsonSerializer.toJson(this); return gsonSerializer.toJson(this);
} }
private static List<EmcComponent> collateComponents(List<EmcComponent> uncollatedComponents) private static List<EmcComponent> collateComponents(List<EmcComponent> uncollatedComponents)
{ {
Integer[] componentCount = new Integer[EmcType.TYPES.length]; Integer[] componentCount = new Integer[EmcType.TYPES.length];
for (EmcComponent emcComponent : uncollatedComponents) for (EmcComponent emcComponent : uncollatedComponents)
@ -245,7 +240,6 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
private static int compareComponents(float[] first, float[] second) private static int compareComponents(float[] first, float[] second)
{ {
if (first.length == EmcType.TYPES.length && second.length == EmcType.TYPES.length) if (first.length == EmcType.TYPES.length && second.length == EmcType.TYPES.length)
{ {
@ -268,7 +262,6 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
@Override @Override
public JsonElement serialize(EmcValue emcValue, Type type, JsonSerializationContext context) public JsonElement serialize(EmcValue emcValue, Type type, JsonSerializationContext context)
{ {
JsonObject jsonEmcValue = new JsonObject(); JsonObject jsonEmcValue = new JsonObject();
for (EmcType emcType : EmcType.TYPES) for (EmcType emcType : EmcType.TYPES)

View file

@ -132,6 +132,11 @@ public class ItemAlchemicalDust extends ItemEE
{ {
List<ItemStack> alchemicalDustStacks = new ArrayList<ItemStack>(); List<ItemStack> alchemicalDustStacks = new ArrayList<ItemStack>();
for (int meta = 0; meta < ALCHEMICAL_DUST_NAMES.length; meta++)
{
alchemicalDustStacks.add(new ItemStack(ModItems.alchemicalDust, 1, meta));
}
return alchemicalDustStacks; return alchemicalDustStacks;
} }
} }

View file

@ -17,13 +17,13 @@ import net.minecraft.item.ItemStack;
public class ModItems public class ModItems
{ {
// Mod item instances // Mod item instances
public static Item miniumShard; public static ItemEE miniumShard;
public static Item inertStone; public static ItemEE inertStone;
public static Item miniumStone; public static ItemEE miniumStone;
public static Item philStone; public static ItemEE philStone;
public static Item alchemicalDust; public static ItemEE alchemicalDust;
public static Item alchemicalBag; public static ItemEE alchemicalBag;
public static Item alchemicalChalk; public static ItemEE alchemicalChalk;
public static void init() public static void init()
{ {

View file

@ -2,6 +2,9 @@ package com.pahimar.ee3.recipe;
import com.pahimar.ee3.emc.EmcRegistry; import com.pahimar.ee3.emc.EmcRegistry;
import com.pahimar.ee3.emc.EmcValue; import com.pahimar.ee3.emc.EmcValue;
import com.pahimar.ee3.helper.ItemHelper;
import com.pahimar.ee3.helper.LogHelper;
import com.pahimar.ee3.item.ModItems;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
@ -24,7 +27,11 @@ public class CalcinationManager
if (emcValue != null) if (emcValue != null)
{ {
// TODO The magic happens here // TODO Get EmcValue of itemStack, add it list of EmcValues of the different dusts, sort it, determine position, and determine result from that
for (ItemStack alchemicalDustStack : ModItems.alchemicalDust.getSubTypes())
{
LogHelper.debug(ItemHelper.toString(alchemicalDustStack));
}
} }
return calcinationResults; return calcinationResults;