Updated JEI compat to use VanillaTypes

This commit is contained in:
drcrazy 2018-08-29 16:44:45 +03:00
parent f0852a09cf
commit c41b889160
9 changed files with 38 additions and 48 deletions

View file

@ -25,6 +25,7 @@
package techreborn.compat.jei;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@ -93,11 +94,9 @@ public abstract class BaseRecipeWrapper<T extends BaseRecipe> implements IRecipe
}
@Override
public void getIngredients(
@Nonnull
IIngredients ingredients) {
ingredients.setInputLists(ItemStack.class, inputs);
ingredients.setOutputs(ItemStack.class, baseRecipe.getOutputs());
public void getIngredients(@Nonnull IIngredients ingredients) {
ingredients.setInputLists(VanillaTypes.ITEM, inputs);
ingredients.setOutputs(VanillaTypes.ITEM, baseRecipe.getOutputs());
}
@Nonnull

View file

@ -28,6 +28,7 @@ import mezz.jei.api.gui.IGuiFluidStackGroup;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.ItemStack;
@ -83,7 +84,7 @@ public class RecipeUtil {
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
if (itemInputSlots != null) {
List<List<ItemStack>> inputs = ingredients.getInputs(ItemStack.class);
List<List<ItemStack>> inputs = ingredients.getInputs(VanillaTypes.ITEM);
for (int i = 0; i < inputs.size() && i < itemInputSlots.length; i++) {
int inputSlot = itemInputSlots[i];
guiItemStacks.set(inputSlot, inputs.get(i));
@ -91,7 +92,7 @@ public class RecipeUtil {
}
if (itemOutputSlots != null) {
List<List<ItemStack>> outputs = ingredients.getOutputs(ItemStack.class);
List<List<ItemStack>> outputs = ingredients.getOutputs(VanillaTypes.ITEM);
for (int i = 0; i < outputs.size() && i < itemOutputSlots.length; i++) {
int outputSlot = itemOutputSlots[i];
guiItemStacks.set(outputSlot, outputs.get(i));
@ -99,7 +100,7 @@ public class RecipeUtil {
}
if (fluidInputSlots != null) {
List<List<FluidStack>> fluidInputs = ingredients.getInputs(FluidStack.class);
List<List<FluidStack>> fluidInputs = ingredients.getInputs(VanillaTypes.FLUID);
for (int i = 0; i < fluidInputs.size() && i < fluidInputSlots.length; i++) {
int inputTank = fluidInputSlots[i];
guiFluidStacks.set(inputTank, fluidInputs.get(i));
@ -107,7 +108,7 @@ public class RecipeUtil {
}
if (fluidOutputSlots != null) {
List<List<FluidStack>> fluidOutputs = ingredients.getOutputs(FluidStack.class);
List<List<FluidStack>> fluidOutputs = ingredients.getOutputs(VanillaTypes.FLUID);
for (int i = 0; i < fluidOutputs.size() && i < fluidOutputSlots.length; i++) {
int outputTank = fluidOutputSlots[i];
guiFluidStacks.set(outputTank, fluidOutputs.get(i));

View file

@ -29,6 +29,7 @@ import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
@ -57,13 +58,10 @@ public class FluidReplicatorRecipeWrapper implements IRecipeWrapper {
IDrawableAnimated.StartDirection.LEFT, false);
}
/* (non-Javadoc)
* @see mezz.jei.api.recipe.IRecipeWrapper#getIngredients(mezz.jei.api.ingredients.IIngredients)
*/
@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInput(ItemStack.class, new ItemStack(ModItems.UU_MATTER, recipe.getInput()));
ingredients.setOutput(FluidStack.class, new FluidStack(recipe.getFluid(), Fluid.BUCKET_VOLUME));
ingredients.setInput(VanillaTypes.ITEM, new ItemStack(ModItems.UU_MATTER, recipe.getInput()));
ingredients.setOutput(VanillaTypes.FLUID, new FluidStack(recipe.getFluid(), Fluid.BUCKET_VOLUME));
}
@Override

View file

@ -29,8 +29,8 @@ import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeCategory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import reborncore.common.util.StringUtils;
import techreborn.compat.jei.RecipeCategoryUids;
@ -88,7 +88,7 @@ public class FusionReactorRecipeCategory implements IRecipeCategory<FusionReacto
itemStacks.set(inputSlotTop, recipeWrapper.getTopInput());
itemStacks.set(inputSlotBottom, recipeWrapper.getBottomInput());
itemStacks.set(outputSlot, ingredients.getOutputs(ItemStack.class).get(0));
itemStacks.set(outputSlot, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
}
}

View file

@ -25,6 +25,7 @@
package techreborn.compat.jei.fusionReactor;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
@ -43,8 +44,8 @@ public class FusionReactorRecipeWrapper implements IRecipeWrapper {
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
ingredients.setInputs(ItemStack.class, Arrays.asList(baseRecipe.getTopInput(), baseRecipe.getBottomInput()));
ingredients.setOutput(ItemStack.class, baseRecipe.getOutput());
ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(baseRecipe.getTopInput(), baseRecipe.getBottomInput()));
ingredients.setOutput(VanillaTypes.ITEM, baseRecipe.getOutput());
}
public ItemStack getTopInput() {

View file

@ -29,6 +29,7 @@ import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraftforge.fluids.Fluid;
@ -60,6 +61,6 @@ public class FluidGeneratorRecipeWrapper implements IRecipeWrapper {
@Override
public void getIngredients(final IIngredients ingredients) {
ingredients.setInput(FluidStack.class, new FluidStack(this.baseRecipe.getFluid(), Fluid.BUCKET_VOLUME));
ingredients.setInput(VanillaTypes.FLUID, new FluidStack(this.baseRecipe.getFluid(), Fluid.BUCKET_VOLUME));
}
}

View file

@ -29,6 +29,7 @@ import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
@ -41,29 +42,22 @@ import java.util.Collections;
import java.util.List;
public class IndustrialGrinderRecipeWrapper extends BaseRecipeWrapper<IndustrialGrinderRecipe> {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/industrial_grinder.png");
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_grinder.png");
private final IDrawableAnimated progress;
public IndustrialGrinderRecipeWrapper(
@Nonnull
IJeiHelpers jeiHelpers,
@Nonnull
IndustrialGrinderRecipe baseRecipe) {
public IndustrialGrinderRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers, @Nonnull IndustrialGrinderRecipe baseRecipe) {
super(baseRecipe);
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
IDrawableStatic progressStatic = guiHelper.createDrawable(texture, 176, 14, 24, 17);
int ticksPerCycle = baseRecipe.tickTime();
this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle,
IDrawableAnimated.StartDirection.LEFT, false);
IDrawableAnimated.StartDirection.LEFT, false);
}
@Override
public void getIngredients(
@Nonnull
final IIngredients ingredients) {
ingredients.setInput(FluidStack.class, this.baseRecipe.fluidStack);
public void getIngredients(@Nonnull final IIngredients ingredients) {
ingredients.setInput(VanillaTypes.FLUID, this.baseRecipe.fluidStack);
super.getIngredients(ingredients);
}
@ -85,8 +79,10 @@ public class IndustrialGrinderRecipeWrapper extends BaseRecipeWrapper<Industrial
int x = 70;
int y = 40;
int lineHeight = minecraft.fontRenderer.FONT_HEIGHT;
minecraft.fontRenderer.drawString("Time: " + baseRecipe.tickTime / 20 + " s", x, y, 0x444444);
minecraft.fontRenderer.drawString("Energy: " + PowerSystem.getLocaliszedPowerFormattedNoSuffix(baseRecipe.euPerTick) + " " + PowerSystem.getDisplayPower().abbreviation + "/t", x, y += lineHeight, 0x444444);
minecraft.fontRenderer
.drawString("Energy: " + PowerSystem.getLocaliszedPowerFormattedNoSuffix(baseRecipe.euPerTick) + " "
+ PowerSystem.getDisplayPower().abbreviation + "/t", x, y += lineHeight, 0x444444);
}
}

View file

@ -29,6 +29,7 @@ import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
@ -43,28 +44,21 @@ import java.util.List;
* @author drcrazy
*/
public class IndustrialSawmillRecipeWrapper extends BaseRecipeWrapper<IndustrialSawmillRecipe> {
public static final ResourceLocation texture = new ResourceLocation("techreborn",
"textures/gui/industrial_sawmill.png");
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_sawmill.png");
private final IDrawableAnimated progress;
public IndustrialSawmillRecipeWrapper(
@Nonnull
IJeiHelpers jeiHelpers,
@Nonnull
IndustrialSawmillRecipe baseRecipe) {
public IndustrialSawmillRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers, @Nonnull IndustrialSawmillRecipe baseRecipe) {
super(baseRecipe);
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
IDrawableStatic progressStatic = guiHelper.createDrawable(texture, 176, 14, 20, 13);
int ticksPerCycle = baseRecipe.tickTime();
this.progress = guiHelper.createAnimatedDrawable(progressStatic, ticksPerCycle,
IDrawableAnimated.StartDirection.LEFT, false);
IDrawableAnimated.StartDirection.LEFT, false);
}
@Override
public void getIngredients(
@Nonnull
final IIngredients ingredients) {
ingredients.setInput(FluidStack.class, this.baseRecipe.fluidStack);
public void getIngredients(@Nonnull final IIngredients ingredients) {
ingredients.setInput(VanillaTypes.FLUID, this.baseRecipe.fluidStack);
super.getIngredients(ingredients);
}

View file

@ -27,9 +27,9 @@ package techreborn.compat.jei.rollingMachine;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.*;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import reborncore.common.util.StringUtils;
import techreborn.compat.jei.RecipeCategoryUids;
@ -98,7 +98,7 @@ public class RollingMachineRecipeCategory implements IRecipeCategory<RollingMach
}
guiItemStacks.init(OUTPUT_SLOTS[0], false, 94, 18);
craftingGridHelper.setInputs(guiItemStacks, ingredients.getInputs(ItemStack.class));
guiItemStacks.set(OUTPUT_SLOTS[0], ingredients.getOutputs(ItemStack.class).get(0));
craftingGridHelper.setInputs(guiItemStacks, ingredients.getInputs(VanillaTypes.ITEM));
guiItemStacks.set(OUTPUT_SLOTS[0], ingredients.getOutputs(VanillaTypes.ITEM).get(0));
}
}