More incomplete stuff
This commit is contained in:
parent
89c5bf4f33
commit
b2581ac65c
|
@ -16,6 +16,7 @@ import com.pahimar.ee3.recipe.RecipesAludel;
|
|||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Reference;
|
||||
import com.pahimar.ee3.util.LogHelper;
|
||||
import com.pahimar.ee3.util.NBTHelper;
|
||||
import com.pahimar.ee3.util.SerializationHelper;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
|
@ -26,6 +27,7 @@ import cpw.mods.fml.common.event.*;
|
|||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -112,6 +114,9 @@ public class EquivalentExchange3
|
|||
transmutationKnowledge.learnTransmutation(Items.apple);
|
||||
transmutationKnowledge.learnTransmutation(Items.arrow);
|
||||
transmutationKnowledge.learnTransmutation(Items.baked_potato);
|
||||
ItemStack testStack = new ItemStack(Items.blaze_powder);
|
||||
NBTHelper.setString(testStack, "test_string", "This is a test string");
|
||||
transmutationKnowledge.learnTransmutation(testStack);
|
||||
LogHelper.info(transmutationKnowledge.toJson());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package com.pahimar.ee3.exchange;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class JsonItemStack
|
||||
{
|
||||
public String itemName;
|
||||
public int itemDamage;
|
||||
public int stackSize;
|
||||
public byte[] compressedStackTagCompound;
|
||||
public NBTTagCompound nbtTagCompound;
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package com.pahimar.ee3.exchange;
|
||||
|
||||
public class JsonUnitItemStack
|
||||
{
|
||||
public String itemName;
|
||||
public int itemDamage;
|
||||
public byte[] compressedStackTagCompound;
|
||||
}
|
|
@ -6,13 +6,10 @@ import com.pahimar.ee3.util.ItemHelper;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
|
@ -401,16 +398,9 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
|||
if (stackSize > 0 && item != null)
|
||||
{
|
||||
itemStack = new ItemStack(item, stackSize, jsonItemStack.itemDamage);
|
||||
if (jsonItemStack.compressedStackTagCompound != null)
|
||||
if (jsonItemStack.nbtTagCompound != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
itemStack.stackTagCompound = CompressedStreamTools.readCompressed(new ByteArrayInputStream(jsonItemStack.compressedStackTagCompound));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
itemStack.stackTagCompound = jsonItemStack.nbtTagCompound;
|
||||
}
|
||||
}
|
||||
stackObject = itemStack;
|
||||
|
@ -483,17 +473,9 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
|
|||
JsonItemStack jsonItemStack = new JsonItemStack();
|
||||
jsonItemStack.itemName = Item.itemRegistry.getNameForObject(((ItemStack) wrappedStack.wrappedStack).getItem());
|
||||
jsonItemStack.itemDamage = ((ItemStack) wrappedStack.wrappedStack).getItemDamage();
|
||||
jsonItemStack.stackSize = ((ItemStack) wrappedStack.wrappedStack).stackSize;
|
||||
if (((ItemStack) wrappedStack.wrappedStack).stackTagCompound != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
jsonItemStack.compressedStackTagCompound = CompressedStreamTools.compress(((ItemStack) wrappedStack.wrappedStack).stackTagCompound);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
jsonItemStack.nbtTagCompound = ((ItemStack) wrappedStack.wrappedStack).stackTagCompound;
|
||||
}
|
||||
jsonWrappedStack.add("data", gson.toJsonTree(jsonItemStack, JsonItemStack.class));
|
||||
}
|
||||
|
|
|
@ -61,6 +61,6 @@ public class KnowledgeRegistry
|
|||
|
||||
public void savePlayerKnowledgeToDisk(EntityPlayer entityPlayer)
|
||||
{
|
||||
SerializationHelper.writeNBTToFile(knowledgeDirectory, entityPlayer.getUniqueID().toString() + ".transmutation", playerKnowledgeMap.get(entityPlayer.getUniqueID()));
|
||||
SerializationHelper.writeNBTToFile(knowledgeDirectory, entityPlayer.getUniqueID().toString() + ".json", playerKnowledgeMap.get(entityPlayer.getUniqueID()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
package com.pahimar.ee3.knowledge;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.pahimar.ee3.exchange.JsonUnitItemStack;
|
||||
import com.pahimar.ee3.exchange.JsonItemStack;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.util.INBTTaggable;
|
||||
import com.pahimar.ee3.util.ItemHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -213,20 +211,14 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
|
||||
for (ItemStack itemStack : transmutationKnowledge.getKnownTransmutations())
|
||||
{
|
||||
JsonUnitItemStack jsonUnitItemStack = new JsonUnitItemStack();
|
||||
jsonUnitItemStack.itemName = Item.itemRegistry.getNameForObject(itemStack.getItem());
|
||||
jsonUnitItemStack.itemDamage = itemStack.getItemDamage();
|
||||
JsonItemStack jsonItemStack = new JsonItemStack();
|
||||
jsonItemStack.itemName = Item.itemRegistry.getNameForObject(itemStack.getItem());
|
||||
jsonItemStack.itemDamage = itemStack.getItemDamage();
|
||||
if (itemStack.stackTagCompound != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
jsonUnitItemStack.compressedStackTagCompound = CompressedStreamTools.compress(itemStack.stackTagCompound);
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
jsonItemStack.nbtTagCompound = itemStack.getTagCompound();
|
||||
}
|
||||
jsonTransmutationKnowledge.add(gson.toJsonTree(jsonUnitItemStack));
|
||||
jsonTransmutationKnowledge.add(gson.toJsonTree(jsonItemStack));
|
||||
}
|
||||
|
||||
return jsonTransmutationKnowledge;
|
||||
|
|
Loading…
Reference in a new issue