Search in sources :

Example 6 with PigmentStack

use of mekanism.api.chemical.pigment.PigmentStack 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))));
    }
}
Also used : PigmentStack(mekanism.api.chemical.pigment.PigmentStack) InfusionStack(mekanism.api.chemical.infuse.InfusionStack) FluidStack(net.minecraftforge.fluids.FluidStack) GasStack(mekanism.api.chemical.gas.GasStack) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) ILangEntry(mekanism.api.text.ILangEntry)

Example 7 with PigmentStack

use of mekanism.api.chemical.pigment.PigmentStack in project Mekanism by mekanism.

the class ItemStackToPigmentRecipeMapper method handleRecipe.

@Override
public boolean handleRecipe(IMappingCollector<NormalizedSimpleStack, Long> mapper, IRecipe<?> iRecipe, INSSFakeGroupManager groupManager) {
    if (!(iRecipe instanceof ItemStackToPigmentRecipe)) {
        // Double check that we have a type of recipe we know how to handle
        return false;
    }
    boolean handled = false;
    ItemStackToPigmentRecipe recipe = (ItemStackToPigmentRecipe) iRecipe;
    for (ItemStack representation : recipe.getInput().getRepresentations()) {
        PigmentStack output = recipe.getOutput(representation);
        if (!output.isEmpty()) {
            IngredientHelper ingredientHelper = new IngredientHelper(mapper);
            ingredientHelper.put(representation);
            if (ingredientHelper.addAsConversion(output)) {
                handled = true;
            }
        }
    }
    return handled;
}
Also used : ItemStackToPigmentRecipe(mekanism.api.recipes.ItemStackToPigmentRecipe) PigmentStack(mekanism.api.chemical.pigment.PigmentStack) ItemStack(net.minecraft.item.ItemStack) IngredientHelper(mekanism.common.integration.projecte.IngredientHelper)

Example 8 with PigmentStack

use of mekanism.api.chemical.pigment.PigmentStack 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");
    }
}
Also used : ChemicalStack(mekanism.api.chemical.ChemicalStack) IIngredients(mezz.jei.api.ingredients.IIngredients) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) ChemicalType(mekanism.api.chemical.ChemicalType) IGuiHelper(mezz.jei.api.helpers.IGuiHelper) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) GuiGauge(mekanism.client.gui.element.gauge.GuiGauge) TileEntityChemicalDissolutionChamber(mekanism.common.tile.machine.TileEntityChemicalDissolutionChamber) GasStack(mekanism.api.chemical.gas.GasStack) NonNull(mekanism.api.annotations.NonNull) MekanismBlocks(mekanism.common.registries.MekanismBlocks) IRecipeLayout(mezz.jei.api.gui.IRecipeLayout) GuiHorizontalPowerBar(mekanism.client.gui.element.bar.GuiHorizontalPowerBar) ChemicalDissolutionRecipe(mekanism.api.recipes.ChemicalDissolutionRecipe) BaseRecipeCategory(mekanism.client.jei.BaseRecipeCategory) SlotOverlay(mekanism.common.inventory.container.slot.SlotOverlay) SlotType(mekanism.client.gui.element.slot.SlotType) DataType(mekanism.common.tile.component.config.DataType) Collectors(java.util.stream.Collectors) MekanismJEI(mekanism.client.jei.MekanismJEI) ProgressType(mekanism.client.gui.element.progress.ProgressType) List(java.util.List) InfusionStack(mekanism.api.chemical.infuse.InfusionStack) IIngredientType(mezz.jei.api.ingredients.IIngredientType) GaugeType(mekanism.client.gui.element.gauge.GaugeType) PigmentStack(mekanism.api.chemical.pigment.PigmentStack) IGuiIngredientGroup(mezz.jei.api.gui.ingredient.IGuiIngredientGroup) VanillaTypes(mezz.jei.api.constants.VanillaTypes) Collections(java.util.Collections) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) ChemicalType(mekanism.api.chemical.ChemicalType) InfusionStack(mekanism.api.chemical.infuse.InfusionStack) GasStack(mekanism.api.chemical.gas.GasStack) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack)

Example 9 with PigmentStack

