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()));
}
}
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;
}
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;
}
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));
}
}
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;
}
Aggregations