Engines use float for energy now.

This commit is contained in:
SirSengir 2012-07-21 10:55:40 +02:00
parent 81b58867a5
commit 5bd849d60f
5 changed files with 20 additions and 20 deletions

View file

@ -33,13 +33,13 @@ public class IronEngineFuel {
} }
public final LiquidStack liquid; public final LiquidStack liquid;
public final int powerPerCycle; public final float powerPerCycle;
public final int totalBurningTime; public final int totalBurningTime;
public IronEngineFuel(int liquidId, int powerPerCycle, int totalBurningTime) { public IronEngineFuel(int liquidId, float powerPerCycle, int totalBurningTime) {
this(new LiquidStack(liquidId, BuildCraftAPI.BUCKET_VOLUME, 0), powerPerCycle, totalBurningTime); this(new LiquidStack(liquidId, BuildCraftAPI.BUCKET_VOLUME, 0), powerPerCycle, totalBurningTime);
} }
public IronEngineFuel(LiquidStack liquid, int powerPerCycle, int totalBurningTime) { public IronEngineFuel(LiquidStack liquid, float powerPerCycle, int totalBurningTime) {
this.liquid = liquid; this.liquid = liquid;
this.powerPerCycle = powerPerCycle; this.powerPerCycle = powerPerCycle;
this.totalBurningTime = totalBurningTime; this.totalBurningTime = totalBurningTime;

View file

@ -21,12 +21,12 @@ public abstract class Engine {
public int maxEnergy; public int maxEnergy;
protected int currentOutput = 0; protected float currentOutput = 0;
public @TileNetworkData public @TileNetworkData
float progress; float progress;
public @TileNetworkData public @TileNetworkData
Orientations orientation; Orientations orientation;
public int energy; public float energy;
public @TileNetworkData public @TileNetworkData
EnergyStage energyStage = EnergyStage.Blue; EnergyStage energyStage = EnergyStage.Blue;
@ -84,7 +84,7 @@ public abstract class Engine {
public abstract void delete(); public abstract void delete();
public void addEnergy(int addition) { public void addEnergy(float addition) {
energy += addition; energy += addition;
if (getEnergyStage() == EnergyStage.Explosion) { if (getEnergyStage() == EnergyStage.Explosion) {
@ -96,7 +96,7 @@ public abstract class Engine {
} }
} }
public int extractEnergy(int min, int max, boolean doExtract) { public float extractEnergy(int min, int max, boolean doExtract) {
if (energy < min) { if (energy < min) {
return 0; return 0;
} }
@ -109,7 +109,7 @@ public abstract class Engine {
actualMax = max; actualMax = max;
} }
int extracted; float extracted;
if (energy >= actualMax) { if (energy >= actualMax) {
extracted = actualMax; extracted = actualMax;
@ -154,11 +154,11 @@ public abstract class Engine {
return 0; return 0;
} }
public int getEnergyStored() { public float getEnergyStored() {
return energy; return energy;
} }
public int getCurrentOutput() { public float getCurrentOutput() {
return currentOutput; return currentOutput;
} }

View file

@ -227,10 +227,10 @@ public class EngineIron extends Engine {
public void getGUINetworkData(int i, int j) { public void getGUINetworkData(int i, int j) {
switch (i) { switch (i) {
case 0: case 0:
energy = j; energy = j / 10;
break; break;
case 1: case 1:
currentOutput = j; currentOutput = j / 10;
break; break;
case 2: case 2:
heat = j; heat = j;
@ -252,8 +252,8 @@ public class EngineIron extends Engine {
@Override @Override
public void sendGUINetworkData(ContainerEngine containerEngine, ICrafting iCrafting) { public void sendGUINetworkData(ContainerEngine containerEngine, ICrafting iCrafting) {
iCrafting.updateCraftingInventoryInfo(containerEngine, 0, energy); iCrafting.updateCraftingInventoryInfo(containerEngine, 0, Math.round(energy * 10));
iCrafting.updateCraftingInventoryInfo(containerEngine, 1, currentOutput); iCrafting.updateCraftingInventoryInfo(containerEngine, 1, Math.round(currentOutput * 10));
iCrafting.updateCraftingInventoryInfo(containerEngine, 2, heat); iCrafting.updateCraftingInventoryInfo(containerEngine, 2, heat);
iCrafting.updateCraftingInventoryInfo(containerEngine, 3, liquidQty); iCrafting.updateCraftingInventoryInfo(containerEngine, 3, liquidQty);
iCrafting.updateCraftingInventoryInfo(containerEngine, 4, liquidId); iCrafting.updateCraftingInventoryInfo(containerEngine, 4, liquidId);

View file

@ -155,15 +155,15 @@ public class EngineStone extends Engine {
@Override @Override
public void sendGUINetworkData(ContainerEngine containerEngine, ICrafting iCrafting) { public void sendGUINetworkData(ContainerEngine containerEngine, ICrafting iCrafting) {
iCrafting.updateCraftingInventoryInfo(containerEngine, 0, energy); iCrafting.updateCraftingInventoryInfo(containerEngine, 0, Math.round(energy));
iCrafting.updateCraftingInventoryInfo(containerEngine, 1, currentOutput); iCrafting.updateCraftingInventoryInfo(containerEngine, 1, Math.round(currentOutput));
iCrafting.updateCraftingInventoryInfo(containerEngine, 2, burnTime); iCrafting.updateCraftingInventoryInfo(containerEngine, 2, burnTime);
iCrafting.updateCraftingInventoryInfo(containerEngine, 3, totalBurnTime); iCrafting.updateCraftingInventoryInfo(containerEngine, 3, totalBurnTime);
} }
@Override @Override
public int getHeat() { public int getHeat() {
return energy; return Math.round(energy);
} }
/* IINVENTORY */ /* IINVENTORY */

View file

@ -121,7 +121,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
if (isPoweredTile(tile)) { if (isPoweredTile(tile)) {
IPowerReceptor receptor = (IPowerReceptor) tile; IPowerReceptor receptor = (IPowerReceptor) tile;
int extracted = engine.extractEnergy(receptor.getPowerProvider().getMinEnergyReceived(), float extracted = engine.extractEnergy(receptor.getPowerProvider().getMinEnergyReceived(),
receptor.getPowerProvider().getMaxEnergyReceived(), true); receptor.getPowerProvider().getMaxEnergyReceived(), true);
if (extracted > 0) { if (extracted > 0) {
@ -227,7 +227,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
if (engine != null) { if (engine != null) {
engine.progress = nbttagcompound.getFloat("progress"); engine.progress = nbttagcompound.getFloat("progress");
engine.energy = nbttagcompound.getInteger("energy"); engine.energy = nbttagcompound.getFloat("energyF");
engine.orientation = Orientations.values()[orientation]; engine.orientation = Orientations.values()[orientation];
} }
@ -245,7 +245,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
if (engine != null) { if (engine != null) {
nbttagcompound.setInteger("orientation", orientation); nbttagcompound.setInteger("orientation", orientation);
nbttagcompound.setFloat("progress", engine.progress); nbttagcompound.setFloat("progress", engine.progress);
nbttagcompound.setInteger("energy", engine.energy); nbttagcompound.setFloat("energyF", engine.energy);
} }
if (engine != null) { if (engine != null) {