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:
parent
4caf4e1237
commit
4abd5b121a
3 changed files with 3 additions and 89 deletions
|
@ -2,7 +2,6 @@ package com.pahimar.ee3.api;
|
||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import com.pahimar.ee3.helper.FluidHelper;
|
import com.pahimar.ee3.helper.FluidHelper;
|
||||||
import com.pahimar.ee3.helper.GsonItemStackSerialization;
|
|
||||||
import com.pahimar.ee3.helper.ItemHelper;
|
import com.pahimar.ee3.helper.ItemHelper;
|
||||||
import com.pahimar.ee3.helper.LogHelper;
|
import com.pahimar.ee3.helper.LogHelper;
|
||||||
import com.pahimar.ee3.lib.Compare;
|
import com.pahimar.ee3.lib.Compare;
|
||||||
|
@ -457,8 +456,7 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
||||||
|
|
||||||
if (wrappedStack.wrappedStack instanceof ItemStack)
|
if (wrappedStack.wrappedStack instanceof ItemStack)
|
||||||
{
|
{
|
||||||
Gson gsonItemStackSerializer = (new GsonBuilder()).registerTypeAdapter(ItemStack.class, new GsonItemStackSerialization()).create();
|
jsonWrappedStack.add("wrappedStack", gsonWrappedStack.toJsonTree(wrappedStack.wrappedStack, ItemStack.class));
|
||||||
jsonWrappedStack.add("wrappedStack", gsonItemStackSerializer.toJsonTree(wrappedStack.wrappedStack, ItemStack.class));
|
|
||||||
}
|
}
|
||||||
else if (wrappedStack.wrappedStack instanceof OreStack)
|
else if (wrappedStack.wrappedStack instanceof OreStack)
|
||||||
{
|
{
|
||||||
|
@ -506,8 +504,7 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
||||||
{
|
{
|
||||||
if (className.equalsIgnoreCase(ItemStack.class.getSimpleName()))
|
if (className.equalsIgnoreCase(ItemStack.class.getSimpleName()))
|
||||||
{
|
{
|
||||||
Gson gsonItemStackSerializer = (new GsonBuilder()).registerTypeAdapter(ItemStack.class, new GsonItemStackSerialization()).create();
|
ItemStack itemStack = gsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), ItemStack.class);
|
||||||
ItemStack itemStack = gsonItemStackSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), ItemStack.class);
|
|
||||||
|
|
||||||
if (stackSize > 0)
|
if (stackSize > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.text.DecimalFormat;
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class ItemTooltipEventHandler
|
public class ItemTooltipEventHandler
|
||||||
{
|
{
|
||||||
private static boolean debug = true;
|
private static boolean debug = false;
|
||||||
private static DecimalFormat emcDecimalFormat = new DecimalFormat("#.###");
|
private static DecimalFormat emcDecimalFormat = new DecimalFormat("#.###");
|
||||||
|
|
||||||
@ForgeSubscribe
|
@ForgeSubscribe
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue