Display progress bar on JEI recipes for the Solderer

This commit is contained in:
raoulvdberge
2017-04-22 12:32:50 +02:00
parent e2ce330397
commit 032071a44c
6 changed files with 36 additions and 5 deletions

View File

@@ -1,5 +1,8 @@
package com.raoulvdberge.refinedstorage.api.storage;
/**
* The storage disk type.
*/
public enum StorageDiskType {
ITEMS,
FLUIDS

View File

@@ -27,7 +27,7 @@ public class RSJEIPlugin extends BlankModPlugin {
registry.handleRecipes(RecipeWrapperSolderer.class, recipe -> recipe, RecipeCategorySolderer.ID);
registry.addRecipes(RecipeMakerSolderer.getRecipes(), RecipeCategorySolderer.ID);
registry.addRecipes(RecipeMakerSolderer.getRecipes(registry.getJeiHelpers().getGuiHelper()), RecipeCategorySolderer.ID);
registry.addRecipeCategoryCraftingItem(new ItemStack(RSBlocks.SOLDERER), RecipeCategorySolderer.ID);

View File

@@ -18,7 +18,7 @@ public class RecipeCategorySolderer extends BlankRecipeCategory<RecipeWrapperSol
private IDrawable background;
public RecipeCategorySolderer(IGuiHelper helper) {
background = helper.createDrawable(new ResourceLocation("refinedstorage", "textures/gui/solderer.png"), 43, 19, 101, 54);
this.background = helper.createDrawable(new ResourceLocation("refinedstorage", "textures/gui/solderer.png"), 43, 19, 101, 54);
}
@Override

View File

@@ -2,13 +2,14 @@ package com.raoulvdberge.refinedstorage.integration.jei;
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import mezz.jei.api.IGuiHelper;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
public final class RecipeMakerSolderer {
public static List<RecipeWrapperSolderer> getRecipes() {
public static List<RecipeWrapperSolderer> getRecipes(IGuiHelper guiHelper) {
List<RecipeWrapperSolderer> recipes = new ArrayList<>();
for (ISoldererRecipe recipe : API.instance().getSoldererRegistry().getRecipes()) {
@@ -20,7 +21,7 @@ public final class RecipeMakerSolderer {
ItemStack output = recipe.getResult();
recipes.add(new RecipeWrapperSolderer(inputs, output));
recipes.add(new RecipeWrapperSolderer(guiHelper, recipe.getDuration(), inputs, output));
}
return recipes;

View File

@@ -1,16 +1,35 @@
package com.raoulvdberge.refinedstorage.integration.jei;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import java.util.List;
public class RecipeWrapperSolderer extends BlankRecipeWrapper {
private IDrawableAnimated progress;
private List<ItemStack> inputs;
private ItemStack output;
public RecipeWrapperSolderer(List<ItemStack> inputs, ItemStack output) {
public RecipeWrapperSolderer(IGuiHelper guiHelper, int duration, List<ItemStack> inputs, ItemStack output) {
this.progress = guiHelper.createAnimatedDrawable(
guiHelper.createDrawable(
new ResourceLocation("refinedstorage", "textures/gui/solderer.png"),
212,
0,
22,
15
),
duration,
IDrawableAnimated.StartDirection.LEFT,
false
);
this.inputs = inputs;
this.output = output;
}
@@ -38,6 +57,13 @@ public class RecipeWrapperSolderer extends BlankRecipeWrapper {
return ItemStack.areItemStacksEqual(output, other.output);
}
@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
progress.draw(minecraft, 40, 18);
}
@Override
public String toString() {
return inputs + " = " + output;