mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 20:42:35 +00:00
Tidy up JEI integration
This commit is contained in:
1 parent
8da0c0dc95
commit
48c8c016b4
33 files changed
+323
-357
No files matched your search
@@ -3,28 +3,23 @@ package forestry.core.recipes.jei;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.BlankRecipeCategory;
|
||||
import mezz.jei.util.Translator;
|
||||
|
||||
public abstract class ForestryRecipeCategory implements IRecipeCategory {
|
||||
|
||||
protected ForestryTooltipCallback tooltip;
|
||||
public abstract class ForestryRecipeCategory extends BlankRecipeCategory {
|
||||
@Nonnull
|
||||
protected final IDrawable background;
|
||||
private final IDrawable background;
|
||||
@Nonnull
|
||||
protected final String localizedName;
|
||||
private final String localizedName;
|
||||
|
||||
public ForestryRecipeCategory(IDrawable background, String unlocalizedName) {
|
||||
public ForestryRecipeCategory(@Nonnull IDrawable background, String unlocalizedName) {
|
||||
this.background = background;
|
||||
this.localizedName = Translator.translateToLocal(unlocalizedName);
|
||||
}
|
||||
|
||||
public ForestryRecipeCategory(IDrawable background, String unlocalizedName, int slots) {
|
||||
public ForestryRecipeCategory(@Nonnull IDrawable background, String unlocalizedName, int slots) {
|
||||
this.background = background;
|
||||
this.localizedName = Translator.translateToLocal(unlocalizedName);
|
||||
this.tooltip = new ForestryTooltipCallback(slots);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -38,12 +33,4 @@ public abstract class ForestryRecipeCategory implements IRecipeCategory {
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
|
||||
if(tooltip != null){
|
||||
this.tooltip = new ForestryTooltipCallback(tooltip.getTooltip().length);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,6 @@ public class ForestryRecipeCategoryUid {
|
||||
public static final String FERMENTER = "forestry.fermenter";
|
||||
public static final String MOISTENER = "forestry.moistener";
|
||||
public static final String SQUEEZER = "forestry.squeezer";
|
||||
public static final String SQUEEZER_CONTAINER = "forestry.squeezer.container";
|
||||
public static final String STILL = "forestry.still";
|
||||
|
||||
}
|
||||
@@ -1,66 +1,19 @@
|
||||
package forestry.core.recipes.jei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
|
||||
public abstract class ForestryRecipeWrapper<R> implements IRecipeWrapper {
|
||||
public abstract class ForestryRecipeWrapper<R> extends BlankRecipeWrapper {
|
||||
|
||||
@Nonnull
|
||||
protected final R recipe;
|
||||
private final R recipe;
|
||||
|
||||
public ForestryRecipeWrapper(@Nonnull R recipe) {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleClick(@Nonnull Minecraft minecraft, int mouseX, int mouseY, int mouseButton) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getTooltipStrings(int mouseX, int mouseY) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public R getRecipe() {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@@ -1,43 +1,34 @@
|
||||
package forestry.core.recipes.jei;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mezz.jei.api.gui.ITooltipCallback;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class ForestryTooltipCallback implements ITooltipCallback<ItemStack>{
|
||||
import mezz.jei.api.gui.ITooltipCallback;
|
||||
|
||||
private List<String>[] tip;
|
||||
|
||||
public ForestryTooltipCallback(int slots) {
|
||||
tip = new List[slots];
|
||||
for(int i = 0;i < slots;i++){
|
||||
tip[i] = new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
public class ForestryTooltipCallback implements ITooltipCallback<ItemStack> {
|
||||
|
||||
private final ArrayListMultimap<Integer, String> tooltips = ArrayListMultimap.create();
|
||||
|
||||
public void addToTooltip(int index, List<String> tooltip) {
|
||||
this.tip[index].addAll(tooltip);
|
||||
tooltips.get(index).addAll(tooltip);
|
||||
}
|
||||
|
||||
public void addToTooltip(int index, String tooltip) {
|
||||
this.tip[index].add(tooltip);
|
||||
tooltips.get(index).add(tooltip);
|
||||
}
|
||||
|
||||
public List<String> getTooltip(int index) {
|
||||
return tip[index];
|
||||
}
|
||||
|
||||
public List<String>[] getTooltip() {
|
||||
return tip;
|
||||
return tooltips.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTooltip(int slotIndex, boolean input, ItemStack ingredient, List<String> tooltip) {
|
||||
List<String> tip = this.tip[slotIndex];
|
||||
public void onTooltip(int index, boolean input, ItemStack ingredient, List<String> tooltip) {
|
||||
List<String> tip = tooltips.get(index);
|
||||
if(!tip.isEmpty()){
|
||||
tooltip.addAll(tip);
|
||||
}
|
||||
@@ -45,13 +36,13 @@ public class ForestryTooltipCallback implements ITooltipCallback<ItemStack>{
|
||||
|
||||
public void addChanceTooltip(int index, float chance) {
|
||||
if (chance <= 0.0F) {
|
||||
tip[index].add(EnumChatFormatting.GRAY + String.format(JEIUtils.translate("chance"), JEIUtils.translate("chance.never")));
|
||||
tooltips.get(index).add(EnumChatFormatting.GRAY + String.format(JEIUtils.translate("chance"), JEIUtils.translate("chance.never")));
|
||||
} else if (chance < 0.01F) {
|
||||
tip[index].add(EnumChatFormatting.GRAY + String.format(JEIUtils.translate("chance"), JEIUtils.translate("chance.lessThan1")));
|
||||
tooltips.get(index).add(EnumChatFormatting.GRAY + String.format(JEIUtils.translate("chance"), JEIUtils.translate("chance.lessThan1")));
|
||||
} else if (chance != 1.0F) {
|
||||
NumberFormat percentFormat = NumberFormat.getPercentInstance();
|
||||
percentFormat.setMaximumFractionDigits(2);
|
||||
tip[index].add(EnumChatFormatting.GRAY + String.format(JEIUtils.translate("chance"), String.valueOf(percentFormat.format(chance))));
|
||||
tooltips.get(index).add(EnumChatFormatting.GRAY + String.format(JEIUtils.translate("chance"), String.valueOf(percentFormat.format(chance))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-23
@@ -1,7 +1,8 @@
|
||||
package forestry.core.recipes.jei;
|
||||
package forestry.factory.recipes.jei;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.factory.gui.ContainerWorktable;
|
||||
import forestry.factory.recipes.jei.bottler.BottlerRecipeCategory;
|
||||
import forestry.factory.recipes.jei.bottler.BottlerRecipeHandler;
|
||||
@@ -39,34 +40,33 @@ import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
|
||||
|
||||
@JEIPlugin
|
||||
public class JEIIntegrationPlugin extends BlankModPlugin {
|
||||
public class FactoryJeiPlugin extends BlankModPlugin {
|
||||
@Override
|
||||
public void register(@Nonnull IModRegistry registry) {
|
||||
IJeiHelpers jeiHelpers = registry.getJeiHelpers();
|
||||
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
|
||||
|
||||
registry.addRecipeCategories(new BottlerRecipeCategory(guiHelper),
|
||||
new CarpenterRecipeCategory(guiHelper),
|
||||
new CentrifugeRecipeCategory(guiHelper),
|
||||
new FabricatorRecipeCategory(guiHelper),
|
||||
new FermenterRecipeCategory(guiHelper),
|
||||
new MoistenerRecipeCategory(guiHelper),
|
||||
new SqueezerRecipeCategory(guiHelper, ForestryRecipeCategoryUid.SQUEEZER),
|
||||
new SqueezerRecipeCategory(guiHelper, ForestryRecipeCategoryUid.SQUEEZER_CONTAINER),
|
||||
new StillRecipeCategory(guiHelper));
|
||||
|
||||
registry.addRecipeHandlers(new BottlerRecipeHandler(),
|
||||
new CarpenterRecipeHandler(),
|
||||
new CentrifugeRecipeHandler(),
|
||||
new FabricatorRecipeHandler(),
|
||||
new FermenterRecipeHandler(),
|
||||
new MoistenerRecipeHandler(),
|
||||
new SqueezerRecipeHandler<>(SqueezerRecipeWrapper.class, ForestryRecipeCategoryUid.SQUEEZER),
|
||||
new SqueezerRecipeHandler<>(SqueezerContainerRecipeWrapper.class, ForestryRecipeCategoryUid.SQUEEZER_CONTAINER),
|
||||
new StillRecipeHandler());
|
||||
registry.addRecipeCategories(new BottlerRecipeCategory(guiHelper),
|
||||
new CarpenterRecipeCategory(guiHelper),
|
||||
new CentrifugeRecipeCategory(guiHelper),
|
||||
new FabricatorRecipeCategory(guiHelper),
|
||||
new FermenterRecipeCategory(guiHelper),
|
||||
new MoistenerRecipeCategory(guiHelper),
|
||||
new SqueezerRecipeCategory(guiHelper, ForestryRecipeCategoryUid.SQUEEZER),
|
||||
new StillRecipeCategory(guiHelper));
|
||||
|
||||
registry.addRecipeHandlers(new BottlerRecipeHandler(),
|
||||
new CarpenterRecipeHandler(),
|
||||
new CentrifugeRecipeHandler(),
|
||||
new FabricatorRecipeHandler(),
|
||||
new FermenterRecipeHandler(),
|
||||
new MoistenerRecipeHandler(),
|
||||
new SqueezerRecipeHandler<>(SqueezerRecipeWrapper.class, ForestryRecipeCategoryUid.SQUEEZER),
|
||||
new SqueezerRecipeHandler<>(SqueezerContainerRecipeWrapper.class, ForestryRecipeCategoryUid.SQUEEZER),
|
||||
new StillRecipeHandler());
|
||||
|
||||
registry.addRecipes(BottlerRecipeMaker.getBottlerRecipes());
|
||||
registry.addRecipes(CarpenterRecipeMaker.getCrapenterRecipes());
|
||||
registry.addRecipes(CarpenterRecipeMaker.getCarpenterRecipes());
|
||||
registry.addRecipes(CentrifugeRecipeMaker.getCentrifugeRecipe());
|
||||
registry.addRecipes(FabricatorRecipeMaker.getFabricatorRecipes());
|
||||
registry.addRecipes(FermenterRecipeMaker.getFermenterRecipes());
|
||||
@@ -74,7 +74,7 @@ public class JEIIntegrationPlugin extends BlankModPlugin {
|
||||
registry.addRecipes(SqueezerRecipeMaker.getSqueezerRecipes());
|
||||
registry.addRecipes(SqueezerRecipeMaker.getSqueezerContainerRecipes());
|
||||
registry.addRecipes(StillRecipeMaker.getStillRecipes());
|
||||
|
||||
|
||||
IRecipeTransferRegistry transferRegistry = registry.getRecipeTransferRegistry();
|
||||
transferRegistry.addRecipeTransferHandler(ContainerWorktable.class, VanillaRecipeCategoryUid.CRAFTING, 19, 9, 1, 36);
|
||||
}
|
||||
@@ -2,8 +2,12 @@ package forestry.factory.recipes.jei.bottler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategory;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
@@ -12,8 +16,6 @@ import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class BottlerRecipeCategory extends ForestryRecipeCategory{
|
||||
|
||||
@@ -23,9 +25,9 @@ public class BottlerRecipeCategory extends ForestryRecipeCategory{
|
||||
|
||||
private final static ResourceLocation guiTexture = new ResourceLocation("forestry", "textures/gui/bottler.png");
|
||||
@Nonnull
|
||||
protected final IDrawableAnimated arrow;
|
||||
private final IDrawableAnimated arrow;
|
||||
@Nonnull
|
||||
protected final IDrawable tankOverlay;
|
||||
private final IDrawable tankOverlay;
|
||||
|
||||
public BottlerRecipeCategory(IGuiHelper guiHelper) {
|
||||
super(guiHelper.createDrawable(guiTexture, 48, 11, 123, 65), "tile.for.factory.0.name");
|
||||
@@ -35,23 +37,19 @@ public class BottlerRecipeCategory extends ForestryRecipeCategory{
|
||||
this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 0, 16, 58);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid() {
|
||||
return ForestryRecipeCategoryUid.BOTTLER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft) {
|
||||
arrow.draw(minecraft, 32, 28);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
|
||||
|
||||
@@ -60,8 +58,8 @@ public class BottlerRecipeCategory extends ForestryRecipeCategory{
|
||||
|
||||
guiFluidStacks.init(inputTank, true, 5, 6, 16, 58, 10000, false, tankOverlay);
|
||||
|
||||
guiItemStacks.set(emptySlot, recipeWrapper.getInputs());
|
||||
guiItemStacks.set(outputSlot, recipeWrapper.getOutputs());
|
||||
guiItemStacks.setFromRecipe(emptySlot, recipeWrapper.getInputs());
|
||||
guiItemStacks.setFromRecipe(outputSlot, recipeWrapper.getOutputs());
|
||||
|
||||
guiFluidStacks.set(inputTank, recipeWrapper.getFluidInputs());
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.factory.recipes.BottlerRecipe;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
@@ -21,6 +22,7 @@ public class BottlerRecipeHandler implements IRecipeHandler<BottlerRecipeWrapper
|
||||
return ForestryRecipeCategoryUid.BOTTLER;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull BottlerRecipeWrapper recipe) {
|
||||
return recipe;
|
||||
|
||||
@@ -3,9 +3,12 @@ package forestry.factory.recipes.jei.bottler;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import forestry.factory.recipes.BottlerRecipe;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class BottlerRecipeWrapper extends ForestryRecipeWrapper<BottlerRecipe> {
|
||||
|
||||
@@ -15,17 +18,17 @@ public class BottlerRecipeWrapper extends ForestryRecipeWrapper<BottlerRecipe> {
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() {
|
||||
return Collections.singletonList(recipe.input);
|
||||
return Collections.singletonList(getRecipe().input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs() {
|
||||
return Collections.singletonList(recipe.empty);
|
||||
public List<ItemStack> getInputs() {
|
||||
return Collections.singletonList(getRecipe().empty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return Collections.singletonList(recipe.filled);
|
||||
return Collections.singletonList(getRecipe().filled);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
package forestry.factory.recipes.jei.carpenter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategory;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.ICraftingGridHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
@@ -16,8 +20,6 @@ import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class CarpenterRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
@@ -31,9 +33,9 @@ public class CarpenterRecipeCategory extends ForestryRecipeCategory {
|
||||
@Nonnull
|
||||
private final ICraftingGridHelper craftingGridHelper;
|
||||
@Nonnull
|
||||
protected final IDrawableAnimated arrow;
|
||||
private final IDrawableAnimated arrow;
|
||||
@Nonnull
|
||||
protected final IDrawable tankOverlay;
|
||||
private final IDrawable tankOverlay;
|
||||
|
||||
public CarpenterRecipeCategory(IGuiHelper guiHelper) {
|
||||
super(guiHelper.createDrawable(guiTexture, 9, 16, 158, 61), "tile.for.factory.1.name");
|
||||
@@ -51,16 +53,12 @@ public class CarpenterRecipeCategory extends ForestryRecipeCategory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft) {
|
||||
arrow.draw(minecraft, 89, 34);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
|
||||
|
||||
@@ -82,9 +80,7 @@ public class CarpenterRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
craftingGridHelper.setOutput(guiItemStacks, wrapper.getOutputs());
|
||||
List<Object> inputs = new ArrayList<>();
|
||||
for(Object ingredient : wrapper.getRecipe().getCraftingGridRecipe().getIngredients()){
|
||||
inputs.add(ingredient);
|
||||
}
|
||||
Collections.addAll(inputs, wrapper.getRecipe().getCraftingGridRecipe().getIngredients());
|
||||
craftingGridHelper.setInput(guiItemStacks, inputs, wrapper.getRecipe().getCraftingGridRecipe().getWidth(), wrapper.getRecipe().getCraftingGridRecipe().getHeight());
|
||||
|
||||
guiFluidStacks.set(inputTank, wrapper.getFluidInputs());
|
||||
|
||||
@@ -4,6 +4,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.recipes.ICarpenterRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
@@ -21,13 +22,14 @@ public class CarpenterRecipeHandler implements IRecipeHandler<CarpenterRecipeWra
|
||||
return ForestryRecipeCategoryUid.CARPENTER;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(CarpenterRecipeWrapper recipe) {
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull CarpenterRecipeWrapper recipe) {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(CarpenterRecipeWrapper wrapper) {
|
||||
public boolean isRecipeValid(@Nonnull CarpenterRecipeWrapper wrapper) {
|
||||
ICarpenterRecipe recipe = wrapper.getRecipe();
|
||||
if(recipe.getPackagingTime() <= 0){
|
||||
return false;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class CarpenterRecipeMaker {
|
||||
private CarpenterRecipeMaker() {
|
||||
}
|
||||
|
||||
public static List<CarpenterRecipeWrapper> getCrapenterRecipes() {
|
||||
public static List<CarpenterRecipeWrapper> getCarpenterRecipes() {
|
||||
List<CarpenterRecipeWrapper> recipes = new ArrayList<>();
|
||||
for(ICarpenterRecipe recipe : RecipeManagers.carpenterManager.recipes())
|
||||
recipes.add(new CarpenterRecipeWrapper(recipe));
|
||||
|
||||
@@ -1,39 +1,42 @@
|
||||
package forestry.factory.recipes.jei.carpenter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.ICarpenterRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class CarpenterRecipeWrapper extends ForestryRecipeWrapper<ICarpenterRecipe>{
|
||||
|
||||
public CarpenterRecipeWrapper(@Nonnull ICarpenterRecipe recipe) {
|
||||
super(recipe);
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List getInputs() {
|
||||
List<Object> inputs = new ArrayList<>();
|
||||
for(Object ingredient : recipe.getCraftingGridRecipe().getIngredients()){
|
||||
inputs.add(ingredient);
|
||||
}
|
||||
inputs.add(recipe.getBox());
|
||||
Collections.addAll(inputs, getRecipe().getCraftingGridRecipe().getIngredients());
|
||||
inputs.add(getRecipe().getBox());
|
||||
return inputs;
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() {
|
||||
return Collections.singletonList(recipe.getFluidResource());
|
||||
return Collections.singletonList(getRecipe().getFluidResource());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return Collections.singletonList(recipe.getCraftingGridRecipe().getRecipeOutput());
|
||||
public List<ItemStack> getOutputs() {
|
||||
return Collections.singletonList(getRecipe().getCraftingGridRecipe().getRecipeOutput());
|
||||
}
|
||||
|
||||
}
|
||||
+14
-17
@@ -1,15 +1,20 @@
|
||||
package forestry.factory.recipes.jei.centrifuge;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategory;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.core.recipes.jei.ForestryTooltipCallback;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.IDrawableStatic;
|
||||
@@ -17,15 +22,12 @@ import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.gui.ingredients.GuiItemStackGroup;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class CentrifugeRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
public static final int[][] OUTPUTS = new int[][]{{0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1}, {0, 2}, {1, 2}, {2, 2}};
|
||||
private static final int[][] OUTPUTS = new int[][]{{0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1}, {0, 2}, {1, 2}, {2, 2}};
|
||||
|
||||
public static final Comparator<Entry<ItemStack, Float>> highestChanceComparator = new Comparator<Entry<ItemStack, Float>>() {
|
||||
private static final Comparator<Entry<ItemStack, Float>> highestChanceComparator = new Comparator<Entry<ItemStack, Float>>() {
|
||||
@Override
|
||||
public int compare(Entry<ItemStack, Float> o1, Entry<ItemStack, Float> o2) {
|
||||
return o2.getValue().compareTo(o1.getValue());
|
||||
@@ -37,7 +39,8 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
private final static ResourceLocation guiTexture = new ResourceLocation("forestry", "textures/gui/centrifugesocket.png");
|
||||
@Nonnull
|
||||
protected final IDrawableAnimated arrow;
|
||||
private final IDrawableAnimated arrow;
|
||||
private final ForestryTooltipCallback tooltip = new ForestryTooltipCallback();
|
||||
|
||||
public CentrifugeRecipeCategory(IGuiHelper guiHelper) {
|
||||
super(guiHelper.createDrawable(guiTexture, 5, 14, 166, 65), "tile.for.factory.2.name", 10);
|
||||
@@ -53,21 +56,16 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft) {
|
||||
arrow.draw(minecraft, 53, 22);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
|
||||
super.setRecipe(recipeLayout, recipeWrapper);
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
guiItemStacks.init(inputSlot, true, 24, 22);
|
||||
guiItemStacks.set(inputSlot, recipeWrapper.getInputs());
|
||||
guiItemStacks.setFromRecipe(inputSlot, recipeWrapper.getInputs());
|
||||
CentrifugeRecipeWrapper centrifugeWrapper = (CentrifugeRecipeWrapper) recipeWrapper;
|
||||
setResults(centrifugeWrapper.getRecipe().getAllProducts(), (GuiItemStackGroup) guiItemStacks);
|
||||
guiItemStacks.addTooltipCallback(tooltip);
|
||||
@@ -82,7 +80,6 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory {
|
||||
sortByChance.addAll(entrySet);
|
||||
|
||||
int i = 0;
|
||||
float[] chances = new float[sortByChance.size()];
|
||||
while (!sortByChance.isEmpty()) {
|
||||
Entry<ItemStack, Float> stack = sortByChance.poll();
|
||||
if (i >= OUTPUTS.length) {
|
||||
|
||||
@@ -2,11 +2,13 @@ package forestry.factory.recipes.jei.centrifuge;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.recipes.ICentrifugeRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CentrifugeRecipeHandler implements IRecipeHandler<CentrifugeRecipeWrapper> {
|
||||
|
||||
@@ -22,13 +24,14 @@ public class CentrifugeRecipeHandler implements IRecipeHandler<CentrifugeRecipeW
|
||||
return ForestryRecipeCategoryUid.CENTRIFUGE;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(CentrifugeRecipeWrapper recipe) {
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull CentrifugeRecipeWrapper recipe) {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(CentrifugeRecipeWrapper wrapper){
|
||||
public boolean isRecipeValid(@Nonnull CentrifugeRecipeWrapper wrapper) {
|
||||
ICentrifugeRecipe recipe = wrapper.getRecipe();
|
||||
if(recipe.getProcessingTime() <= 0){
|
||||
return false;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package forestry.factory.recipes.jei.centrifuge;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.recipes.ICentrifugeRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
@@ -12,15 +12,17 @@ public class CentrifugeRecipeWrapper extends ForestryRecipeWrapper<ICentrifugeRe
|
||||
public CentrifugeRecipeWrapper(@Nonnull ICentrifugeRecipe recipe) {
|
||||
super(recipe);
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List getInputs() {
|
||||
return Collections.singletonList(recipe.getInput());
|
||||
return Collections.singletonList(getRecipe().getInput());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return Collections.singletonList(recipe.getAllProducts().keySet());
|
||||
return Collections.singletonList(getRecipe().getAllProducts().keySet());
|
||||
}
|
||||
|
||||
}
|
||||
+9
-17
@@ -1,26 +1,28 @@
|
||||
package forestry.factory.recipes.jei.fabricator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import forestry.api.recipes.IFabricatorSmeltingRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategory;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.factory.recipes.FabricatorSmeltingRecipeManager;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.ICraftingGridHelper;
|
||||
import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class FabricatorRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
@@ -48,15 +50,7 @@ public class FabricatorRecipeCategory extends ForestryRecipeCategory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
|
||||
|
||||
@@ -88,9 +82,7 @@ public class FabricatorRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
craftingGridHelper.setOutput(guiItemStacks, wrapper.getOutputs());
|
||||
List<Object> inputs = new ArrayList<>();
|
||||
for(Object ingredient : wrapper.getRecipe().getIngredients()){
|
||||
inputs.add(ingredient);
|
||||
}
|
||||
Collections.addAll(inputs, wrapper.getRecipe().getIngredients());
|
||||
craftingGridHelper.setInput(guiItemStacks, inputs, wrapper.getRecipe().getWidth(), wrapper.getRecipe().getHeight());
|
||||
|
||||
guiFluidStacks.set(inputTank, wrapper.getFluidInputs());
|
||||
|
||||
@@ -4,6 +4,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.recipes.IFabricatorRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
@@ -21,13 +22,14 @@ public class FabricatorRecipeHandler implements IRecipeHandler<FabricatorRecipeW
|
||||
return ForestryRecipeCategoryUid.FABRICATOR;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(FabricatorRecipeWrapper recipe) {
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull FabricatorRecipeWrapper recipe) {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(FabricatorRecipeWrapper wrapper) {
|
||||
public boolean isRecipeValid(@Nonnull FabricatorRecipeWrapper wrapper) {
|
||||
IFabricatorRecipe recipe = wrapper.getRecipe();
|
||||
if(recipe.getIngredients() == null){
|
||||
return false;
|
||||
|
||||
+13
-10
@@ -1,13 +1,16 @@
|
||||
package forestry.factory.recipes.jei.fabricator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.IFabricatorRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class FabricatorRecipeWrapper extends ForestryRecipeWrapper<IFabricatorRecipe>{
|
||||
|
||||
@@ -18,21 +21,21 @@ public class FabricatorRecipeWrapper extends ForestryRecipeWrapper<IFabricatorRe
|
||||
@Override
|
||||
public List getInputs() {
|
||||
List<Object> inputs = new ArrayList<>();
|
||||
for(Object ingredient : recipe.getIngredients()){
|
||||
inputs.add(ingredient);
|
||||
}
|
||||
inputs.add(recipe.getPlan());
|
||||
Collections.addAll(inputs, getRecipe().getIngredients());
|
||||
inputs.add(getRecipe().getPlan());
|
||||
return inputs;
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() {
|
||||
return Collections.singletonList(recipe.getLiquid());
|
||||
return Collections.singletonList(getRecipe().getLiquid());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return Collections.singletonList(recipe.getRecipeOutput());
|
||||
public List<ItemStack> getOutputs() {
|
||||
return Collections.singletonList(getRecipe().getRecipeOutput());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
package forestry.factory.recipes.jei.fermenter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.api.fuels.FermenterFuel;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategory;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
@@ -17,9 +21,6 @@ import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FermenterRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
@@ -31,11 +32,11 @@ public class FermenterRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
private final static ResourceLocation guiTexture = new ResourceLocation("forestry", "textures/gui/fermenter.png");
|
||||
@Nonnull
|
||||
protected final IDrawableAnimated progressBar0;
|
||||
private final IDrawableAnimated progressBar0;
|
||||
@Nonnull
|
||||
protected final IDrawableAnimated progressBar1;
|
||||
private final IDrawableAnimated progressBar1;
|
||||
@Nonnull
|
||||
protected final IDrawable tankOverlay;
|
||||
private final IDrawable tankOverlay;
|
||||
|
||||
public FermenterRecipeCategory(IGuiHelper guiHelper) {
|
||||
super(guiHelper.createDrawable(guiTexture, 30, 15, 116, 65), "tile.for.factory.3.name");
|
||||
@@ -54,17 +55,13 @@ public class FermenterRecipeCategory extends ForestryRecipeCategory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft) {
|
||||
progressBar0.draw(minecraft, 44, 17);
|
||||
progressBar1.draw(minecraft, 68, 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.recipes.IFermenterRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
@@ -21,13 +22,14 @@ public class FermenterRecipeHandler implements IRecipeHandler<FermenterRecipeWra
|
||||
return ForestryRecipeCategoryUid.FERMENTER;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(FermenterRecipeWrapper recipe) {
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull FermenterRecipeWrapper recipe) {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(FermenterRecipeWrapper wrapper) {
|
||||
public boolean isRecipeValid(@Nonnull FermenterRecipeWrapper wrapper) {
|
||||
IFermenterRecipe recipe = wrapper.getRecipe();
|
||||
if(recipe.getFermentationValue() <= 0){
|
||||
return false;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package forestry.factory.recipes.jei.fermenter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.fuels.FermenterFuel;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.recipes.IFermenterRecipe;
|
||||
import forestry.api.recipes.IVariableFermentable;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class FermenterRecipeWrapper extends ForestryRecipeWrapper<IFermenterRecipe>{
|
||||
|
||||
@@ -33,23 +34,25 @@ public class FermenterRecipeWrapper extends ForestryRecipeWrapper<IFermenterReci
|
||||
inputs.add(fermentable);
|
||||
return inputs;
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getFermentable() {
|
||||
return fermentable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() {
|
||||
return Collections.singletonList(recipe.getFluidResource());
|
||||
return Collections.singletonList(getRecipe().getFluidResource());
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs() {
|
||||
int amount = Math.round(recipe.getFermentationValue() * recipe.getModifier());
|
||||
int amount = Math.round(getRecipe().getFermentationValue() * getRecipe().getModifier());
|
||||
if (fermentable.getItem() instanceof IVariableFermentable) {
|
||||
amount *= ((IVariableFermentable) fermentable.getItem()).getFermentationModifier(fermentable);
|
||||
}
|
||||
FluidStack output = new FluidStack(recipe.getOutput(), amount);
|
||||
FluidStack output = new FluidStack(getRecipe().getOutput(), amount);
|
||||
return Collections.singletonList(output);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,14 @@ package forestry.factory.recipes.jei.moistener;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategory;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
@@ -12,9 +18,6 @@ import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
public class MoistenerRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
@@ -27,11 +30,11 @@ public class MoistenerRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
private final static ResourceLocation guiTexture = new ResourceLocation("forestry", "textures/gui/moistener.png");
|
||||
@Nonnull
|
||||
protected final IDrawableAnimated arrow;
|
||||
private final IDrawableAnimated arrow;
|
||||
@Nonnull
|
||||
protected final IDrawableAnimated progressBar;
|
||||
private final IDrawableAnimated progressBar;
|
||||
@Nonnull
|
||||
protected final IDrawable tankOverlay;
|
||||
private final IDrawable tankOverlay;
|
||||
|
||||
public MoistenerRecipeCategory(IGuiHelper guiHelper) {
|
||||
super(guiHelper.createDrawable(guiTexture, 15, 15, 145, 60), "tile.for.factory.4.name");
|
||||
@@ -50,17 +53,13 @@ public class MoistenerRecipeCategory extends ForestryRecipeCategory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft) {
|
||||
arrow.draw(minecraft, 78, 2);
|
||||
progressBar.draw(minecraft, 109, 22);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.recipes.IMoistenerRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
@@ -21,13 +22,14 @@ public class MoistenerRecipeHandler implements IRecipeHandler<MoistenerRecipeWra
|
||||
return ForestryRecipeCategoryUid.MOISTENER;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(MoistenerRecipeWrapper recipe) {
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull MoistenerRecipeWrapper recipe) {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(MoistenerRecipeWrapper wrapper) {
|
||||
public boolean isRecipeValid(@Nonnull MoistenerRecipeWrapper wrapper) {
|
||||
IMoistenerRecipe recipe = wrapper.getRecipe();
|
||||
if(recipe.getTimePerItem() <= 0){
|
||||
return false;
|
||||
|
||||
@@ -1,43 +1,44 @@
|
||||
package forestry.factory.recipes.jei.moistener;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.fuels.MoistenerFuel;
|
||||
import forestry.api.recipes.IMoistenerRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class MoistenerRecipeWrapper extends ForestryRecipeWrapper<IMoistenerRecipe>{
|
||||
|
||||
@Nonnull
|
||||
private MoistenerFuel fuel;
|
||||
private final MoistenerFuel fuel;
|
||||
|
||||
public MoistenerRecipeWrapper(@Nonnull IMoistenerRecipe recipe, MoistenerFuel fuel) {
|
||||
public MoistenerRecipeWrapper(@Nonnull IMoistenerRecipe recipe, @Nonnull MoistenerFuel fuel) {
|
||||
super(recipe);
|
||||
this.fuel = fuel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs() {
|
||||
public List<ItemStack> getInputs() {
|
||||
List<ItemStack> inputs = new ArrayList<>();
|
||||
inputs.add(recipe.getResource());
|
||||
inputs.add(getRecipe().getResource());
|
||||
if(fuel.item != null)
|
||||
inputs.add(fuel.item);
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
public List<ItemStack> getOutputs() {
|
||||
List<ItemStack> outputs = new ArrayList<>();
|
||||
outputs.add(recipe.getProduct());
|
||||
outputs.add(getRecipe().getProduct());
|
||||
if(fuel.product != null)
|
||||
outputs.add(fuel.product);
|
||||
return outputs;
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
public MoistenerFuel getFuel() {
|
||||
return fuel;
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package forestry.factory.recipes.jei.squeezer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
|
||||
public abstract class AbstractSqueezerRecipeWrapper<R> extends ForestryRecipeWrapper<R> {
|
||||
public AbstractSqueezerRecipeWrapper(@Nonnull R recipe) {
|
||||
super(recipe);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public abstract List<ItemStack> getInputs();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public abstract List<FluidStack> getFluidOutputs();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public abstract List<ItemStack> getOutputs();
|
||||
|
||||
/**
|
||||
* @return Chance remnants will be produced by a single recipe cycle, from 0 to 1.
|
||||
*/
|
||||
public abstract float getRemnantsChance();
|
||||
}
|
||||
+18
-16
@@ -1,44 +1,46 @@
|
||||
package forestry.factory.recipes.jei.squeezer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import forestry.factory.recipes.ISqueezerContainerRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class SqueezerContainerRecipeWrapper extends ForestryRecipeWrapper<ISqueezerContainerRecipe>{
|
||||
import forestry.factory.recipes.ISqueezerContainerRecipe;
|
||||
|
||||
public class SqueezerContainerRecipeWrapper extends AbstractSqueezerRecipeWrapper<ISqueezerContainerRecipe> {
|
||||
|
||||
@Nonnull
|
||||
private ItemStack filledContainer;
|
||||
private final ItemStack filledContainer;
|
||||
|
||||
public SqueezerContainerRecipeWrapper(@Nonnull ISqueezerContainerRecipe recipe, @Nonnull ItemStack filledContainer) {
|
||||
super(recipe);
|
||||
this.filledContainer = filledContainer;
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List getInputs() {
|
||||
public List<ItemStack> getInputs() {
|
||||
return Collections.singletonList(filledContainer);
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs() {
|
||||
return Collections.singletonList(FluidContainerRegistry.getFluidForFilledItem(filledContainer));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return Collections.singletonList(recipe.getRemnants());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return super.equals(obj);
|
||||
public List<ItemStack> getOutputs() {
|
||||
return Collections.singletonList(getRecipe().getRemnants());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRemnantsChance() {
|
||||
return getRecipe().getRemnantsChance();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
package forestry.factory.recipes.jei.squeezer;
|
||||
|
||||
import java.util.Collection;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategory;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import forestry.factory.recipes.ISqueezerContainerRecipe;
|
||||
import forestry.core.recipes.jei.ForestryTooltipCallback;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
@@ -17,9 +18,6 @@ import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class SqueezerRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
@@ -32,13 +30,14 @@ public class SqueezerRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
private final static ResourceLocation guiTexture = new ResourceLocation("forestry", "textures/gui/squeezersocket.png");
|
||||
@Nonnull
|
||||
protected final IDrawableAnimated arrow;
|
||||
private final IDrawableAnimated arrow;
|
||||
@Nonnull
|
||||
protected final IDrawable tankOverlay;
|
||||
private final IDrawable tankOverlay;
|
||||
@Nonnull
|
||||
protected final String UID;
|
||||
private final String UID;
|
||||
private final ForestryTooltipCallback tooltip = new ForestryTooltipCallback();
|
||||
|
||||
public SqueezerRecipeCategory(IGuiHelper guiHelper, String UID) {
|
||||
public SqueezerRecipeCategory(@Nonnull IGuiHelper guiHelper, @Nonnull String UID) {
|
||||
super(guiHelper.createDrawable(guiTexture, 9, 16, 158, 61), "tile.for.factory.5.name", 10);
|
||||
|
||||
IDrawableStatic arrowDrawable = guiHelper.createDrawable(guiTexture, 176, 60, 43, 18);
|
||||
@@ -54,50 +53,35 @@ public class SqueezerRecipeCategory extends ForestryRecipeCategory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft) {
|
||||
arrow.draw(minecraft, 67, 25);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
|
||||
super.setRecipe(recipeLayout, recipeWrapper);
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
|
||||
|
||||
ForestryRecipeWrapper wrapper = (ForestryRecipeWrapper) recipeWrapper;
|
||||
|
||||
float chance = 0;
|
||||
if(wrapper.getRecipe() instanceof ISqueezerRecipe){
|
||||
chance = ((ISqueezerRecipe) wrapper.getRecipe()).getRemnantsChance();
|
||||
}else if(wrapper.getRecipe() instanceof ISqueezerContainerRecipe){
|
||||
chance = ((ISqueezerContainerRecipe) wrapper.getRecipe()).getRemnantsChance();
|
||||
}
|
||||
AbstractSqueezerRecipeWrapper<?> wrapper = (AbstractSqueezerRecipeWrapper) recipeWrapper;
|
||||
|
||||
float chance = wrapper.getRemnantsChance();
|
||||
|
||||
guiFluidStacks.init(outputTank, false, 113, 2, 16, 58, 10000, false, tankOverlay);
|
||||
guiFluidStacks.set(outputTank, recipeWrapper.getFluidOutputs());
|
||||
|
||||
guiFluidStacks.set(outputTank, wrapper.getFluidOutputs());
|
||||
|
||||
guiItemStacks.init(craftOutputSlot, false, 87, 43);
|
||||
guiItemStacks.set(craftOutputSlot, recipeWrapper.getOutputs());
|
||||
guiItemStacks.set(craftOutputSlot, wrapper.getOutputs());
|
||||
tooltip.addChanceTooltip(craftOutputSlot, chance);
|
||||
setIngredients(guiItemStacks, recipeWrapper.getInputs(), chance);
|
||||
setIngredients(guiItemStacks, wrapper.getInputs());
|
||||
|
||||
guiItemStacks.addTooltipCallback(tooltip);
|
||||
|
||||
}
|
||||
|
||||
public void setIngredients(IGuiItemStackGroup guiItemStacks, List<Object> inputs, float chance) {
|
||||
private static void setIngredients(@Nonnull IGuiItemStackGroup guiItemStacks, @Nonnull List<ItemStack> inputs) {
|
||||
int i = 0;
|
||||
for (Object stack : inputs) {
|
||||
for (ItemStack stack : inputs) {
|
||||
guiItemStacks.init(craftInputSlot + i, true, 7 + INPUTS[i][0] * 18, 4 + INPUTS[i][1] * 18);
|
||||
if(stack instanceof ItemStack){
|
||||
guiItemStacks.set(craftInputSlot + i, (ItemStack) stack);
|
||||
}else{
|
||||
guiItemStacks.set(craftInputSlot + i, (Collection<ItemStack>) stack);
|
||||
}
|
||||
guiItemStacks.set(craftInputSlot + i, stack);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,19 @@ import javax.annotation.Nonnull;
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import forestry.factory.recipes.ISqueezerContainerRecipe;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
public class SqueezerRecipeHandler<R extends ForestryRecipeWrapper> implements IRecipeHandler<R> {
|
||||
|
||||
@Nonnull
|
||||
private Class<R> clazz;
|
||||
private final Class<R> clazz;
|
||||
@Nonnull
|
||||
private String UID;
|
||||
private final String UID;
|
||||
|
||||
public SqueezerRecipeHandler(@Nonnull Class<R> clazz, @Nonnull String UID) {
|
||||
this.clazz = clazz;
|
||||
public SqueezerRecipeHandler(@Nonnull Class<R> recipeClass, @Nonnull String UID) {
|
||||
this.clazz = recipeClass;
|
||||
this.UID = UID;
|
||||
}
|
||||
|
||||
@@ -32,13 +33,14 @@ public class SqueezerRecipeHandler<R extends ForestryRecipeWrapper> implements I
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(R recipe) {
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull R recipe) {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(R wrapper) {
|
||||
public boolean isRecipeValid(@Nonnull R wrapper) {
|
||||
if(wrapper.getFluidOutputs() == null || wrapper.getFluidOutputs().isEmpty()){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,39 +1,44 @@
|
||||
package forestry.factory.recipes.jei.squeezer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class SqueezerRecipeWrapper extends ForestryRecipeWrapper<ISqueezerRecipe>{
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
|
||||
public class SqueezerRecipeWrapper extends AbstractSqueezerRecipeWrapper<ISqueezerRecipe> {
|
||||
|
||||
public SqueezerRecipeWrapper(@Nonnull ISqueezerRecipe recipe) {
|
||||
super(recipe);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List getInputs() {
|
||||
public List<ItemStack> getInputs() {
|
||||
List<ItemStack> inputs = new ArrayList<>();
|
||||
for(ItemStack ingredient : recipe.getResources()){
|
||||
inputs.add(ingredient);
|
||||
}
|
||||
Collections.addAll(inputs, getRecipe().getResources());
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs() {
|
||||
return Collections.singletonList(recipe.getFluidOutput());
|
||||
return Collections.singletonList(getRecipe().getFluidOutput());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<ItemStack> getOutputs() {
|
||||
return Collections.singletonList(getRecipe().getRemnants());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return Collections.singletonList(recipe.getRemnants());
|
||||
public float getRemnantsChance() {
|
||||
return getRecipe().getRemnantsChance();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,8 +2,12 @@ package forestry.factory.recipes.jei.still;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategory;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
@@ -11,8 +15,6 @@ import mezz.jei.api.gui.IDrawableStatic;
|
||||
import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class StillRecipeCategory extends ForestryRecipeCategory {
|
||||
|
||||
@@ -22,9 +24,9 @@ public class StillRecipeCategory extends ForestryRecipeCategory {
|
||||
private final static ResourceLocation guiTexture = new ResourceLocation("forestry", "textures/gui/still.png");
|
||||
|
||||
@Nonnull
|
||||
protected final IDrawable tankOverlay;
|
||||
private final IDrawable tankOverlay;
|
||||
@Nonnull
|
||||
protected final IDrawableAnimated progressBar;
|
||||
private final IDrawableAnimated progressBar;
|
||||
|
||||
public StillRecipeCategory(IGuiHelper guiHelper) {
|
||||
super(guiHelper.createDrawable(guiTexture, 30, 11, 116, 65), "tile.for.factory.6.name");
|
||||
@@ -34,31 +36,26 @@ public class StillRecipeCategory extends ForestryRecipeCategory {
|
||||
this.progressBar = guiHelper.createAnimatedDrawable(progressBarDrawable0, 20, IDrawableAnimated.StartDirection.BOTTOM, false);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid() {
|
||||
return ForestryRecipeCategoryUid.STILL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft) {
|
||||
progressBar.draw(minecraft, 54, 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) {
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
|
||||
|
||||
|
||||
|
||||
guiFluidStacks.init(inputTank, true, 5, 4, 16, 58, 10000, false, tankOverlay);
|
||||
guiFluidStacks.init(outputTank, false, 95, 4, 16, 58, 10000, false, tankOverlay);
|
||||
|
||||
guiFluidStacks.set(inputTank, recipeWrapper.getFluidInputs());
|
||||
guiFluidStacks.set(outputTank, recipeWrapper.getFluidOutputs());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.recipes.IStillRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
@@ -15,18 +16,20 @@ public class StillRecipeHandler implements IRecipeHandler<StillRecipeWrapper> {
|
||||
return StillRecipeWrapper.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return ForestryRecipeCategoryUid.STILL;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(StillRecipeWrapper recipe) {
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull StillRecipeWrapper recipe) {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(StillRecipeWrapper wrapper) {
|
||||
public boolean isRecipeValid(@Nonnull StillRecipeWrapper wrapper) {
|
||||
IStillRecipe recipe = wrapper.getRecipe();
|
||||
if(recipe.getInput() == null){
|
||||
return false;
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
package forestry.factory.recipes.jei.still;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.recipes.IStillRecipe;
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class StillRecipeWrapper extends ForestryRecipeWrapper<IStillRecipe>{
|
||||
|
||||
public StillRecipeWrapper(@Nonnull IStillRecipe recipe) {
|
||||
super(recipe);
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() {
|
||||
return Collections.singletonList(recipe.getInput());
|
||||
return Collections.singletonList(getRecipe().getInput());
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs() {
|
||||
return Collections.singletonList(recipe.getOutput());
|
||||
return Collections.singletonList(getRecipe().getOutput());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user