Added grinder and inscriber recipes. Improved JEI integration.
This commit is contained in:
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.recipes;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.recipes.ISubItemResolver;
|
||||
import appeng.api.recipes.ResolverResult;
|
||||
import appeng.api.recipes.ResolverResultSet;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.items.materials.ItemMaterial;
|
||||
import appeng.items.materials.MaterialType;
|
||||
import appeng.items.parts.ItemPart;
|
||||
import appeng.items.parts.PartType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class AEItemResolver implements ISubItemResolver
|
||||
{
|
||||
|
||||
@Override
|
||||
public Object resolveItemByName( final String nameSpace, final String itemName )
|
||||
{
|
||||
|
||||
if( nameSpace.equals( AppEng.MOD_ID ) )
|
||||
{
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IItems items = definitions.items();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if( itemName.startsWith( "paint_ball." ) )
|
||||
{
|
||||
return this.paintBall( items.coloredPaintBall(), itemName.substring( itemName.indexOf( '.' ) + 1 ), false );
|
||||
}
|
||||
|
||||
if( itemName.startsWith( "lumen_paint_ball." ) )
|
||||
{
|
||||
return this.paintBall( items.coloredPaintBall(), itemName.substring( itemName.indexOf( '.' ) + 1 ), true );
|
||||
}
|
||||
|
||||
if( itemName.equals( "cable_glass" ) )
|
||||
{
|
||||
return new ResolverResultSet( "cable_glass", parts.cableGlass().allStacks( 1 ) );
|
||||
}
|
||||
|
||||
if( itemName.startsWith( "cable_glass." ) )
|
||||
{
|
||||
return this.cableItem( parts.cableGlass(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
|
||||
}
|
||||
|
||||
if( itemName.equals( "cable_covered" ) )
|
||||
{
|
||||
return new ResolverResultSet( "cable_covered", parts.cableCovered().allStacks( 1 ) );
|
||||
}
|
||||
|
||||
if( itemName.startsWith( "cable_covered." ) )
|
||||
{
|
||||
return this.cableItem( parts.cableCovered(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
|
||||
}
|
||||
|
||||
if( itemName.equals( "cable_smart" ) )
|
||||
{
|
||||
return new ResolverResultSet( "cable_smart", parts.cableSmart().allStacks( 1 ) );
|
||||
}
|
||||
|
||||
if( itemName.startsWith( "cable_smart." ) )
|
||||
{
|
||||
return this.cableItem( parts.cableSmart(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
|
||||
}
|
||||
|
||||
if( itemName.equals( "cable_dense_covered" ) )
|
||||
{
|
||||
return new ResolverResultSet( "cable_dense_covered", parts.cableDenseCovered().allStacks( 1 ) );
|
||||
}
|
||||
|
||||
if( itemName.startsWith( "cable_dense_covered." ) )
|
||||
{
|
||||
return this.cableItem( parts.cableDenseCovered(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
|
||||
}
|
||||
|
||||
if( itemName.equals( "cable_dense_smart" ) )
|
||||
{
|
||||
return new ResolverResultSet( "cable_dense_smart", parts.cableDenseSmart().allStacks( 1 ) );
|
||||
}
|
||||
|
||||
if( itemName.startsWith( "cable_dense_smart." ) )
|
||||
{
|
||||
return this.cableItem( parts.cableDenseSmart(), itemName.substring( itemName.indexOf( '.' ) + 1 ) );
|
||||
}
|
||||
|
||||
if( itemName.startsWith( "crystal_seed." ) )
|
||||
{
|
||||
if( itemName.equalsIgnoreCase( "crystal_seed.certus" ) )
|
||||
{
|
||||
return new ResolverResultSet( "certus_crystal_seed", items.certusCrystalSeed().stack( 1 ) );
|
||||
}
|
||||
if( itemName.equalsIgnoreCase( "crystal_seed.nether" ) )
|
||||
{
|
||||
return new ResolverResultSet( "nether_crystal_seed", items.netherQuartzSeed().stack( 1 ) );
|
||||
}
|
||||
if( itemName.equalsIgnoreCase( "crystal_seed.fluix" ) )
|
||||
{
|
||||
return new ResolverResultSet( "fluix_crystal_seed", items.fluixCrystalSeed().stack( 1 ) );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if( itemName.startsWith( "material." ) )
|
||||
{
|
||||
// FIXME entire class is redundant i think
|
||||
// FIXME final String materialName = itemName.substring( itemName.indexOf( '.' ) + 1 );
|
||||
// FIXME final MaterialType mt = MaterialType.valueOf( materialName.toUpperCase() );
|
||||
// FIXME // itemName = itemName.substring( 0, itemName.indexOf( "." ) );
|
||||
// FIXME if( mt.getItemInstance() == ItemMaterial.instance && mt.getDamageValue() >= 0 && mt.isRegistered() )
|
||||
// FIXME {
|
||||
// FIXME return new ResolverResult( "material", mt.getDamageValue() );
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
// FIXME if( itemName.startsWith( "part." ) )
|
||||
// FIXME {
|
||||
// FIXME final String partName = itemName.substring( itemName.indexOf( '.' ) + 1 );
|
||||
// FIXME final PartType pt = PartType.valueOf( partName.toUpperCase() );
|
||||
// FIXME // itemName = itemName.substring( 0, itemName.indexOf( "." ) );
|
||||
// FIXME final int dVal = ItemPart.instance.getDamageByType( pt );
|
||||
// FIXME if( dVal >= 0 )
|
||||
// FIXME {
|
||||
// FIXME return new ResolverResult( "part", dVal );
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Object paintBall( final AEColoredItemDefinition partType, final String substring, final boolean lumen )
|
||||
{
|
||||
AEColor col;
|
||||
|
||||
try
|
||||
{
|
||||
col = AEColor.valueOf( substring.toUpperCase() );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
col = AEColor.TRANSPARENT;
|
||||
}
|
||||
|
||||
if( col == AEColor.TRANSPARENT )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final ItemStack is = partType.stack( col, 1 );
|
||||
return new ResolverResult( "paint_ball", ( lumen ? 20 : 0 ) + is.getDamage() );
|
||||
}
|
||||
|
||||
private Object cableItem( final AEColoredItemDefinition partType, final String substring )
|
||||
{
|
||||
AEColor col;
|
||||
|
||||
try
|
||||
{
|
||||
col = AEColor.valueOf( substring.toUpperCase() );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
col = AEColor.TRANSPARENT;
|
||||
}
|
||||
|
||||
final ItemStack is = partType.stack( col, 1 );
|
||||
return new ResolverResult( "part", is.getDamage() );
|
||||
}
|
||||
}
|
||||
@@ -20,18 +20,21 @@ public class GrinderRecipe implements IRecipe<IInventory> {
|
||||
private final ResourceLocation id;
|
||||
private final String group;
|
||||
private final Ingredient ingredient;
|
||||
private final int ingredientCount;
|
||||
private final ItemStack result;
|
||||
private final List<GrinderOptionalResult> optionalResults;
|
||||
private final int turns;
|
||||
|
||||
public GrinderRecipe(ResourceLocation id, String group, Ingredient ingredient, ItemStack result, int turns, List<GrinderOptionalResult> optionalResults) {
|
||||
public GrinderRecipe(ResourceLocation id, String group, Ingredient ingredient, int ingredientCount, ItemStack result, int turns, List<GrinderOptionalResult> optionalResults) {
|
||||
this.id = id;
|
||||
this.group = group;
|
||||
this.ingredient = ingredient;
|
||||
this.ingredientCount = ingredientCount;
|
||||
this.result = result;
|
||||
this.turns = turns;
|
||||
this.optionalResults = ImmutableList.copyOf(optionalResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(IInventory inv, World worldIn) {
|
||||
return this.ingredient.test(inv.getStackInSlot(0));
|
||||
@@ -72,6 +75,14 @@ public class GrinderRecipe implements IRecipe<IInventory> {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
public int getTurns() {
|
||||
return turns;
|
||||
}
|
||||
|
||||
public int getIngredientCount() {
|
||||
return ingredientCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<Ingredient> getIngredients() {
|
||||
NonNullList<Ingredient> nonnulllist = NonNullList.create();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -32,7 +33,12 @@ public class GrinderRecipeSerializer extends ForgeRegistryEntry<IRecipeSerialize
|
||||
@Override
|
||||
public GrinderRecipe read(ResourceLocation recipeId, JsonObject json) {
|
||||
String group = JSONUtils.getString(json, "group", "");
|
||||
Ingredient ingredient = Ingredient.deserialize(JSONUtils.getJsonObject(json, "input"));
|
||||
JsonObject inputObj = JSONUtils.getJsonObject(json, "input");
|
||||
Ingredient ingredient = Ingredient.deserialize(inputObj);
|
||||
int ingredientCount = 1;
|
||||
if (inputObj.has("count")) {
|
||||
ingredientCount = inputObj.get("count").getAsInt();
|
||||
}
|
||||
|
||||
JsonObject result = JSONUtils.getJsonObject(json, "result");
|
||||
ItemStack primaryResult = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(result, "primary"));
|
||||
@@ -45,25 +51,28 @@ public class GrinderRecipeSerializer extends ForgeRegistryEntry<IRecipeSerialize
|
||||
throw new IllegalStateException("Entry in optional result list should be an object.");
|
||||
}
|
||||
ItemStack optionalResultItem = ShapedRecipe.deserializeItem(optionalResultJson.getAsJsonObject());
|
||||
float optionalChance = JSONUtils.getFloat(optionalResultJson.getAsJsonObject(), "chance", 1.0f);
|
||||
float optionalChance = JSONUtils.getFloat(optionalResultJson.getAsJsonObject(), "percentageChance",
|
||||
AEConfig.instance().getOreDoublePercentage()) / 100.0f;
|
||||
optionalResults.add(new GrinderOptionalResult(optionalChance, optionalResultItem));
|
||||
}
|
||||
}
|
||||
|
||||
int turns = JSONUtils.getInt(json, "turns", 8);
|
||||
|
||||
return new GrinderRecipe(recipeId, group, ingredient, primaryResult, turns, optionalResults);
|
||||
return new GrinderRecipe(recipeId, group, ingredient, ingredientCount, primaryResult, turns, optionalResults);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public GrinderRecipe read(ResourceLocation recipeId, PacketBuffer buffer) {
|
||||
return null;
|
||||
// FIXME NOT YET IMPLEMENTED
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buffer, GrinderRecipe recipe) {
|
||||
|
||||
// FIXME NOT YET IMPLEMENTED
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class GrinderRecipes {
|
||||
|
||||
private GrinderRecipes() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Search all available Grinder recipes for a recipe matching the given input or null;
|
||||
*/
|
||||
@Nullable
|
||||
public static GrinderRecipe findForInput(World world, ItemStack input) {
|
||||
for (IRecipe<IInventory> recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) {
|
||||
GrinderRecipe grinderRecipe = (GrinderRecipe) recipe;
|
||||
if (grinderRecipe.getIngredient().test(input) && input.getCount() >= grinderRecipe.getIngredientCount()) {
|
||||
return grinderRecipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given item stack is an ingredient in any grinder recipe, disregarding its current size.
|
||||
*/
|
||||
public static boolean isValidIngredient(World world, ItemStack stack) {
|
||||
for (IRecipe<IInventory> recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) {
|
||||
GrinderRecipe grinderRecipe = (GrinderRecipe) recipe;
|
||||
if (grinderRecipe.getIngredient().test(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
|
||||
public class InscriberHandler
|
||||
{
|
||||
|
||||
// @Override
|
||||
// public void register( JsonObject json, JsonContext ctx )
|
||||
// {
|
||||
// ItemStack result = PartRecipeFactory.getResult( json, ctx );
|
||||
// String mode = JSONUtils.getString( json, "mode" );
|
||||
//
|
||||
// JsonObject ingredients = JSONUtils.getJsonObject( json, "ingredients" );
|
||||
//
|
||||
// List<ItemStack> middle = Arrays.asList( CraftingHelper.getIngredient( ingredients.get( "middle" ), ctx ).getMatchingStacks() );
|
||||
// ItemStack[] top = new ItemStack[] { null };
|
||||
// if( ingredients.has( "top" ) )
|
||||
// {
|
||||
// top = CraftingHelper.getIngredient( JSONUtils.getJsonObject( ingredients, "top" ), ctx ).getMatchingStacks();
|
||||
// }
|
||||
//
|
||||
// ItemStack[] bottom = new ItemStack[] { null };
|
||||
// if( ingredients.has( "bottom" ) )
|
||||
// {
|
||||
// bottom = CraftingHelper.getIngredient( JSONUtils.getJsonObject( ingredients, "bottom" ), ctx ).getMatchingStacks();
|
||||
// }
|
||||
//
|
||||
// final IInscriberRegistry reg = AEApi.instance().registries().inscriber();
|
||||
// for( int i = 0; i < top.length; ++i )
|
||||
// {
|
||||
// for( int j = 0; j < bottom.length; ++j )
|
||||
// {
|
||||
// final IInscriberRecipeBuilder builder = reg.builder();
|
||||
// builder.withOutput( result );
|
||||
// builder.withProcessType( "press".equals( mode ) ? InscriberProcessType.PRESS : InscriberProcessType.INSCRIBE );
|
||||
// builder.withInputs( middle );
|
||||
//
|
||||
// if( top[i] != null )
|
||||
// {
|
||||
// builder.withTopOptional( top[i] );
|
||||
// }
|
||||
// if( bottom[j] != null )
|
||||
// {
|
||||
// builder.withBottomOptional( bottom[j] );
|
||||
// }
|
||||
//
|
||||
// reg.addRecipe( builder.build() );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class InscriberRecipe implements IRecipe<IInventory> {
|
||||
|
||||
@@ -20,20 +20,20 @@ public class InscriberRecipe implements IRecipe<IInventory> {
|
||||
private final ResourceLocation id;
|
||||
private final String group;
|
||||
|
||||
private List<Ingredient> inputs;
|
||||
private Ingredient middleInput;
|
||||
private Ingredient topOptional;
|
||||
private Ingredient bottomOptional;
|
||||
private ItemStack output;
|
||||
private ItemStack topOptional;
|
||||
private ItemStack bottomOptional;
|
||||
private InscriberProcessType type;
|
||||
private InscriberProcessType processType;
|
||||
|
||||
public InscriberRecipe(ResourceLocation id, String group, List<Ingredient> inputs, ItemStack output, ItemStack topOptional, ItemStack bottomOptional, InscriberProcessType type) {
|
||||
public InscriberRecipe(ResourceLocation id, String group, Ingredient middleInput, ItemStack output, Ingredient topOptional, Ingredient bottomOptional, InscriberProcessType processType) {
|
||||
this.id = id;
|
||||
this.group = group;
|
||||
this.inputs = inputs;
|
||||
this.middleInput = middleInput;
|
||||
this.output = output;
|
||||
this.topOptional = topOptional;
|
||||
this.bottomOptional = bottomOptional;
|
||||
this.type = type;
|
||||
this.processType = processType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,27 +43,27 @@ public class InscriberRecipe implements IRecipe<IInventory> {
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(IInventory inv) {
|
||||
return null;
|
||||
return this.output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit(int width, int height) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return null;
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return null;
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return null;
|
||||
return GrinderRecipeSerializer.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,20 +71,33 @@ public class InscriberRecipe implements IRecipe<IInventory> {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public List<Ingredient> getInputs() {
|
||||
return inputs;
|
||||
@Override
|
||||
public NonNullList<Ingredient> getIngredients() {
|
||||
NonNullList<Ingredient> nonnulllist = NonNullList.create();
|
||||
nonnulllist.add(this.topOptional);
|
||||
nonnulllist.add(this.middleInput);
|
||||
nonnulllist.add(this.bottomOptional);
|
||||
return nonnulllist;
|
||||
}
|
||||
|
||||
public Ingredient getMiddleInput() {
|
||||
return middleInput;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public ItemStack getTopOptional() {
|
||||
public Ingredient getTopOptional() {
|
||||
return topOptional;
|
||||
}
|
||||
|
||||
public ItemStack getBottomOptional() {
|
||||
public Ingredient getBottomOptional() {
|
||||
return bottomOptional;
|
||||
}
|
||||
|
||||
public InscriberProcessType getProcessType() {
|
||||
return processType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.core.AppEng;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.crafting.ShapedRecipe;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class InscriberRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<InscriberRecipe> {
|
||||
|
||||
public static final InscriberRecipeSerializer INSTANCE = new InscriberRecipeSerializer();
|
||||
|
||||
static {
|
||||
INSTANCE.setRegistryName(AppEng.MOD_ID, "inscriber");
|
||||
}
|
||||
|
||||
private InscriberRecipeSerializer() {
|
||||
}
|
||||
|
||||
private static InscriberProcessType getMode(JsonObject json) {
|
||||
String mode = JSONUtils.getString( json, "mode", "inscribe" );
|
||||
switch (mode) {
|
||||
case "inscribe":
|
||||
return InscriberProcessType.INSCRIBE;
|
||||
case "press":
|
||||
return InscriberProcessType.PRESS;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown mode for inscriber recipe: " + mode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public InscriberRecipe read(ResourceLocation recipeId, JsonObject json) {
|
||||
|
||||
InscriberProcessType mode = getMode(json);
|
||||
|
||||
String group = JSONUtils.getString(json, "group", "");
|
||||
ItemStack result = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(json, "result"));
|
||||
|
||||
// Deserialize the three parts of the input
|
||||
JsonObject ingredients = JSONUtils.getJsonObject( json, "ingredients" );
|
||||
Ingredient middle = Ingredient.deserialize( ingredients.get( "middle" ) );
|
||||
Ingredient top = Ingredient.EMPTY;
|
||||
if( ingredients.has( "top" ) )
|
||||
{
|
||||
top = Ingredient.deserialize( ingredients.get( "top" ) );
|
||||
}
|
||||
Ingredient bottom = Ingredient.EMPTY;
|
||||
if( ingredients.has( "bottom" ) )
|
||||
{
|
||||
bottom = Ingredient.deserialize( ingredients.get( "bottom" ) );
|
||||
}
|
||||
|
||||
return new InscriberRecipe(recipeId, group, middle, result, top, bottom, mode);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public InscriberRecipe read(ResourceLocation recipeId, PacketBuffer buffer) {
|
||||
// FIXME NOT YET IMPLEMENTED
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buffer, InscriberRecipe recipe) {
|
||||
// FIXME NOT YET IMPLEMENTED
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user