use of mekanism.api.chemical.slurry.SlurryStack in project Mekanism by mekanism.
the class StorageUtils method addStoredSubstance.
/**
* @implNote Assumes there is only one "tank"
*/
public static void addStoredSubstance(@Nonnull ItemStack stack, @Nonnull List<ITextComponent> tooltip, boolean isCreative) {
// Note we ensure the capabilities are not null, as the first call to addInformation happens before capability injection
if (Capabilities.GAS_HANDLER_CAPABILITY == null || Capabilities.INFUSION_HANDLER_CAPABILITY == null || Capabilities.PIGMENT_HANDLER_CAPABILITY == null || Capabilities.SLURRY_HANDLER_CAPABILITY == null || CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY == null) {
return;
}
FluidStack fluidStack = StorageUtils.getStoredFluidFromNBT(stack);
GasStack gasStack = StorageUtils.getStoredGasFromNBT(stack);
InfusionStack infusionStack = StorageUtils.getStoredInfusionFromNBT(stack);
PigmentStack pigmentStack = StorageUtils.getStoredPigmentFromNBT(stack);
SlurryStack slurryStack = StorageUtils.getStoredSlurryFromNBT(stack);
if (fluidStack.isEmpty() && gasStack.isEmpty() && infusionStack.isEmpty() && pigmentStack.isEmpty() && slurryStack.isEmpty()) {
tooltip.add(MekanismLang.EMPTY.translate());
return;
}
ILangEntry type;
Object contents;
long amount;
if (!fluidStack.isEmpty()) {
contents = fluidStack;
amount = fluidStack.getAmount();
type = MekanismLang.LIQUID;
} else {
ChemicalStack<?> chemicalStack;
if (!gasStack.isEmpty()) {
chemicalStack = gasStack;
type = MekanismLang.GAS;
} else if (!infusionStack.isEmpty()) {
chemicalStack = infusionStack;
type = MekanismLang.INFUSE_TYPE;
} else if (!pigmentStack.isEmpty()) {
chemicalStack = pigmentStack;
type = MekanismLang.PIGMENT;
} else if (!slurryStack.isEmpty()) {
chemicalStack = slurryStack;
type = MekanismLang.SLURRY;
} else {
throw new IllegalStateException("Unknown chemical");
}
contents = chemicalStack;
amount = chemicalStack.getAmount();
}
if (isCreative) {
tooltip.add(type.translateColored(EnumColor.YELLOW, EnumColor.ORANGE, MekanismLang.GENERIC_STORED.translate(contents, EnumColor.GRAY, MekanismLang.INFINITE)));
} else {
tooltip.add(type.translateColored(EnumColor.YELLOW, EnumColor.ORANGE, MekanismLang.GENERIC_STORED_MB.translate(contents, EnumColor.GRAY, TextUtils.format(amount))));
}
}
use of mekanism.api.chemical.slurry.SlurryStack 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.chemical.slurry.SlurryStack 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.slurry.SlurryStack 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");
}
}
Aggregations