use of mekanism.api.chemical.infuse.InfusionStack in project Mekanism by mekanism.
the class TileEntityMetallurgicInfuserFactory method findRecipe.
@Override
protected MetallurgicInfuserRecipe findRecipe(int process, @Nonnull ItemStack fallbackInput, @Nonnull IInventorySlot outputSlot, @Nullable IInventorySlot secondaryOutputSlot) {
InfusionStack stored = infusionTank.getStack();
ItemStack output = outputSlot.getStack();
// TODO: Give it something that is not empty when we don't have a stored infusion stack for getting the output?
return getRecipeType().getInputCache().findTypeBasedRecipe(level, fallbackInput, stored, recipe -> InventoryUtils.areItemsStackable(recipe.getOutput(fallbackInput, stored), output));
}
use of mekanism.api.chemical.infuse.InfusionStack in project Mekanism by mekanism.
the class ItemStackToInfuseTypeRecipeMapper method handleRecipe.
@Override
public boolean handleRecipe(IMappingCollector<NormalizedSimpleStack, Long> mapper, IRecipe<?> iRecipe, INSSFakeGroupManager groupManager) {
if (!(iRecipe instanceof ItemStackToInfuseTypeRecipe)) {
// Double check that we have a type of recipe we know how to handle
return false;
}
boolean handled = false;
ItemStackToInfuseTypeRecipe recipe = (ItemStackToInfuseTypeRecipe) iRecipe;
for (ItemStack representation : recipe.getInput().getRepresentations()) {
InfusionStack output = recipe.getOutput(representation);
if (!output.isEmpty()) {
IngredientHelper ingredientHelper = new IngredientHelper(mapper);
ingredientHelper.put(representation);
if (ingredientHelper.addAsConversion(output)) {
handled = true;
}
}
}
return handled;
}
use of mekanism.api.chemical.infuse.InfusionStack in project Mekanism by mekanism.
the class ChemicalDissolutionRecipeCategory method setIngredients.
@Override
public void setIngredients(ChemicalDissolutionRecipe recipe, IIngredients ingredients) {
ingredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(recipe.getItemInput().getRepresentations()));
List<@NonNull GasStack> gasInputs = recipe.getGasInput().getRepresentations();
List<GasStack> scaledGases = gasInputs.stream().map(gas -> new GasStack(gas, gas.getAmount() * TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED)).collect(Collectors.toList());
ingredients.setInputLists(MekanismJEI.TYPE_GAS, Collections.singletonList(scaledGases));
BoxedChemicalStack outputDefinition = recipe.getOutputDefinition();
ChemicalType chemicalType = outputDefinition.getChemicalType();
if (chemicalType == ChemicalType.GAS) {
ingredients.setOutput(MekanismJEI.TYPE_GAS, (GasStack) outputDefinition.getChemicalStack());
} else if (chemicalType == ChemicalType.INFUSION) {
ingredients.setOutput(MekanismJEI.TYPE_INFUSION, (InfusionStack) outputDefinition.getChemicalStack());
} else if (chemicalType == ChemicalType.PIGMENT) {
ingredients.setOutput(MekanismJEI.TYPE_PIGMENT, (PigmentStack) outputDefinition.getChemicalStack());
} else if (chemicalType == ChemicalType.SLURRY) {
ingredients.setOutput(MekanismJEI.TYPE_SLURRY, (SlurryStack) outputDefinition.getChemicalStack());
} else {
throw new IllegalStateException("Unknown chemical type");
}
}
use of mekanism.api.chemical.infuse.InfusionStack in project Mekanism by mekanism.
the class ChemicalDissolutionRecipeCategory method setRecipe.
@Override
public void setRecipe(IRecipeLayout recipeLayout, ChemicalDissolutionRecipe recipe, IIngredients ingredients) {
initItem(recipeLayout.getItemStacks(), 0, true, inputSlot, recipe.getItemInput().getRepresentations());
List<@NonNull GasStack> gasInputs = recipe.getGasInput().getRepresentations();
List<GasStack> scaledGases = gasInputs.stream().map(gas -> new GasStack(gas, gas.getAmount() * TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED)).collect(Collectors.toList());
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.TYPE_GAS);
initChemical(gasStacks, 0, true, inputGauge, scaledGases);
BoxedChemicalStack outputDefinition = recipe.getOutputDefinition();
ChemicalType chemicalType = outputDefinition.getChemicalType();
if (chemicalType == ChemicalType.GAS) {
initChemicalOutput(recipeLayout, MekanismJEI.TYPE_GAS, (GasStack) outputDefinition.getChemicalStack());
} else if (chemicalType == ChemicalType.INFUSION) {
initChemicalOutput(recipeLayout, MekanismJEI.TYPE_INFUSION, (InfusionStack) outputDefinition.getChemicalStack());
} else if (chemicalType == ChemicalType.PIGMENT) {
initChemicalOutput(recipeLayout, MekanismJEI.TYPE_PIGMENT, (PigmentStack) outputDefinition.getChemicalStack());
} else if (chemicalType == ChemicalType.SLURRY) {
initChemicalOutput(recipeLayout, MekanismJEI.TYPE_SLURRY, (SlurryStack) outputDefinition.getChemicalStack());
} else {
throw new IllegalStateException("Unknown chemical type");
}
}
use of mekanism.api.chemical.infuse.InfusionStack in project Mekanism by mekanism.
the class InfusionInventorySlot method fillOrConvert.
/**
* Fills the tank from this item OR converts the given item to an infusion type
*/
public static InfusionInventorySlot fillOrConvert(IInfusionTank infusionTank, Supplier<World> worldSupplier, @Nullable IContentsListener listener, int x, int y) {
Objects.requireNonNull(infusionTank, "Infusion tank cannot be null");
Objects.requireNonNull(worldSupplier, "World supplier cannot be null");
Function<ItemStack, InfusionStack> potentialConversionSupplier = stack -> getPotentialConversion(worldSupplier.get(), stack);
return new InfusionInventorySlot(infusionTank, worldSupplier, getFillOrConvertExtractPredicate(infusionTank, InfusionInventorySlot::getCapability, potentialConversionSupplier), getFillOrConvertInsertPredicate(infusionTank, InfusionInventorySlot::getCapability, potentialConversionSupplier), stack -> {
if (stack.getCapability(Capabilities.INFUSION_HANDLER_CAPABILITY).isPresent()) {
// Note: we mark all infusion items as valid and have a more restrictive insert check so that we allow full tanks when they are done being filled
return true;
}
// Allow infusion conversion of items that have an infusion that is valid
InfusionStack conversion = getPotentialConversion(worldSupplier.get(), stack);
return !conversion.isEmpty() && infusionTank.isValid(conversion);
}, listener, x, y);
}
Aggregations