Search in sources :

Example 1 with BrewingOreRecipe

use of net.minecraftforge.common.brewing.BrewingOreRecipe in project Gaspunk by Ladysnake.

the class GasRecipeDeserializer method deserializeRecipe.

private static void deserializeRecipe(JsonObject json, JsonContext context) {
    String resultName = JsonUtils.getString(json, "result");
    IGas result = ModGases.REGISTRY.getValue(new ResourceLocation(resultName));
    if (result == null)
        throw new JsonParseException("Unrecognized gas: " + resultName);
    JsonObject jsInput = JsonUtils.getJsonObject(json, "input");
    ItemStack in;
    if (jsInput.has("gas"))
        in = getBottle(ModGases.REGISTRY.getValue(new ResourceLocation(JsonUtils.getString(jsInput, "gas"))));
    else
        in = CraftingHelper.getItemStack(jsInput, context);
    JsonObject jsIngredient = JsonUtils.getJsonObject(json, "ingredient");
    String type = JsonUtils.getString(jsIngredient, "type", "minecraft:item");
    if ("forge:ore_dict".equals(type)) {
        String ingredient = JsonUtils.getString(jsIngredient, "ore");
        BrewingRecipeRegistry.addRecipe(new BrewingOreRecipe(in, ingredient, ((ItemGasTube) ModItems.GAS_TUBE).getItemStackFor(result)));
    } else if ("minecraft:item".equals(type)) {
        ItemStack ingredient = CraftingHelper.getItemStack(jsIngredient, context);
        BrewingRecipeRegistry.addRecipe(new BrewingRecipe(in, ingredient, ((ItemGasTube) ModItems.GAS_TUBE).getItemStackFor(result)));
    }
}
Also used : ItemGasTube(ladysnake.gaspunk.item.ItemGasTube) IGas(ladysnake.gaspunk.api.IGas) ResourceLocation(net.minecraft.util.ResourceLocation) JsonObject(com.google.gson.JsonObject) JsonParseException(com.google.gson.JsonParseException) ItemStack(net.minecraft.item.ItemStack) BrewingOreRecipe(net.minecraftforge.common.brewing.BrewingOreRecipe) BrewingRecipe(net.minecraftforge.common.brewing.BrewingRecipe)

Aggregations

JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 IGas (ladysnake.gaspunk.api.IGas)1 ItemGasTube (ladysnake.gaspunk.item.ItemGasTube)1 ItemStack (net.minecraft.item.ItemStack)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 BrewingOreRecipe (net.minecraftforge.common.brewing.BrewingOreRecipe)1 BrewingRecipe (net.minecraftforge.common.brewing.BrewingRecipe)1