Search in sources :

Example 1 with Gas

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

the class BoilerRecipeCategory method getBoilerRecipes.

public static List<BoilerJEIRecipe> getBoilerRecipes() {
    // Note: The recipes below ignore the boiler's efficiency and rounds the amount of coolant
    int waterAmount = 1;
    double waterToSteamEfficiency = HeatUtils.getWaterThermalEnthalpy() / HeatUtils.getSteamEnergyEfficiency();
    List<BoilerJEIRecipe> recipes = new ArrayList<>();
    // Special case heat only recipe
    double temperature = waterAmount * waterToSteamEfficiency / (BoilerMultiblockData.CASING_HEAT_CAPACITY * MekanismConfig.general.boilerWaterConductivity.get()) + HeatUtils.BASE_BOIL_TEMP;
    recipes.add(new BoilerJEIRecipe(null, FluidStackIngredient.from(FluidTags.WATER, waterAmount), MekanismGases.STEAM.getStack(waterAmount), GasStack.EMPTY, temperature));
    // Go through all gases and add each coolant
    for (Gas gas : MekanismAPI.gasRegistry()) {
        HeatedCoolant heatedCoolant = gas.get(HeatedCoolant.class);
        if (heatedCoolant != null) {
            // If it is a cooled coolant add a recipe for it
            Gas cooledCoolant = heatedCoolant.getCooledGas();
            long coolantAmount = Math.round(waterAmount * waterToSteamEfficiency / heatedCoolant.getThermalEnthalpy());
            recipes.add(new BoilerJEIRecipe(GasStackIngredient.from(gas, coolantAmount), FluidStackIngredient.from(FluidTags.WATER, waterAmount), MekanismGases.STEAM.getStack(waterAmount), cooledCoolant.getStack(coolantAmount), HeatUtils.BASE_BOIL_TEMP));
        }
    }
    return recipes;
}
Also used : HeatedCoolant(mekanism.api.chemical.gas.attribute.GasAttributes.HeatedCoolant) ArrayList(java.util.ArrayList) Gas(mekanism.api.chemical.gas.Gas) BoilerJEIRecipe(mekanism.client.jei.machine.BoilerRecipeCategory.BoilerJEIRecipe)

Example 2 with Gas

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

the class GasInventorySlot method fillOrConvert.

/**
 * Fills the tank from this item OR converts the given item to a gas
 */
public static GasInventorySlot fillOrConvert(IGasTank gasTank, Supplier<World> worldSupplier, @Nullable IContentsListener listener, int x, int y) {
    Objects.requireNonNull(gasTank, "Gas tank cannot be null");
    Objects.requireNonNull(worldSupplier, "World supplier cannot be null");
    Function<ItemStack, GasStack> potentialConversionSupplier = stack -> getPotentialConversion(worldSupplier.get(), stack);
    return new GasInventorySlot(gasTank, worldSupplier, getFillOrConvertExtractPredicate(gasTank, GasInventorySlot::getCapability, potentialConversionSupplier), getFillOrConvertInsertPredicate(gasTank, GasInventorySlot::getCapability, potentialConversionSupplier), stack -> {
        if (stack.getCapability(Capabilities.GAS_HANDLER_CAPABILITY).isPresent()) {
            // Note: we mark all gas items as valid and have a more restrictive insert check so that we allow full tanks when they are done being filled
            return true;
        }
        // Allow gas conversion of items that have a gas that is valid
        GasStack gasConversion = getPotentialConversion(worldSupplier.get(), stack);
        return !gasConversion.isEmpty() && gasTank.isValid(gasConversion);
    }, listener, x, y);
}
Also used : Gas(mekanism.api.chemical.gas.Gas) IGasHandler(mekanism.api.chemical.gas.IGasHandler) MethodsReturnNonnullByDefault(mcp.MethodsReturnNonnullByDefault) MekanismRecipeType(mekanism.common.recipe.MekanismRecipeType) Predicate(java.util.function.Predicate) IMekanismInventory(mekanism.api.inventory.IMekanismInventory) World(net.minecraft.world.World) IChemicalHandler(mekanism.api.chemical.IChemicalHandler) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) BooleanSupplier(java.util.function.BooleanSupplier) Objects(java.util.Objects) IContentsListener(mekanism.api.IContentsListener) ItemStack(net.minecraft.item.ItemStack) FieldsAreNonnullByDefault(mekanism.api.annotations.FieldsAreNonnullByDefault) IGasTank(mekanism.api.chemical.gas.IGasTank) Capabilities(mekanism.common.capabilities.Capabilities) GasStack(mekanism.api.chemical.gas.GasStack) NonNull(mekanism.api.annotations.NonNull) Nullable(javax.annotation.Nullable) ItemStackToGasRecipe(mekanism.api.recipes.ItemStackToGasRecipe) GasStack(mekanism.api.chemical.gas.GasStack) ItemStack(net.minecraft.item.ItemStack)

Example 3 with Gas

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

the class RotaryInputRecipeCache method findFirstRecipe.

