use of gregtech.api.capability.impl.ItemFuelInfo 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();
}
use of gregtech.api.capability.impl.ItemFuelInfo in project GregTech by GregTechCE.
the class SteamCoalBoiler method getFuels.
@Override
public Collection<IFuelInfo> getFuels() {
ItemStack fuelInSlot = importItems.extractItem(0, Integer.MAX_VALUE, true);
if (fuelInSlot == null || fuelInSlot.isEmpty())
return Collections.emptySet();
final int fuelRemaining = fuelInSlot.getCount();
final int fuelCapacity = importItems.getSlotLimit(0);
final long burnTime = fuelRemaining * TileEntityFurnace.getItemBurnTime(fuelInSlot) * (this.isHighPressure ? 6 : 12);
return Collections.singleton(new ItemFuelInfo(fuelInSlot, fuelRemaining, fuelCapacity, 1, burnTime));
}
use of gregtech.api.capability.impl.ItemFuelInfo in project GregTech by GregTechCE.
the class FuelableInfoProvider method addProbeInfo.
@Override
protected void addProbeInfo(IFuelable capability, IProbeInfo probeInfo, TileEntity tileEntity, EnumFacing sideHit) {
Collection<IFuelInfo> fuels = capability.getFuels();
if (fuels == null || fuels.isEmpty()) {
probeInfo.text(TextStyleClass.WARNING + "{*gregtech.top.fuel_none*}");
return;
}
for (IFuelInfo fuelInfo : fuels) {
final String fuelName = fuelInfo.getFuelName();
final int fuelRemaining = fuelInfo.getFuelRemaining();
final int fuelCapacity = fuelInfo.getFuelCapacity();
final int fuelMinConsumed = fuelInfo.getFuelMinConsumed();
final long burnTime = fuelInfo.getFuelBurnTimeLong() / 20;
IProbeInfo horizontalPane = probeInfo.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER));
if (fuelInfo instanceof ItemFuelInfo) {
horizontalPane.text(TextStyleClass.INFO + "{*gregtech.top.fuel_name*} ").itemLabel(((ItemFuelInfo) fuelInfo).getItemStack());
} else {
horizontalPane.text(TextStyleClass.INFO + "{*gregtech.top.fuel_name*} {*" + fuelName + "*}");
}
horizontalPane = probeInfo.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER));
horizontalPane.progress(fuelRemaining, fuelCapacity, probeInfo.defaultProgressStyle().suffix("/" + fuelCapacity + " ").borderColor(0x00000000).backgroundColor(0x00000000).filledColor(0xFFFFE000).alternateFilledColor(0xFFEED000));
if (fuelRemaining < fuelMinConsumed)
horizontalPane.text("{*gregtech.top.fuel_min_consume*} " + fuelMinConsumed);
else
horizontalPane.text("{*gregtech.top.fuel_burn*} " + burnTime + " {*gregtech.top.fuel_time*}");
}
}
Aggregations