use of mekanism.api.chemical.pigment.PigmentStack 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");
    }
}
Also used : ChemicalStack(mekanism.api.chemical.ChemicalStack) IIngredients(mezz.jei.api.ingredients.IIngredients) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) ChemicalType(mekanism.api.chemical.ChemicalType) IGuiHelper(mezz.jei.api.helpers.IGuiHelper) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) GuiGauge(mekanism.client.gui.element.gauge.GuiGauge) TileEntityChemicalDissolutionChamber(mekanism.common.tile.machine.TileEntityChemicalDissolutionChamber) GasStack(mekanism.api.chemical.gas.GasStack) NonNull(mekanism.api.annotations.NonNull) MekanismBlocks(mekanism.common.registries.MekanismBlocks) IRecipeLayout(mezz.jei.api.gui.IRecipeLayout) GuiHorizontalPowerBar(mekanism.client.gui.element.bar.GuiHorizontalPowerBar) ChemicalDissolutionRecipe(mekanism.api.recipes.ChemicalDissolutionRecipe) BaseRecipeCategory(mekanism.client.jei.BaseRecipeCategory) SlotOverlay(mekanism.common.inventory.container.slot.SlotOverlay) SlotType(mekanism.client.gui.element.slot.SlotType) DataType(mekanism.common.tile.component.config.DataType) Collectors(java.util.stream.Collectors) MekanismJEI(mekanism.client.jei.MekanismJEI) ProgressType(mekanism.client.gui.element.progress.ProgressType) List(java.util.List) InfusionStack(mekanism.api.chemical.infuse.InfusionStack) IIngredientType(mezz.jei.api.ingredients.IIngredientType) GaugeType(mekanism.client.gui.element.gauge.GaugeType) PigmentStack(mekanism.api.chemical.pigment.PigmentStack) IGuiIngredientGroup(mezz.jei.api.gui.ingredient.IGuiIngredientGroup) VanillaTypes(mezz.jei.api.constants.VanillaTypes) Collections(java.util.Collections) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) ChemicalType(mekanism.api.chemical.ChemicalType) InfusionStack(mekanism.api.chemical.infuse.InfusionStack) GasStack(mekanism.api.chemical.gas.GasStack) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack)

Example 10 with PigmentStack

use of mekanism.api.chemical.pigment.PigmentStack in project Mekanism by mekanism.

the class SerializerHelper method serializeBoxedChemicalStack.

/**
 * Helper to serialize a Boxed Chemical Stack into a Json Object.
 *
 * @param stack Stack to serialize.
 *
 * @return Json representation.
 */
public static JsonElement serializeBoxedChemicalStack(@Nonnull BoxedChemicalStack stack) {
    JsonObject json;
    ChemicalType chemicalType = stack.getChemicalType();
    if (chemicalType == ChemicalType.GAS) {
        json = serializeGasStack((GasStack) stack.getChemicalStack());
    } else if (chemicalType == ChemicalType.INFUSION) {
        json = serializeInfusionStack((InfusionStack) stack.getChemicalStack());
    } else if (chemicalType == ChemicalType.PIGMENT) {
        json = serializePigmentStack((PigmentStack) stack.getChemicalStack());
    } else if (chemicalType == ChemicalType.SLURRY) {
        json = serializeSlurryStack((SlurryStack) stack.getChemicalStack());
    } else {
        throw new IllegalStateException("Unknown chemical type");
    }
    json.addProperty(JsonConstants.CHEMICAL_TYPE, chemicalType.getSerializedName());
    return json;
}
Also used : PigmentStack(mekanism.api.chemical.pigment.PigmentStack) ChemicalType(mekanism.api.chemical.ChemicalType) JsonObject(com.google.gson.JsonObject) GasStack(mekanism.api.chemical.gas.GasStack)

Aggregations

PigmentStack (mekanism.api.chemical.pigment.PigmentStack)10 GasStack (mekanism.api.chemical.gas.GasStack)6 InfusionStack (mekanism.api.chemical.infuse.InfusionStack)5 SlurryStack (mekanism.api.chemical.slurry.SlurryStack)5 Collections (java.util.Collections)3 List (java.util.List)3 ChemicalStack (mekanism.api.chemical.ChemicalStack)3 ChemicalType (mekanism.api.chemical.ChemicalType)3 IngredientHelper (mekanism.common.integration.projecte.IngredientHelper)3 ItemStack (net.minecraft.item.ItemStack)3 Collectors (java.util.stream.Collectors)2 NonNull (mekanism.api.annotations.NonNull)2 BoxedChemicalStack (mekanism.api.chemical.merged.BoxedChemicalStack)2 ChemicalDissolutionRecipe (mekanism.api.recipes.ChemicalDissolutionRecipe)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