From af55bd86a295136fed833b0a6cac6b1017be4825 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 13 Jun 2016 21:33:08 -0700 Subject: [PATCH] Fix #1322 JEI missing most squeezer recipes --- gradle.properties | 2 +- .../java/forestry/api/recipes/ISqueezerRecipe.java | 3 +++ .../core/recipes/jei/ForestryTooltipCallback.java | 2 +- .../java/forestry/factory/recipes/SqueezerRecipe.java | 6 +++++- .../recipes/jei/squeezer/SqueezerRecipeHandler.java | 11 +---------- .../recipes/jei/squeezer/SqueezerRecipeWrapper.java | 3 ++- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gradle.properties b/gradle.properties index 30f611a8b..94ec7e4c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,4 +7,4 @@ ic2_version=2.5.5-ex19 version_major=5 version_minor=0 -version_patch=12 +version_patch=13 diff --git a/src/main/java/forestry/api/recipes/ISqueezerRecipe.java b/src/main/java/forestry/api/recipes/ISqueezerRecipe.java index 385b33799..820dc56b2 100644 --- a/src/main/java/forestry/api/recipes/ISqueezerRecipe.java +++ b/src/main/java/forestry/api/recipes/ISqueezerRecipe.java @@ -5,6 +5,8 @@ ******************************************************************************/ package forestry.api.recipes; +import javax.annotation.Nullable; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -24,6 +26,7 @@ public interface ISqueezerRecipe extends IForestryRecipe { /** * @return Item stack representing the possible remnants from this recipe. (i.e. tin left over from tin cans) */ + @Nullable ItemStack getRemnants(); /** diff --git a/src/main/java/forestry/core/recipes/jei/ForestryTooltipCallback.java b/src/main/java/forestry/core/recipes/jei/ForestryTooltipCallback.java index 78dce7f44..01fc395d2 100644 --- a/src/main/java/forestry/core/recipes/jei/ForestryTooltipCallback.java +++ b/src/main/java/forestry/core/recipes/jei/ForestryTooltipCallback.java @@ -30,7 +30,7 @@ public class ForestryTooltipCallback implements ITooltipCallback { } else if (chance > 1.0) { chance = 1.0f; } - + NumberFormat percentFormat = NumberFormat.getPercentInstance(); percentFormat.setMaximumFractionDigits(2); String chanceString = String.valueOf(percentFormat.format(chance)); diff --git a/src/main/java/forestry/factory/recipes/SqueezerRecipe.java b/src/main/java/forestry/factory/recipes/SqueezerRecipe.java index e614561d4..1093b2873 100644 --- a/src/main/java/forestry/factory/recipes/SqueezerRecipe.java +++ b/src/main/java/forestry/factory/recipes/SqueezerRecipe.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.factory.recipes; +import javax.annotation.Nullable; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -21,10 +23,11 @@ public class SqueezerRecipe implements ISqueezerRecipe { private final int processingTime; private final ItemStack[] resources; private final FluidStack fluidOutput; + @Nullable private final ItemStack remnants; private final float remnantsChance; - public SqueezerRecipe(int processingTime, ItemStack[] resources, FluidStack fluidOutput, ItemStack remnants, float remnantsChance) { + public SqueezerRecipe(int processingTime, ItemStack[] resources, FluidStack fluidOutput, @Nullable ItemStack remnants, float remnantsChance) { this.processingTime = processingTime; this.resources = resources; this.fluidOutput = fluidOutput; @@ -38,6 +41,7 @@ public class SqueezerRecipe implements ISqueezerRecipe { } @Override + @Nullable public ItemStack getRemnants() { return remnants; } diff --git a/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeHandler.java b/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeHandler.java index 16839e6a2..6852bb5aa 100644 --- a/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeHandler.java +++ b/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeHandler.java @@ -51,16 +51,7 @@ public class SqueezerRecipeHandler implements I if (wrapper.getInputs() == null || wrapper.getInputs().isEmpty()) { return false; } - if (wrapper.getOutputs() == null || wrapper.getOutputs().isEmpty()) { - return false; - } - if (wrapper.getRecipe() instanceof ISqueezerContainerRecipe) { - ISqueezerContainerRecipe recipe = (ISqueezerContainerRecipe) wrapper.getRecipe(); - return recipe.getProcessingTime() > 0 && recipe.getRemnantsChance() > 0; - } else { - ISqueezerRecipe recipe = (ISqueezerRecipe) wrapper.getRecipe(); - return recipe.getProcessingTime() > 0 && recipe.getRemnantsChance() > 0; - } + return true; } } diff --git a/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeWrapper.java b/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeWrapper.java index 48c2f90de..4a0e1f756 100644 --- a/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeWrapper.java +++ b/src/main/java/forestry/factory/recipes/jei/squeezer/SqueezerRecipeWrapper.java @@ -34,7 +34,8 @@ public class SqueezerRecipeWrapper extends AbstractSqueezerRecipeWrapper getOutputs() { - return Collections.singletonList(getRecipe().getRemnants()); + ItemStack remnants = getRecipe().getRemnants(); + return remnants == null ? Collections.emptyList() : Collections.singletonList(remnants); } @Override