use of mekanism.api.chemical.merged.BoxedChemicalStack in project Mekanism by mekanism.
the class GuiChemicalCrystallizer method updateSlotContents.
private void updateSlotContents() {
BoxedChemicalStack boxedChemical = oreInfo.getInputChemical();
if (!boxedChemical.isEmpty() && boxedChemical.getChemicalType() == ChemicalType.SLURRY) {
Slurry inputSlurry = (Slurry) boxedChemical.getChemicalStack().getType();
if (prevSlurry != inputSlurry) {
prevSlurry = inputSlurry;
iterStacks.clear();
if (!prevSlurry.isEmptyType() && !prevSlurry.isIn(MekanismTags.Slurries.DIRTY)) {
ITag<Item> oreTag = prevSlurry.getOreTag();
if (oreTag != null) {
for (Item ore : oreTag.getValues()) {
iterStacks.add(new ItemStack(ore));
}
}
}
slotDisplay.updateStackList();
}
} else if (!prevSlurry.isEmptyType()) {
prevSlurry = MekanismAPI.EMPTY_SLURRY;
iterStacks.clear();
slotDisplay.updateStackList();
}
}
use of mekanism.api.chemical.merged.BoxedChemicalStack in project Mekanism by mekanism.
the class BoxedChemicalNetwork method absorbBuffer.
@Override
public void absorbBuffer(BoxedPressurizedTube transmitter) {
BoxedChemicalStack chemical = transmitter.releaseShare();
if (!chemical.isEmpty()) {
Current current = chemicalTank.getCurrent();
ChemicalStack<?> chemicalStack = chemical.getChemicalStack();
if (current == Current.EMPTY) {
setStack(chemicalStack.copy(), chemicalTank.getTankForType(chemical.getChemicalType()));
} else if (ChemicalUtil.compareTypes(chemical.getChemicalType(), current)) {
IChemicalTank<?, ?> tank = chemicalTank.getTankFromCurrent(current);
if (chemicalStack.getType() == tank.getType()) {
long amount = chemicalStack.getAmount();
MekanismUtils.logMismatchedStackSize(tank.growStack(amount, Action.EXECUTE), amount);
}
}
}
}
use of mekanism.api.chemical.merged.BoxedChemicalStack in project Mekanism by mekanism.
the class BoxedPressurizedTube method releaseShare.
@Nonnull
@Override
public BoxedChemicalStack releaseShare() {
BoxedChemicalStack ret;
Current current = chemicalTank.getCurrent();
if (current == Current.EMPTY) {
ret = BoxedChemicalStack.EMPTY;
} else {
IChemicalTank<?, ?> tank = chemicalTank.getTankFromCurrent(current);
ret = BoxedChemicalStack.box(tank.getStack());
tank.setEmpty();
}
return ret;
}
use of mekanism.api.chemical.merged.BoxedChemicalStack in project Mekanism by mekanism.
the class ChemicalDissolutionRecipeMapper method handleRecipe.
@Override
public boolean handleRecipe(IMappingCollector<NormalizedSimpleStack, Long> mapper, IRecipe<?> iRecipe, INSSFakeGroupManager groupManager) {
if (!(iRecipe instanceof ChemicalDissolutionRecipe)) {
// Double check that we have a type of recipe we know how to handle
return false;
}
boolean handled = false;
ChemicalDissolutionRecipe recipe = (ChemicalDissolutionRecipe) iRecipe;
List<@NonNull ItemStack> itemRepresentations = recipe.getItemInput().getRepresentations();
List<@NonNull GasStack> gasRepresentations = recipe.getGasInput().getRepresentations();
for (GasStack gasRepresentation : gasRepresentations) {
NSSGas nssGas = NSSGas.createGas(gasRepresentation);
long gasAmount = gasRepresentation.getAmount() * TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED;
for (ItemStack itemRepresentation : itemRepresentations) {
BoxedChemicalStack output = recipe.getOutput(itemRepresentation, gasRepresentation);
if (!output.isEmpty()) {
IngredientHelper ingredientHelper = new IngredientHelper(mapper);
ingredientHelper.put(itemRepresentation);
ingredientHelper.put(nssGas, gasAmount);
if (ingredientHelper.addAsConversion(output.getChemicalStack())) {
handled = true;
}
}
}
}
return handled;
}
use of mekanism.api.chemical.merged.BoxedChemicalStack in project Mekanism by mekanism.
the class ChemicalCrystallizerInputRecipeCache method containsInput.
/**
* Checks if there is a matching recipe that has the given input.
*
* @param world World.
* @param input Recipe input.
*
* @return {@code true} if there is a match, {@code false} if there isn't.
*/
public boolean containsInput(@Nullable World world, BoxedChemicalStack input) {
if (input.isEmpty()) {
// Don't allow empty inputs
return false;
}
initCacheIfNeeded(world);
ChemicalType type = input.getChemicalType();
return containsInput(type, input.getChemicalStack()) || typeBasedComplexRecipes.get(type).stream().anyMatch(recipe -> recipe.testType(input));
}
Aggregations