/**
 * Finds the first recipe that matches the given gas input.
 *
 * @param world World.
 * @param input Recipe input.
 *
 * @return Recipe matching the given gas input, or {@code null} if no recipe matches.
 */
@Nullable
public RotaryRecipe findFirstRecipe(@Nullable World world, GasStack input) {
    if (gasInputCache.isEmpty(input)) {
        // Don't allow empty inputs
        return null;
    }
    initCacheIfNeeded(world);
    Predicate<RotaryRecipe> matchPredicate = recipe -> recipe.test(input);
    RotaryRecipe recipe = gasInputCache.findFirstRecipe(input, matchPredicate);
    return recipe == null ? findFirstRecipe(complexGasInputRecipes, matchPredicate) : recipe;
}
Also used : Gas(mekanism.api.chemical.gas.Gas) RotaryRecipe(mekanism.api.recipes.RotaryRecipe) MekanismRecipeType(mekanism.common.recipe.MekanismRecipeType) Predicate(java.util.function.Predicate) World(net.minecraft.world.World) Set(java.util.Set) ChemicalInputCache(mekanism.common.recipe.lookup.cache.type.ChemicalInputCache) FluidInputCache(mekanism.common.recipe.lookup.cache.type.FluidInputCache) HashSet(java.util.HashSet) List(java.util.List) GasStack(mekanism.api.chemical.gas.GasStack) FluidStack(net.minecraftforge.fluids.FluidStack) Nullable(javax.annotation.Nullable) RotaryRecipe(mekanism.api.recipes.RotaryRecipe) Nullable(javax.annotation.Nullable)

Example 4 with Gas

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

the class CrTGasBuilder method build.

@Override
protected void build(ResourceLocation registryName) {
    Gas gas;
    if (colorRepresentation == null) {
        gas = new Gas(getInternal());
    } else {
        int color = colorRepresentation;
        gas = new Gas(getInternal()) {

            @Override
            public int getColorRepresentation() {
                return color;
            }
        };
    }
    CrTContentUtils.queueGasForRegistration(registryName, gas);
}
Also used : Gas(mekanism.api.chemical.gas.Gas)

Example 5 with Gas

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

the class FissionReactorRecipeCategory method getFissionRecipes.

public static List<FissionJEIRecipe> getFissionRecipes() {
    // Note: The recipes below ignore thermal conductivity and just take enthalpy into account and it rounds the amount of coolant
    // TODO: Eventually we may want to try and improve on that but for now this should be fine
    List<FissionJEIRecipe> recipes = new ArrayList<>();
    double energyPerFuel = MekanismGeneratorsConfig.generators.energyPerFissionFuel.get().doubleValue();
    // Special case water recipe
    long coolantAmount = Math.round(energyPerFuel * HeatUtils.getSteamEnergyEfficiency() / HeatUtils.getWaterThermalEnthalpy());
    recipes.add(new FissionJEIRecipe(null, GasStackIngredient.from(MekanismGases.FISSILE_FUEL, 1), MekanismGases.STEAM.getStack(coolantAmount), MekanismGases.NUCLEAR_WASTE.getStack(1)));
    // Go through all gases and add each coolant
    for (Gas gas : MekanismAPI.gasRegistry()) {
        CooledCoolant cooledCoolant = gas.get(CooledCoolant.class);
        if (cooledCoolant != null) {
            // If it is a cooled coolant add a recipe for it
            Gas heatedCoolant = cooledCoolant.getHeatedGas();
            coolantAmount = Math.round(energyPerFuel / cooledCoolant.getThermalEnthalpy());
            recipes.add(new FissionJEIRecipe(GasStackIngredient.from(gas, coolantAmount), GasStackIngredient.from(MekanismGases.FISSILE_FUEL, 1), heatedCoolant.getStack(coolantAmount), MekanismGases.NUCLEAR_WASTE.getStack(1)));
        }
    }
    return recipes;
}
Also used : CooledCoolant(mekanism.api.chemical.gas.attribute.GasAttributes.CooledCoolant) FissionJEIRecipe(mekanism.generators.client.jei.FissionReactorRecipeCategory.FissionJEIRecipe) ArrayList(java.util.ArrayList) Gas(mekanism.api.chemical.gas.Gas)

Aggregations

Gas (mekanism.api.chemical.gas.Gas)5 ArrayList (java.util.ArrayList)2 Predicate (java.util.function.Predicate)2 Nullable (javax.annotation.Nullable)2 GasStack (mekanism.api.chemical.gas.GasStack)2 MekanismRecipeType (mekanism.common.recipe.MekanismRecipeType)2 World (net.minecraft.world.World)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 BooleanSupplier (java.util.function.BooleanSupplier)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)1 MethodsReturnNonnullByDefault (mcp.MethodsReturnNonnullByDefault)1 IContentsListener (mekanism.api.IContentsListener)1 FieldsAreNonnullByDefault (mekanism.api.annotations.FieldsAreNonnullByDefault)1 NonNull (mekanism.api.annotations.NonNull)1 IChemicalHandler (mekanism.api.chemical.IChemicalHandler)1