Skip to content
Permalink
Browse files

Added Heating recipe category to JEI

  • Loading branch information...
DisasterMoo committed Jul 25, 2019
1 parent 0ff3a91 commit 0a37fe10735b7bf25b2945c539030f96ae779e72
@@ -32,13 +32,15 @@
import net.dries007.tfc.objects.items.ItemsTFC;
import net.dries007.tfc.objects.items.metal.ItemAnvil;
import net.dries007.tfc.objects.items.rock.ItemRock;
import net.dries007.tfc.objects.recipes.heat.HeatRecipeManager;

@JEIPlugin
public final class TFCJEIPlugin implements IModPlugin
{
private static final String ALLOY_UID = TFCConstants.MOD_ID + ".alloy";
private static final String ANVIL_UID = TFCConstants.MOD_ID + ".anvil";
private static final String BARREL_UID = TFCConstants.MOD_ID + ".barrel";
private static final String HEAT_UID = TFCConstants.MOD_ID + ".heat";
private static final String KNAP_CLAY_UID = TFCConstants.MOD_ID + ".knap.clay";
private static final String KNAP_FIRECLAY_UID = TFCConstants.MOD_ID + ".knap.fireclay";
private static final String KNAP_LEATHER_UID = TFCConstants.MOD_ID + ".knap.leather";
@@ -55,6 +57,7 @@ public void registerCategories(IRecipeCategoryRegistration registry)
registry.addRecipeCategories(new AlloyCategory(registry.getJeiHelpers().getGuiHelper(), ALLOY_UID));
registry.addRecipeCategories(new AnvilCategory(registry.getJeiHelpers().getGuiHelper(), ANVIL_UID));
registry.addRecipeCategories(new BarrelCategory(registry.getJeiHelpers().getGuiHelper(), BARREL_UID));
registry.addRecipeCategories(new HeatCategory(registry.getJeiHelpers().getGuiHelper(), HEAT_UID));
registry.addRecipeCategories(new KnappingCategory(registry.getJeiHelpers().getGuiHelper(), KNAP_CLAY_UID));
registry.addRecipeCategories(new KnappingCategory(registry.getJeiHelpers().getGuiHelper(), KNAP_FIRECLAY_UID));
registry.addRecipeCategories(new KnappingCategory(registry.getJeiHelpers().getGuiHelper(), KNAP_LEATHER_UID));
@@ -77,6 +80,15 @@ public void register(IModRegistry registry)
registry.addRecipes(quernList, QUERN_UID); //Register recipes to quern category
registry.addRecipeCatalyst(new ItemStack(BlocksTFC.QUERN), QUERN_UID); //Register BlockQuern as the device that do quern recipes

//Wraps all heat recipes
List<SimpleRecipeWrapper> heatRecipes = HeatRecipeManager.RECIPES
.stream()
.map(SimpleRecipeWrapper::new)
.collect(Collectors.toList());

registry.addRecipes(heatRecipes, HEAT_UID);
//No "device" block/item for this recipe category

//Wraps all anvil recipes
List<SimpleRecipeWrapper> anvilList = TFCRegistries.ANVIL.getValuesCollection()
.stream()
@@ -0,0 +1,62 @@
package net.dries007.tfc.compat.jei.categories;

import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;

import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.*;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import net.dries007.tfc.api.util.TFCConstants;
import net.dries007.tfc.compat.jei.BaseRecipeCategory;
import net.dries007.tfc.compat.jei.wrappers.SimpleRecipeWrapper;

@ParametersAreNonnullByDefault
public class HeatCategory extends BaseRecipeCategory<SimpleRecipeWrapper>
{
private static final ResourceLocation ICONS = new ResourceLocation(TFCConstants.MOD_ID, "textures/gui/jei/icons.png");

private final IDrawableStatic slot;
private final IDrawableStatic fire, icon;
private final IDrawableAnimated fireAnimated;

public HeatCategory(IGuiHelper helper, String Uid)
{
super(helper.createBlankDrawable(120, 38), Uid);
icon = helper.createDrawable(ICONS, 14, 0, 14, 14);
fire = helper.createDrawable(ICONS, 0, 0, 14, 14);
IDrawableStatic arrowAnimated = helper.createDrawable(ICONS, 14, 0, 14, 14);
this.fireAnimated = helper.createAnimatedDrawable(arrowAnimated, 160, IDrawableAnimated.StartDirection.TOP, true);
this.slot = helper.getSlotDrawable();
}

@Nullable
@Override
public IDrawable getIcon()
{
return icon;
}

@Override
public void drawExtras(Minecraft minecraft)
{
fire.draw(minecraft, 52, 16);
fireAnimated.draw(minecraft, 52, 16);
slot.draw(minecraft, 20, 16);
slot.draw(minecraft, 84, 16);
}

@Override
public void setRecipe(IRecipeLayout recipeLayout, SimpleRecipeWrapper recipeWrapper, IIngredients ingredients)
{
IGuiItemStackGroup itemStackGroup = recipeLayout.getItemStacks();
itemStackGroup.init(0, true, 20, 16);
itemStackGroup.init(1, false, 84, 16);

itemStackGroup.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0));
itemStackGroup.set(1, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
}
}
@@ -9,6 +9,7 @@
import javax.annotation.Nullable;

import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;

import net.dries007.tfc.api.capability.food.CapabilityFood;
@@ -17,11 +18,13 @@
import net.dries007.tfc.api.capability.heat.IItemHeat;
import net.dries007.tfc.api.types.Metal;
import net.dries007.tfc.api.util.IMetalObject;
import net.dries007.tfc.compat.jei.IJEISimpleRecipe;
import net.dries007.tfc.objects.fluids.FluidsTFC;
import net.dries007.tfc.objects.inventory.ingredient.IIngredient;
import net.dries007.tfc.util.Helpers;
import net.dries007.tfc.util.OreDictionaryHelper;

