Search in sources :

Example 1 with FluidFuelInfo

use of gregtech.api.capability.impl.FluidFuelInfo in project GregTech by GregTechCE.

the class MetaTileEntityLargeBoiler method getFuels.

@Override
public Collection<IFuelInfo> getFuels() {
    if (!isStructureFormed())
        return Collections.emptySet();
    final LinkedHashMap<Object, IFuelInfo> fuels = new LinkedHashMap<Object, IFuelInfo>();
    // fluid capacity is all non water tanks
    int fluidCapacity = 0;
    for (IFluidTank fluidTank : fluidImportInventory.getFluidTanks()) {
        FluidStack fuelStack = fluidTank.drain(Integer.MAX_VALUE, false);
        if (!ModHandler.isWater(fuelStack))
            fluidCapacity += fluidTank.getCapacity();
    }
    for (IFluidTank fluidTank : fluidImportInventory.getFluidTanks()) {
        FluidStack fuelStack = fluidTank.drain(Integer.MAX_VALUE, false);
        if (fuelStack == null || ModHandler.isWater(fuelStack))
            continue;
        FuelRecipe dieselRecipe = RecipeMaps.DIESEL_GENERATOR_FUELS.findRecipe(GTValues.V[9], fuelStack);
        if (dieselRecipe != null) {
            long recipeVoltage = FuelRecipeLogic.getTieredVoltage(dieselRecipe.getMinVoltage());
            int voltageMultiplier = (int) Math.max(1L, recipeVoltage / GTValues.V[GTValues.LV]);
            int burnTime = (int) Math.ceil(dieselRecipe.getDuration() * CONSUMPTION_MULTIPLIER / 2.0 * voltageMultiplier * getThrottleMultiplier());
            int fuelAmountToConsume = (int) Math.ceil(dieselRecipe.getRecipeFluid().amount * CONSUMPTION_MULTIPLIER * boilerType.fuelConsumptionMultiplier * getThrottleMultiplier());
            final long fuelBurnTime = (fuelStack.amount * burnTime) / fuelAmountToConsume;
            FluidFuelInfo fluidFuelInfo = (FluidFuelInfo) fuels.get(fuelStack.getUnlocalizedName());
            if (fluidFuelInfo == null) {
                fluidFuelInfo = new FluidFuelInfo(fuelStack, fuelStack.amount, fluidCapacity, fuelAmountToConsume, fuelBurnTime);
                fuels.put(fuelStack.getUnlocalizedName(), fluidFuelInfo);
            } else {
                fluidFuelInfo.addFuelRemaining(fuelStack.amount);
                fluidFuelInfo.addFuelBurnTime(fuelBurnTime);
            }
        }
        FuelRecipe denseFuelRecipe = RecipeMaps.SEMI_FLUID_GENERATOR_FUELS.findRecipe(GTValues.V[9], fuelStack);
        if (denseFuelRecipe != null) {
            long recipeVoltage = FuelRecipeLogic.getTieredVoltage(denseFuelRecipe.getMinVoltage());
            int voltageMultiplier = (int) Math.max(1L, recipeVoltage / GTValues.V[GTValues.LV]);
            int burnTime = (int) Math.ceil(denseFuelRecipe.getDuration() * CONSUMPTION_MULTIPLIER * 2 * voltageMultiplier * getThrottleMultiplier());
            int fuelAmountToConsume = (int) Math.ceil(denseFuelRecipe.getRecipeFluid().amount * CONSUMPTION_MULTIPLIER * boilerType.fuelConsumptionMultiplier * getThrottleMultiplier());
            final long fuelBurnTime = (fuelStack.amount * burnTime) / fuelAmountToConsume;
            FluidFuelInfo fluidFuelInfo = (FluidFuelInfo) fuels.get(fuelStack.getUnlocalizedName());
            if (fluidFuelInfo == null) {
                fluidFuelInfo = new FluidFuelInfo(fuelStack, fuelStack.amount, fluidCapacity, fuelAmountToConsume, fuelBurnTime);
                fuels.put(fuelStack.getUnlocalizedName(), fluidFuelInfo);
            } else {
                fluidFuelInfo.addFuelRemaining(fuelStack.amount);
                fluidFuelInfo.addFuelBurnTime(fuelBurnTime);
            }
        }
    }
    // item capacity is all slots
    int itemCapacity = 0;
    for (int slotIndex = 0; slotIndex < itemImportInventory.getSlots(); slotIndex++) {
        itemCapacity += itemImportInventory.getSlotLimit(slotIndex);
    }
    for (int slotIndex = 0; slotIndex < itemImportInventory.getSlots(); slotIndex++) {
        ItemStack itemStack = itemImportInventory.getStackInSlot(slotIndex);
        final long burnTime = (int) Math.ceil(TileEntityFurnace.getItemBurnTime(itemStack) / (50.0 * this.boilerType.fuelConsumptionMultiplier * getThrottleMultiplier()));
        if (burnTime > 0) {
            ItemFuelInfo itemFuelInfo = (ItemFuelInfo) fuels.get(itemStack.getTranslationKey());
            if (itemFuelInfo == null) {
                itemFuelInfo = new ItemFuelInfo(itemStack, itemStack.getCount(), itemCapacity, 1, itemStack.getCount() * burnTime);
                fuels.put(itemStack.getTranslationKey(), itemFuelInfo);
            } else {
                itemFuelInfo.addFuelRemaining(itemStack.getCount());
                itemFuelInfo.addFuelBurnTime(itemStack.getCount() * burnTime);
            }
        }
    }
    return fuels.values();
}
Also used : IFuelInfo(gregtech.api.capability.IFuelInfo) FluidFuelInfo(gregtech.api.capability.impl.FluidFuelInfo) FluidStack(net.minecraftforge.fluids.FluidStack) ItemFuelInfo(gregtech.api.capability.impl.ItemFuelInfo) FuelRecipe(gregtech.api.recipes.recipes.FuelRecipe) ItemStack(net.minecraft.item.ItemStack) IFluidTank(net.minecraftforge.fluids.IFluidTank) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with FluidFuelInfo

use of gregtech.api.capability.impl.FluidFuelInfo in project GregTech by GregTechCE.

the class SteamLavaBoiler method getFuels.

@Override
public Collection<IFuelInfo> getFuels() {
    FluidStack lava = lavaFluidTank.drain(Integer.MAX_VALUE, false);
    if (lava == null || lava.amount == 0)
        return Collections.emptySet();
    final int fuelRemaining = lava.amount;
    final int fuelCapacity = lavaFluidTank.getCapacity();
    // 100 mb lasts 600 or 1200 ticks
    final long burnTime = fuelRemaining * (this.isHighPressure ? 6 : 12);
    return Collections.singleton(new FluidFuelInfo(lava, fuelRemaining, fuelCapacity, LAVA_PER_OPERATION, burnTime));
}
Also used : FluidFuelInfo(gregtech.api.capability.impl.FluidFuelInfo) FluidStack(net.minecraftforge.fluids.FluidStack)

Aggregations

FluidFuelInfo (gregtech.api.capability.impl.FluidFuelInfo)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 IFuelInfo (gregtech.api.capability.IFuelInfo)1 ItemFuelInfo (gregtech.api.capability.impl.ItemFuelInfo)1 FuelRecipe (gregtech.api.recipes.recipes.FuelRecipe)1 LinkedHashMap (java.util.LinkedHashMap)1 ItemStack (net.minecraft.item.ItemStack)1 IFluidTank (net.minecraftforge.fluids.IFluidTank)1