Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vfyjxf committed Aug 7, 2021
1 parent 1449d88 commit d6f3cb6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.daemon=false
mc_version=1.7.10
nei_version=2.1.6-GTNH
ae2_version=rv3-beta-52-GTNH
mod_version=1.1.0
mod_version=1.1.1
forge_version=10.13.4.1614
mod_group=com.github.vfyjxf.neenergistics
mod_id=neenergistics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import gregtech.api.enums.ItemList;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;

import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -49,7 +54,7 @@ public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeInd

if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) {
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
recipeInputs.removeIf(positionedStack -> GT_Utility.getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0);
recipeInputs.removeIf(positionedStack -> getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0);
return recipeInputs;
}
return null;
Expand All @@ -60,12 +65,29 @@ public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeInd
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) {
List<PositionedStack> recipeOutputs = new ArrayList<>(recipe.getOtherStacks(recipeIndex));
recipeOutputs.removeIf(positionedStack -> GT_Utility.getFluidFromDisplayStack(positionedStack.items[0]) != null);
recipeOutputs.removeIf(positionedStack -> getFluidFromDisplayStack(positionedStack.items[0]) != null);
//remove output if it's chance != 1
recipeOutputs.removeIf(stack -> stack instanceof FixedPositionedStack && !(((FixedPositionedStack) stack).mChance == 10000 || ((FixedPositionedStack) stack).mChance <= 0));
return recipeOutputs;
}
return null;
}

/**
* For resolving NoSuchMethodError
* Copied from GTNewHorizons/GT5-Unofficial.
*/
public static FluidStack getFluidFromDisplayStack(ItemStack aDisplayStack) {
if (!isStackValid(aDisplayStack) ||
aDisplayStack.getItem() != ItemList.Display_Fluid.getItem() ||
!aDisplayStack.hasTagCompound()) {
return null;
}
Fluid tFluid = FluidRegistry.getFluid(ItemList.Display_Fluid.getItem().getDamage(aDisplayStack));
return new FluidStack(tFluid, (int) aDisplayStack.getTagCompound().getLong("mFluidDisplayAmount"));
}
public static boolean isStackValid(Object aStack) {
return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public class ICRecipeProcessor implements IRecipeProcessor {
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
"blastfurnace", "BlockCutter", "centrifuge", "compressor", "extractor", "fluidcanner", "macerator",
"blastfurnace", "BlockCutter", "centrifuge", "compressor",
"extractor", "fluidcanner", "macerator",
"metalformer", "oreWashing", "solidcanner"
));
}
Expand Down

0 comments on commit d6f3cb6

Please sign in to comment.