public class HeatRecipe
public class HeatRecipe implements IJEISimpleRecipe
{
private final InputType inputType;
private final OutputType outputType;
@@ -134,6 +137,18 @@ public boolean matchesInput(ItemStack stack)
}
}

@Override
public NonNullList<IIngredient<ItemStack>> getIngredients()
{
return NonNullList.withSize(1, IIngredient.of(inputStack));
}

@Override
public NonNullList<ItemStack> getOutputs()
{
return NonNullList.withSize(1, outputStack);
}

private enum OutputType
{
METAL,
@@ -20,45 +20,43 @@

public final class HeatRecipeManager
{
private static final List<HeatRecipe> recipes = new ArrayList<>();
public static final List<HeatRecipe> RECIPES = new ArrayList<>();

public static void postInit()
{
recipes.add(new HeatRecipe(new ItemStack(BlocksTFC.TORCH, 2), "stickWood"));
recipes.add(new HeatRecipe(new ItemStack(Blocks.GLASS), "sand"));
RECIPES.add(new HeatRecipe(new ItemStack(BlocksTFC.TORCH, 2), "stickWood"));
RECIPES.add(new HeatRecipe(new ItemStack(Blocks.GLASS), "sand"));

//Bread
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.BARLEY_BREAD)), new ItemStack(ItemFoodTFC.get(Food.BARLEY_DOUGH))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.CORNBREAD)), new ItemStack(ItemFoodTFC.get(Food.CORNMEAL_DOUGH))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.OAT_BREAD)), new ItemStack(ItemFoodTFC.get(Food.OAT_DOUGH))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.RICE_BREAD)), new ItemStack(ItemFoodTFC.get(Food.RICE_DOUGH))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.RYE_BREAD)), new ItemStack(ItemFoodTFC.get(Food.RYE_DOUGH))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.WHEAT_BREAD)), new ItemStack(ItemFoodTFC.get(Food.WHEAT_DOUGH))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.BARLEY_BREAD)), new ItemStack(ItemFoodTFC.get(Food.BARLEY_DOUGH))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.CORNBREAD)), new ItemStack(ItemFoodTFC.get(Food.CORNMEAL_DOUGH))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.OAT_BREAD)), new ItemStack(ItemFoodTFC.get(Food.OAT_DOUGH))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.RICE_BREAD)), new ItemStack(ItemFoodTFC.get(Food.RICE_DOUGH))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.RYE_BREAD)), new ItemStack(ItemFoodTFC.get(Food.RYE_DOUGH))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.WHEAT_BREAD)), new ItemStack(ItemFoodTFC.get(Food.WHEAT_DOUGH))));

//Meat
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_BEEF)), new ItemStack(ItemFoodTFC.get(Food.BEEF))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_PORK)), new ItemStack(ItemFoodTFC.get(Food.PORK))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_CHICKEN)), new ItemStack(ItemFoodTFC.get(Food.CHICKEN))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_MUTTON)), new ItemStack(ItemFoodTFC.get(Food.MUTTON))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_FISH)), new ItemStack(ItemFoodTFC.get(Food.FISH))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_BEAR)), new ItemStack(ItemFoodTFC.get(Food.BEAR))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_CALAMARI)), new ItemStack(ItemFoodTFC.get(Food.CALAMARI))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_HORSE_MEAT)), new ItemStack(ItemFoodTFC.get(Food.HORSE_MEAT))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_PHEASANT)), new ItemStack(ItemFoodTFC.get(Food.PHEASANT))));
recipes.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_VENISON)), new ItemStack(ItemFoodTFC.get(Food.VENISON))));

// todo: craft tweaker supported recipes (See NTP for a nice-ish way to do it)
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_BEEF)), new ItemStack(ItemFoodTFC.get(Food.BEEF))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_PORK)), new ItemStack(ItemFoodTFC.get(Food.PORK))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_CHICKEN)), new ItemStack(ItemFoodTFC.get(Food.CHICKEN))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_MUTTON)), new ItemStack(ItemFoodTFC.get(Food.MUTTON))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_FISH)), new ItemStack(ItemFoodTFC.get(Food.FISH))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_BEAR)), new ItemStack(ItemFoodTFC.get(Food.BEAR))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_CALAMARI)), new ItemStack(ItemFoodTFC.get(Food.CALAMARI))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_HORSE_MEAT)), new ItemStack(ItemFoodTFC.get(Food.HORSE_MEAT))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_PHEASANT)), new ItemStack(ItemFoodTFC.get(Food.PHEASANT))));
RECIPES.add(new HeatRecipe(new ItemStack(ItemFoodTFC.get(Food.COOKED_VENISON)), new ItemStack(ItemFoodTFC.get(Food.VENISON))));
}

public static void add(HeatRecipe recipe)
{
recipes.add(recipe);
RECIPES.add(recipe);
}

@Nullable
public static HeatRecipe get(ItemStack stack)
{
Optional<HeatRecipe> recipe = recipes.stream().filter(x -> x.matchesInput(stack)).findFirst();
Optional<HeatRecipe> recipe = RECIPES.stream().filter(x -> x.matchesInput(stack)).findFirst();
if (recipe.isPresent())
{
return recipe.get();
Submodule assets updated 1 files
+1 −0 tfc/lang/en_us.lang

0 comments on commit 0a37fe1

Please sign in to comment.
You can’t perform that action at this time.