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