Search in sources :

Example 21 with GasStack

use of mekanism.api.chemical.gas.GasStack in project Mekanism by mekanism.

the class ItemJetpack method addHUDStrings.

@Override
public void addHUDStrings(List<ITextComponent> list, PlayerEntity player, ItemStack stack, EquipmentSlotType slotType) {
    if (slotType == getSlot()) {
        ItemJetpack jetpack = (ItemJetpack) stack.getItem();
        list.add(MekanismLang.JETPACK_MODE.translateColored(EnumColor.DARK_GRAY, jetpack.getMode(stack)));
        GasStack stored = GasStack.EMPTY;
        Optional<IGasHandler> capability = stack.getCapability(Capabilities.GAS_HANDLER_CAPABILITY).resolve();
        if (capability.isPresent()) {
            IGasHandler gasHandlerItem = capability.get();
            if (gasHandlerItem.getTanks() > 0) {
                stored = gasHandlerItem.getChemicalInTank(0);
            }
        }
        list.add(MekanismLang.JETPACK_STORED.translateColored(EnumColor.DARK_GRAY, EnumColor.ORANGE, stored.getAmount()));
    }
}
Also used : IGasHandler(mekanism.api.chemical.gas.IGasHandler) GasStack(mekanism.api.chemical.gas.GasStack)

Example 22 with GasStack

use of mekanism.api.chemical.gas.GasStack in project Mekanism by mekanism.

the class ChemicalUtil method getRGBDurabilityForDisplay.

public static int getRGBDurabilityForDisplay(ItemStack stack) {
    GasStack gasStack = StorageUtils.getStoredGasFromNBT(stack);
    if (!gasStack.isEmpty()) {
        return gasStack.getChemicalColorRepresentation();
    }
    InfusionStack infusionStack = StorageUtils.getStoredInfusionFromNBT(stack);
    if (!infusionStack.isEmpty()) {
        return infusionStack.getChemicalColorRepresentation();
    }
    PigmentStack pigmentStack = StorageUtils.getStoredPigmentFromNBT(stack);
    if (!pigmentStack.isEmpty()) {
        return pigmentStack.getChemicalColorRepresentation();
    }
    SlurryStack slurryStack = StorageUtils.getStoredSlurryFromNBT(stack);
    if (!slurryStack.isEmpty()) {
        return slurryStack.getChemicalColorRepresentation();
    }
    return 0;
}
Also used : PigmentStack(mekanism.api.chemical.pigment.PigmentStack) InfusionStack(mekanism.api.chemical.infuse.InfusionStack) GasStack(mekanism.api.chemical.gas.GasStack) SlurryStack(mekanism.api.chemical.slurry.SlurryStack)

Example 23 with GasStack

use of mekanism.api.chemical.gas.GasStack in project Mekanism by mekanism.

the class StackedWasteBarrel method growStack.

@Override
public long growStack(long amount, Action action) {
    long grownAmount = super.growStack(amount, action);
    if (amount > 0 && grownAmount < amount) {
        // try inserting into above tiles
        if (!tile.getActive()) {
            TileEntityRadioactiveWasteBarrel tileAbove = WorldUtils.getTileEntity(TileEntityRadioactiveWasteBarrel.class, tile.getLevel(), tile.getBlockPos().above());
            if (tileAbove != null) {
                long leftOverToInsert = amount - grownAmount;
                // Note: We do external so that it is not limited by the internal rate limits
                GasStack remainder = tileAbove.getGasTank().insert(new GasStack(stored, leftOverToInsert), action, AutomationType.EXTERNAL);
                grownAmount += leftOverToInsert - remainder.getAmount();
            }
        }
    }
    return grownAmount;
}
Also used : TileEntityRadioactiveWasteBarrel(mekanism.common.tile.TileEntityRadioactiveWasteBarrel) GasStack(mekanism.api.chemical.gas.GasStack)

Example 24 with GasStack

use of mekanism.api.chemical.gas.GasStack in project Mekanism by mekanism.

the class ModuleNutritionalInjectionUnit method addHUDElements.

@Override
public void addHUDElements(IModule<ModuleNutritionalInjectionUnit> module, PlayerEntity player, Consumer<IHUDElement> hudElementAdder) {
    if (module.isEnabled()) {
        ItemStack container = module.getContainer();
        GasStack stored = ((ItemMekaSuitArmor) container.getItem()).getContainedGas(container, MekanismGases.NUTRITIONAL_PASTE.get());
        double ratio = StorageUtils.getRatio(stored.getAmount(), MekanismConfig.gear.mekaSuitNutritionalMaxStorage.getAsLong());
        hudElementAdder.accept(MekanismAPI.getModuleHelper().hudElementPercent(icon, ratio));
    }
}
Also used : ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) GasStack(mekanism.api.chemical.gas.GasStack) ItemStack(net.minecraft.item.ItemStack)

Example 25 with GasStack

use of mekanism.api.chemical.gas.GasStack in project Mekanism by mekanism.

the class SPSMultiblockData method process.

private long process(long operations) {
    if (operations == 0) {
        return 0;
    }
    long processed = inputTank.shrinkStack(operations, Action.EXECUTE);
    int lastInputProcessed = inputProcessed;
    // Limit how much input we actually increase the input processed by to how much we were actually able to remove from the input tank
    inputProcessed += MathUtils.clampToInt(processed);
    final int inputPerAntimatter = MekanismConfig.general.spsInputPerAntimatter.get();
    if (inputProcessed >= inputPerAntimatter) {
        GasStack toAdd = MekanismGases.ANTIMATTER.getStack(inputProcessed / inputPerAntimatter);
        outputTank.insert(toAdd, Action.EXECUTE, AutomationType.INTERNAL);
        inputProcessed %= inputPerAntimatter;
    }
    if (lastInputProcessed != inputProcessed) {
        markDirty();
    }
    return processed;
}
Also used : GasStack(mekanism.api.chemical.gas.GasStack)

Aggregations

GasStack (mekanism.api.chemical.gas.GasStack)44 ItemStack (net.minecraft.item.ItemStack)17 JsonSyntaxException (com.google.gson.JsonSyntaxException)8 IngredientHelper (mekanism.common.integration.projecte.IngredientHelper)8 FluidStackIngredient (mekanism.api.recipes.inputs.FluidStackIngredient)7 FluidStack (net.minecraftforge.fluids.FluidStack)7 List (java.util.List)6 IGasHandler (mekanism.api.chemical.gas.IGasHandler)6 PigmentStack (mekanism.api.chemical.pigment.PigmentStack)6 FloatingLong (mekanism.api.math.FloatingLong)6 GasStackIngredient (mekanism.api.recipes.inputs.chemical.GasStackIngredient)6 NonNull (mekanism.api.annotations.NonNull)5 InfusionStack (mekanism.api.chemical.infuse.InfusionStack)5 SlurryStack (mekanism.api.chemical.slurry.SlurryStack)5 Nonnull (javax.annotation.Nonnull)4 JsonElement (com.google.gson.JsonElement)3 Collections (java.util.Collections)3 Nullable (javax.annotation.Nullable)3 ChemicalType (mekanism.api.chemical.ChemicalType)3 BoxedChemicalStack (mekanism.api.chemical.merged.BoxedChemicalStack)3