mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-18 19:29:19 +00:00
Move Config variables into their own class, (in api because other stuff in API references config, may make sense to move it back to common later), and move Blocks and Items into final variables in their own classes. It looks a lot cleaner this way and my OCD can finally rest now.
63 lines
1.4 KiB
Java
63 lines
1.4 KiB
Java
package mekanism.common;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import mekanism.api.MekanismConfig.general;
|
|
|
|
import mekanism.api.gas.Gas;
|
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
|
import buildcraft.api.fuels.IronEngineFuel;
|
|
import buildcraft.api.fuels.IronEngineFuel.Fuel;
|
|
import cpw.mods.fml.common.ModAPIManager;
|
|
|
|
public class FuelHandler
|
|
{
|
|
public static HashMap<String, FuelGas> fuels = new HashMap<String, FuelGas>();
|
|
|
|
public static void addGas(Gas gas, int burnTicks, double energyPerMilliBucket)
|
|
{
|
|
fuels.put(gas.getName(), new FuelGas(burnTicks, energyPerMilliBucket));
|
|
}
|
|
|
|
public static FuelGas getFuel(Gas gas)
|
|
{
|
|
if(fuels.containsKey(gas.getName()))
|
|
{
|
|
return fuels.get(gas.getName());
|
|
}
|
|
|
|
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|fuels") && gas.hasFluid())
|
|
{
|
|
Fuel bcFuel = IronEngineFuel.getFuelForFluid(gas.getFluid());
|
|
|
|
if(bcFuel != null)
|
|
{
|
|
FuelGas fuel = new FuelGas(bcFuel);
|
|
fuels.put(gas.getName(), fuel);
|
|
|
|
return fuel;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static class FuelGas
|
|
{
|
|
public int burnTicks;
|
|
public double energyPerTick;
|
|
|
|
public FuelGas(int duration, double energyDensity)
|
|
{
|
|
burnTicks = duration;
|
|
energyPerTick = energyDensity / duration;
|
|
}
|
|
|
|
public FuelGas(Fuel bcFuel)
|
|
{
|
|
burnTicks = bcFuel.totalBurningTime / FluidContainerRegistry.BUCKET_VOLUME;
|
|
energyPerTick = bcFuel.powerPerCycle * general.FROM_BC;
|
|
}
|
|
}
|
|
}
|