Moving some things around, and may have fixed the Gson issue with MCPC+

This commit is contained in:
pahimar 2013-12-31 01:24:35 -05:00
parent 458ec07c21
commit e0a2395c72
13 changed files with 91 additions and 44 deletions

View file

@ -106,7 +106,6 @@ public class RecipeMapping implements JsonSerializer<RecipeMapping>, JsonDeseria
@Override
public JsonElement serialize(RecipeMapping recipeMapping, Type type, JsonSerializationContext context)
{
JsonObject jsonRecipeMapping = new JsonObject();
Gson gsonWrappedStack = (new GsonBuilder()).registerTypeAdapter(WrappedStack.class, new WrappedStack()).create();

View file

@ -16,10 +16,8 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class WrappedStack
implements Comparable<WrappedStack>, JsonDeserializer<WrappedStack>
public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<WrappedStack>, JsonSerializer<WrappedStack>
{
private static final Gson gsonSerializer = (new GsonBuilder()).registerTypeAdapter(WrappedStack.class, new WrappedStack()).create();
@SuppressWarnings("unused")
@ -245,7 +243,7 @@ public class WrappedStack
if (wrappedStack != null && wrappedStack.getWrappedStack() != null)
{
className = wrappedStack.getWrappedStack().getClass().getSimpleName();
className = wrappedStack.wrappedStack.getClass().getSimpleName();
this.stackSize = stackSize;
this.wrappedStack = wrappedStack.wrappedStack;
}
@ -300,6 +298,7 @@ public class WrappedStack
return null;
}
@SuppressWarnings("unused")
public String toJson()
{
return gsonSerializer.toJson(this);
@ -445,6 +444,27 @@ public class WrappedStack
return false;
}
@Override
public JsonElement serialize(WrappedStack wrappedStack, Type type, JsonSerializationContext context)
{
JsonObject jsonWrappedStack = new JsonObject();
Gson gsonWrappedStack = new Gson();
jsonWrappedStack.addProperty("className", wrappedStack.className);
jsonWrappedStack.addProperty("stackSize", wrappedStack.stackSize);
if (gsonWrappedStack != null)
{
jsonWrappedStack.add("wrappedStack", gsonWrappedStack.toJsonTree(wrappedStack.wrappedStack));
}
else
{
jsonWrappedStack.add("wrappedStack", JsonNull.INSTANCE);
}
return jsonWrappedStack;
}
/**
*
*/

View file

@ -4,8 +4,8 @@ import com.google.common.collect.ImmutableSortedMap;
import com.pahimar.ee3.api.OreStack;
import com.pahimar.ee3.api.WrappedStack;
import com.pahimar.ee3.helper.EmcHelper;
import com.pahimar.ee3.item.crafting.RecipeRegistry;
import com.pahimar.ee3.lib.Compare;
import com.pahimar.ee3.recipe.RecipeRegistry;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

View file

@ -1,20 +1,16 @@
package com.pahimar.ee3.handler;
import com.pahimar.ee3.block.ModBlocks;
import com.pahimar.ee3.configuration.ConfigurationSettings;
import com.pahimar.ee3.helper.ItemStackNBTHelper;
import com.pahimar.ee3.item.ModItems;
import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
import com.pahimar.ee3.item.crafting.RecipesEquivalentExchange;
import com.pahimar.ee3.lib.Strings;
import cpw.mods.fml.common.ICraftingHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.oredict.ShapedOreRecipe;
/**
* Equivalent-Exchange-3
@ -34,8 +30,7 @@ public class CraftingHandler implements ICraftingHandler
CraftingManager.getInstance().getRecipeList().add(new RecipesAlchemicalBagDyes());
// Register our recipes
initBlockRecipes();
initItemRecipes();
RecipesEquivalentExchange.init();
}
@Override
@ -98,28 +93,4 @@ public class CraftingHandler implements ICraftingHandler
openStone.damageItem(ConfigurationSettings.TRANSMUTE_COST_ITEM, player);
}
}
private static void initBlockRecipes()
{
GameRegistry.addRecipe(new ItemStack(ModBlocks.alchemicalFuel, 1, 0), new Object[]{"iii", "iii", "iii", 'i', new ItemStack(ModItems.alchemicalFuel, 1, 0)});
GameRegistry.addRecipe(new ItemStack(ModBlocks.alchemicalFuel, 1, 1), new Object[]{"iii", "iii", "iii", 'i', new ItemStack(ModItems.alchemicalFuel, 1, 1)});
GameRegistry.addRecipe(new ItemStack(ModBlocks.alchemicalFuel, 1, 2), new Object[]{"iii", "iii", "iii", 'i', new ItemStack(ModItems.alchemicalFuel, 1, 2)});
GameRegistry.addRecipe(new ItemStack(ModBlocks.chalk), new Object[]{"bcb", "cbc", "bcb", 'b', new ItemStack(Item.dyePowder.itemID, 1, 15), 'c', new ItemStack(Item.clay)});
GameRegistry.addRecipe(new ItemStack(ModBlocks.chalk), new Object[]{"cc", "cc", 'c', new ItemStack(ModItems.chalk)});
GameRegistry.addRecipe(new ItemStack(ModBlocks.glassBell), new Object[]{"iii", "i i", "i i", 'i', Block.glass});
GameRegistry.addRecipe(new ItemStack(ModBlocks.aludelBase), new Object[]{"iii", "sis", "iii", 'i', Item.ingotIron, 's', Block.stone});
}
private static void initItemRecipes()
{
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.alchemicalFuel, 9, 0), new ItemStack(ModBlocks.alchemicalFuel, 1, 0));
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.alchemicalFuel, 9, 1), new ItemStack(ModBlocks.alchemicalFuel, 1, 1));
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.alchemicalFuel, 9, 2), new ItemStack(ModBlocks.alchemicalFuel, 1, 2));
GameRegistry.addRecipe(new ItemStack(ModItems.inertStone), new Object[]{"sis", "igi", "sis", 's', Block.stone, 'i', Item.ingotIron, 'g', Item.ingotGold});
GameRegistry.addRecipe(new ItemStack(ModItems.miniumStone), new Object[]{"sss", "sis", "sss", 's', ModItems.miniumShard, 'i', ModItems.inertStone});
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(ModItems.diviningRod), new Object[]{" s ", " s ", "s s", 's', Item.stick}));
}
}

View file

@ -4,7 +4,7 @@ import com.pahimar.ee3.api.OreStack;
import com.pahimar.ee3.api.WrappedStack;
import com.pahimar.ee3.emc.EmcRegistry;
import com.pahimar.ee3.emc.EmcValue;
import com.pahimar.ee3.item.crafting.RecipeRegistry;
import com.pahimar.ee3.recipe.RecipeRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

View file

@ -9,8 +9,8 @@ import com.pahimar.ee3.api.WrappedStack;
import com.pahimar.ee3.emc.EmcRegistry;
import com.pahimar.ee3.emc.EmcValue;
import com.pahimar.ee3.emc.EmcValuesIMC;
import com.pahimar.ee3.item.crafting.RecipesIMC;
import com.pahimar.ee3.lib.Reference;
import com.pahimar.ee3.recipe.RecipesIMC;
import cpw.mods.fml.common.IScheduledTickHandler;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

View file

@ -0,0 +1,43 @@
package com.pahimar.ee3.item.crafting;
import com.pahimar.ee3.block.ModBlocks;
import com.pahimar.ee3.item.ModItems;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.oredict.ShapedOreRecipe;
public class RecipesEquivalentExchange
{
public static void init()
{
initBlockRecipes();
initItemRecipes();
}
private static void initBlockRecipes()
{
GameRegistry.addRecipe(new ItemStack(ModBlocks.alchemicalFuel, 1, 0), new Object[]{"iii", "iii", "iii", 'i', new ItemStack(ModItems.alchemicalFuel, 1, 0)});
GameRegistry.addRecipe(new ItemStack(ModBlocks.alchemicalFuel, 1, 1), new Object[]{"iii", "iii", "iii", 'i', new ItemStack(ModItems.alchemicalFuel, 1, 1)});
GameRegistry.addRecipe(new ItemStack(ModBlocks.alchemicalFuel, 1, 2), new Object[]{"iii", "iii", "iii", 'i', new ItemStack(ModItems.alchemicalFuel, 1, 2)});
GameRegistry.addRecipe(new ItemStack(ModBlocks.chalk), new Object[]{"bcb", "cbc", "bcb", 'b', new ItemStack(Item.dyePowder.itemID, 1, 15), 'c', new ItemStack(Item.clay)});
GameRegistry.addRecipe(new ItemStack(ModBlocks.chalk), new Object[]{"cc", "cc", 'c', new ItemStack(ModItems.chalk)});
GameRegistry.addRecipe(new ItemStack(ModBlocks.glassBell), new Object[]{"iii", "i i", "i i", 'i', Block.glass});
GameRegistry.addRecipe(new ItemStack(ModBlocks.aludelBase), new Object[]{"iii", "sis", "iii", 'i', Item.ingotIron, 's', Block.stone});
}
private static void initItemRecipes()
{
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.alchemicalFuel, 9, 0), new ItemStack(ModBlocks.alchemicalFuel, 1, 0));
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.alchemicalFuel, 9, 1), new ItemStack(ModBlocks.alchemicalFuel, 1, 1));
GameRegistry.addShapelessRecipe(new ItemStack(ModItems.alchemicalFuel, 9, 2), new ItemStack(ModBlocks.alchemicalFuel, 1, 2));
GameRegistry.addRecipe(new ItemStack(ModItems.inertStone), new Object[]{"sis", "igi", "sis", 's', Block.stone, 'i', Item.ingotIron, 'g', Item.ingotGold});
GameRegistry.addRecipe(new ItemStack(ModItems.miniumStone), new Object[]{"sss", "sis", "sss", 's', ModItems.miniumShard, 'i', ModItems.inertStone});
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(ModItems.diviningRod), new Object[]{" s ", " s ", "s s", 's', Item.stick}));
}
}

View file

@ -0,0 +1,14 @@
package com.pahimar.ee3.item.crafting;
public class RecipesTransmutationStones
{
public static void init()
{
}
private static void registerTransmutationRecipes()
{
}
}

View file

@ -1,4 +1,4 @@
package com.pahimar.ee3.item.crafting;
package com.pahimar.ee3.recipe;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

View file

@ -1,4 +1,4 @@
package com.pahimar.ee3.item.crafting;
package com.pahimar.ee3.recipe;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

View file

@ -1,4 +1,4 @@
package com.pahimar.ee3.item.crafting;
package com.pahimar.ee3.recipe;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

View file

@ -1,4 +1,4 @@
package com.pahimar.ee3.item.crafting;
package com.pahimar.ee3.recipe;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

View file

@ -1,4 +1,4 @@
package com.pahimar.ee3.item.crafting;
package com.pahimar.ee3.recipe;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;