Hide cast creation recipes using brass or aluminum brass if not integrated
We don't know if we need the cast fluid until we already have added the recipes, so just don't display them in JEI
@@ -12,11 +12,14 @@ import com.google.common.collect.Maps;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import slimeknights.tconstruct.TinkerIntegration;
import slimeknights.tconstruct.library.TinkerRegistry;
import slimeknights.tconstruct.library.smeltery.Cast;
import slimeknights.tconstruct.library.smeltery.CastingRecipe;
import slimeknights.tconstruct.library.smeltery.ICastingRecipe;
import slimeknights.tconstruct.plugin.jei.JEIPlugin;
+import slimeknights.tconstruct.shared.TinkerFluids;
public class CastingRecipeChecker {
@@ -26,10 +29,19 @@ public class CastingRecipeChecker {
List<CastingRecipeWrapper> recipes = new ArrayList<>();
Map<Triple<Item, Item, Fluid>, List<ItemStack>> castDict = Maps.newHashMap();
+ // skip recipes with brass or alubrass if those are not integrated
+ // done since we have to register those fluids as casts in init, but don't know until postInit if they are used
+ boolean hasAlubrass = TinkerIntegration.isIntegrated(TinkerFluids.alubrass);
+ boolean hasBrass = TinkerIntegration.isIntegrated(TinkerFluids.brass);
for(ICastingRecipe irecipe : TinkerRegistry.getAllTableCastingRecipes()) {
if(irecipe instanceof CastingRecipe) {
CastingRecipe recipe = (CastingRecipe) irecipe;
+ // skip recipes that use either alubrass or brass
+ if (fluidHidden(recipe.getFluid(), hasAlubrass, hasBrass)) {
+ continue;
+ }
+
if(recipe.cast != null && recipe.getResult() != null && recipe.getResult().getItem() instanceof Cast) {
Triple<Item, Item, Fluid> output = Triple.of(recipe.getResult().getItem(), Cast.getPartFromTag(recipe.getResult()), recipe.getFluid().getFluid());
@@ -70,4 +82,12 @@ public class CastingRecipeChecker {
return recipes;
}
+
+ private static boolean fluidHidden(FluidStack fluidStack, boolean hasAlubrass, boolean hasBrass) {
+ if(fluidStack == null) {
+ return true;
+ }
+ Fluid fluid = fluidStack.getFluid();
+ return fluid == null || (!hasAlubrass && fluid == TinkerFluids.alubrass) || (!hasBrass && fluid == TinkerFluids.brass);
+ }
}
