use of mekanism.api.recipes.ChemicalCrystallizerRecipe in project Mekanism by mekanism.
the class ChemicalCrystallizerRecipeMapper method handleRecipe.
@Override
public boolean handleRecipe(IMappingCollector<NormalizedSimpleStack, Long> mapper, IRecipe<?> iRecipe, INSSFakeGroupManager groupManager) {
if (!(iRecipe instanceof ChemicalCrystallizerRecipe)) {
// Double check that we have a type of recipe we know how to handle
return false;
}
boolean handled = false;
ChemicalCrystallizerRecipe recipe = (ChemicalCrystallizerRecipe) iRecipe;
for (ChemicalStack<?> representation : recipe.getInput().getRepresentations()) {
ItemStack output = recipe.getOutput(BoxedChemicalStack.box(representation));
if (!output.isEmpty()) {
IngredientHelper ingredientHelper = new IngredientHelper(mapper);
ingredientHelper.put(representation);
if (ingredientHelper.addAsConversion(output)) {
handled = true;
}
}
}
return handled;
}
use of mekanism.api.recipes.ChemicalCrystallizerRecipe in project Mekanism by mekanism.
the class ChemicalCrystallizerInputRecipeCache method findFirstRecipe.
@Nullable
private <CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack<CHEMICAL>> ChemicalCrystallizerRecipe findFirstRecipe(ChemicalType type, STACK stack) {
Predicate<ChemicalCrystallizerRecipe> matchPredicate = recipe -> ((IChemicalStackIngredient<CHEMICAL, STACK>) recipe.getInput()).test(stack);
ChemicalInputCache<CHEMICAL, STACK, ChemicalCrystallizerRecipe> cache = (ChemicalInputCache<CHEMICAL, STACK, ChemicalCrystallizerRecipe>) typeBasedCache.get(type);
ChemicalCrystallizerRecipe recipe = cache.findFirstRecipe(stack, matchPredicate);
return recipe == null ? findFirstRecipe(typeBasedComplexRecipes.get(type), matchPredicate) : recipe;
}
use of mekanism.api.recipes.ChemicalCrystallizerRecipe in project Mekanism by mekanism.
the class ChemicalCrystallizerInputRecipeCache method initCache.
@Override
protected void initCache(List<ChemicalCrystallizerRecipe> recipes) {
for (ChemicalCrystallizerRecipe recipe : recipes) {
IChemicalStackIngredient<?, ?> ingredient = recipe.getInput();
ChemicalType type = ChemicalType.getTypeFor(ingredient);
if (mapInputs(recipe, type, ingredient)) {
typeBasedComplexRecipes.get(type).add(recipe);
}
}
}
use of mekanism.api.recipes.ChemicalCrystallizerRecipe in project Mekanism by mekanism.
the class ChemicalCrystallizerRecipeCategory method setRecipe.
@Override
public void setRecipe(IRecipeLayout recipeLayout, ChemicalCrystallizerRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
initItem(itemStacks, 0, false, output, recipe.getOutputDefinition());
IChemicalStackIngredient<?, ?> input = recipe.getInput();
if (input instanceof GasStackIngredient) {
initChemical(recipeLayout, recipe, MekanismJEI.TYPE_GAS, (GasStackIngredient) input, null);
} else if (input instanceof InfusionStackIngredient) {
initChemical(recipeLayout, recipe, MekanismJEI.TYPE_INFUSION, (InfusionStackIngredient) input, null);
} else if (input instanceof PigmentStackIngredient) {
initChemical(recipeLayout, recipe, MekanismJEI.TYPE_PIGMENT, (PigmentStackIngredient) input, null);
} else if (input instanceof SlurryStackIngredient) {
SlurryStackIngredient slurryInput = (SlurryStackIngredient) input;
Set<ITag<Item>> tags = new HashSet<>();
for (SlurryStack slurryStack : slurryInput.getRepresentations()) {
Slurry slurry = slurryStack.getType();
if (!slurry.isIn(MekanismTags.Slurries.DIRTY)) {
ITag<Item> oreTag = slurry.getOreTag();
if (oreTag != null) {
tags.add(oreTag);
}
}
}
if (tags.size() == 1) {
initChemical(recipeLayout, recipe, MekanismJEI.TYPE_SLURRY, slurryInput, itemStacks);
// TODO: Eventually come up with a better way to do this to allow for if there outputs based on the input and multiple input types
tags.stream().findFirst().ifPresent(tag -> initItem(itemStacks, 1, false, slurryOreSlot, tag.getValues().stream().map(ItemStack::new).collect(Collectors.toList())));
} else {
initChemical(recipeLayout, recipe, MekanismJEI.TYPE_SLURRY, slurryInput, null);
}
}
}
use of mekanism.api.recipes.ChemicalCrystallizerRecipe in project Mekanism by mekanism.
the class GuiChemicalCrystallizer method getScreenRenderStrings.
public static List<ITextComponent> getScreenRenderStrings(IOreInfo oreInfo) {
BoxedChemicalStack boxedChemical = oreInfo.getInputChemical();
if (!boxedChemical.isEmpty()) {
List<ITextComponent> ret = new ArrayList<>();
ret.add(boxedChemical.getTextComponent());
if (boxedChemical.getChemicalType() == ChemicalType.SLURRY && !oreInfo.getRenderStack().isEmpty()) {
ret.add(MekanismLang.GENERIC_PARENTHESIS.translate(oreInfo.getRenderStack()));
} else {
ChemicalCrystallizerRecipe recipe = oreInfo.getRecipe();
if (recipe == null) {
ret.add(MekanismLang.NO_RECIPE.translate());
} else {
ret.add(MekanismLang.GENERIC_PARENTHESIS.translate(recipe.getOutput(boxedChemical)));
}
}
return ret;
}
return Collections.emptyList();
}
Aggregations