diff --git a/src/main/java/com/pahimar/ee3/api/WrappedStack.java b/src/main/java/com/pahimar/ee3/api/WrappedStack.java index 16767253..4789b1f6 100644 --- a/src/main/java/com/pahimar/ee3/api/WrappedStack.java +++ b/src/main/java/com/pahimar/ee3/api/WrappedStack.java @@ -2,7 +2,6 @@ package com.pahimar.ee3.api; import com.google.gson.*; import com.pahimar.ee3.helper.FluidHelper; -import com.pahimar.ee3.helper.GsonItemStackSerialization; import com.pahimar.ee3.helper.ItemHelper; import com.pahimar.ee3.helper.LogHelper; import com.pahimar.ee3.lib.Compare; @@ -457,8 +456,7 @@ public class WrappedStack implements Comparable, JsonDeserializer< if (wrappedStack.wrappedStack instanceof ItemStack) { - Gson gsonItemStackSerializer = (new GsonBuilder()).registerTypeAdapter(ItemStack.class, new GsonItemStackSerialization()).create(); - jsonWrappedStack.add("wrappedStack", gsonItemStackSerializer.toJsonTree(wrappedStack.wrappedStack, ItemStack.class)); + jsonWrappedStack.add("wrappedStack", gsonWrappedStack.toJsonTree(wrappedStack.wrappedStack, ItemStack.class)); } else if (wrappedStack.wrappedStack instanceof OreStack) { @@ -506,8 +504,7 @@ public class WrappedStack implements Comparable, JsonDeserializer< { if (className.equalsIgnoreCase(ItemStack.class.getSimpleName())) { - Gson gsonItemStackSerializer = (new GsonBuilder()).registerTypeAdapter(ItemStack.class, new GsonItemStackSerialization()).create(); - ItemStack itemStack = gsonItemStackSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), ItemStack.class); + ItemStack itemStack = gsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), ItemStack.class); if (stackSize > 0) { diff --git a/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java b/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java index c90673ac..33f8f63f 100644 --- a/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java +++ b/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java @@ -21,7 +21,7 @@ import java.text.DecimalFormat; @SideOnly(Side.CLIENT) public class ItemTooltipEventHandler { - private static boolean debug = true; + private static boolean debug = false; private static DecimalFormat emcDecimalFormat = new DecimalFormat("#.###"); @ForgeSubscribe diff --git a/src/main/java/com/pahimar/ee3/helper/GsonItemStackSerialization.java b/src/main/java/com/pahimar/ee3/helper/GsonItemStackSerialization.java deleted file mode 100644 index c45b1b6a..00000000 --- a/src/main/java/com/pahimar/ee3/helper/GsonItemStackSerialization.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.pahimar.ee3.helper; - -import com.google.gson.*; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.lang.reflect.Type; - -public class GsonItemStackSerialization implements JsonDeserializer, JsonSerializer -{ - @Override - public ItemStack deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException - { - if (!jsonElement.isJsonPrimitive()) - { - JsonObject jsonItemStack = (JsonObject) jsonElement; - - int stackSize = -1; - int itemID = -1; - Integer itemDamage = null; - NBTTagCompound stackTagCompound = null; - - if (jsonItemStack.get("stackSize") != null) - { - stackSize = jsonItemStack.get("stackSize").getAsInt(); - } - - if (jsonItemStack.get("itemID") != null) - { - itemID = jsonItemStack.get("itemID").getAsInt(); - } - - if (jsonItemStack.get("itemDamage") != null) - { - itemDamage = jsonItemStack.get("itemDamage").getAsInt(); - } - - if (jsonItemStack.get("stackTagCompound") != null && !jsonItemStack.get("stackTagCompound").isJsonPrimitive()) - { - stackTagCompound = new Gson().fromJson(jsonItemStack.get("stackTagCompound"), NBTTagCompound.class); - } - - if (stackSize != -1 && itemID != -1) - { - ItemStack itemStack; - - if (itemDamage != null) - { - itemStack = new ItemStack(itemID, stackSize, itemDamage); - } - else - { - itemStack = new ItemStack(itemID, stackSize, 0); - } - - if (stackTagCompound != null) - { - itemStack.setTagCompound(stackTagCompound); - } - - return itemStack; - } - } - - return null; - } - - @Override - public JsonElement serialize(ItemStack itemStack, Type type, JsonSerializationContext context) - { - JsonObject jsonItemStack = new JsonObject(); - - if (itemStack != null) - { - jsonItemStack.addProperty("stackSize", itemStack.stackSize); - jsonItemStack.addProperty("itemID", itemStack.itemID); - jsonItemStack.addProperty("itemDamage", itemStack.getItemDamage()); - jsonItemStack.add("stackTagCompound", new Gson().toJsonTree(itemStack.getTagCompound())); - } - - return jsonItemStack; - } -}