Reverting out last MCPC+ bugfix changes - looks like the bug is best resolved on MCPC+'s side (marking ItemStack.EntityItemFrame as transient, and so preventing gson'd ItemStacks from overflowing the stack)

This commit is contained in:
pahimar 2013-12-31 03:42:32 -05:00
parent 4caf4e1237
commit 4abd5b121a
3 changed files with 3 additions and 89 deletions

View file

@ -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<WrappedStack>, 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<WrappedStack>, 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)
{

View file

@ -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

View file

@ -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<ItemStack>, JsonSerializer<ItemStack>
{
@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;
}
}