Search in sources :

Example 1 with BoxedChemicalStack

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();
    }
}
Also used : Item(net.minecraft.item.Item) Slurry(mekanism.api.chemical.slurry.Slurry) ItemStack(net.minecraft.item.ItemStack) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack)

Example 2 with BoxedChemicalStack

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);
            }
        }
    }
}
Also used : IChemicalTank(mekanism.api.chemical.IChemicalTank) Current(mekanism.api.chemical.merged.MergedChemicalTank.Current) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack)

Example 3 with BoxedChemicalStack

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;
}
Also used : Current(mekanism.api.chemical.merged.MergedChemicalTank.Current) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack) Nonnull(javax.annotation.Nonnull)

Example 4 with BoxedChemicalStack

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;
}
Also used : ChemicalDissolutionRecipe(mekanism.api.recipes.ChemicalDissolutionRecipe) NSSGas(mekanism.common.integration.projecte.NSSGas) GasStack(mekanism.api.chemical.gas.GasStack) ItemStack(net.minecraft.item.ItemStack) IngredientHelper(mekanism.common.integration.projecte.IngredientHelper) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack)

Example 5 with BoxedChemicalStack

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));
}
Also used : EnumUtils(mekanism.common.util.EnumUtils) MekanismRecipeType(mekanism.common.recipe.MekanismRecipeType) EnumMap(java.util.EnumMap) ChemicalStack(mekanism.api.chemical.ChemicalStack) Predicate(java.util.function.Predicate) World(net.minecraft.world.World) Set(java.util.Set) ChemicalCrystallizerRecipe(mekanism.api.recipes.ChemicalCrystallizerRecipe) ChemicalInputCache(mekanism.common.recipe.lookup.cache.type.ChemicalInputCache) ChemicalType(mekanism.api.chemical.ChemicalType) HashSet(java.util.HashSet) List(java.util.List) Chemical(mekanism.api.chemical.Chemical) Map(java.util.Map) Nullable(javax.annotation.Nullable) IChemicalStackIngredient(mekanism.api.recipes.inputs.chemical.IChemicalStackIngredient) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack) ChemicalType(mekanism.api.chemical.ChemicalType)

Aggregations

BoxedChemicalStack (mekanism.api.chemical.merged.BoxedChemicalStack)9 List (java.util.List)3 ChemicalStack (mekanism.api.chemical.ChemicalStack)3 ChemicalType (mekanism.api.chemical.ChemicalType)3 GasStack (mekanism.api.chemical.gas.GasStack)3 ChemicalDissolutionRecipe (mekanism.api.recipes.ChemicalDissolutionRecipe)3 Collections (java.util.Collections)2 Collectors (java.util.stream.Collectors)2 NonNull (mekanism.api.annotations.NonNull)2 InfusionStack (mekanism.api.chemical.infuse.InfusionStack)2 Current (mekanism.api.chemical.merged.MergedChemicalTank.Current)2 PigmentStack (mekanism.api.chemical.pigment.PigmentStack)2 SlurryStack (mekanism.api.chemical.slurry.SlurryStack)2 ChemicalCrystallizerRecipe (mekanism.api.recipes.ChemicalCrystallizerRecipe)2 GuiHorizontalPowerBar (mekanism.client.gui.element.bar.GuiHorizontalPowerBar)2 GaugeType (mekanism.client.gui.element.gauge.GaugeType)2 GuiGasGauge (mekanism.client.gui.element.gauge.GuiGasGauge)2 GuiGauge (mekanism.client.gui.element.gauge.GuiGauge)2 ProgressType (mekanism.client.gui.element.progress.ProgressType)2 GuiSlot (mekanism.client.gui.element.slot.GuiSlot)2