Moved our energy net to doubles, should be all done(now need to test), added eu to rf conversion
This commit is contained in:
parent
78faca7a19
commit
30ff429b6a
3 changed files with 88 additions and 18 deletions
|
@ -8,20 +8,20 @@ public interface IEnergyInterfaceTile {
|
|||
*
|
||||
* @return Amount of energy in the tile
|
||||
*/
|
||||
public int getEnergy();
|
||||
public double getEnergy();
|
||||
|
||||
/**
|
||||
* Sets the energy in the tile
|
||||
*
|
||||
* @param energy the amount of energy to set.
|
||||
*/
|
||||
public void setEnergy(int energy);
|
||||
public void setEnergy(double energy);
|
||||
|
||||
/**
|
||||
* Gets the max stored energy in the tile
|
||||
* @return The max energy
|
||||
*/
|
||||
public int getMaxPower();
|
||||
public double getMaxPower();
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -29,7 +29,7 @@ public interface IEnergyInterfaceTile {
|
|||
*
|
||||
* @return will return true if can fit all
|
||||
*/
|
||||
public boolean canAddEnergy(int energy);
|
||||
public boolean canAddEnergy(double energy);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -39,7 +39,7 @@ public interface IEnergyInterfaceTile {
|
|||
*
|
||||
* @return The amount of energy that was added.
|
||||
*/
|
||||
public int addEnergy(int energy);
|
||||
public double addEnergy(double energy);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -49,7 +49,7 @@ public interface IEnergyInterfaceTile {
|
|||
*
|
||||
* @return The amount of energy that was added.
|
||||
*/
|
||||
public int addEnergy(int energy, boolean simulate);
|
||||
public double addEnergy(double energy, boolean simulate);
|
||||
|
||||
/**
|
||||
* Returns true if it can use the full amount of energy
|
||||
|
@ -58,7 +58,7 @@ public interface IEnergyInterfaceTile {
|
|||
*
|
||||
* @return if all the energy can be used.
|
||||
*/
|
||||
public boolean canUseEnergy(int energy);
|
||||
public boolean canUseEnergy(double energy);
|
||||
|
||||
/**
|
||||
* Will try and use the full amount of energy
|
||||
|
@ -67,7 +67,7 @@ public interface IEnergyInterfaceTile {
|
|||
*
|
||||
* @return the amount of energy used
|
||||
*/
|
||||
public int useEnergy(int energy);
|
||||
public double useEnergy(double energy);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -77,7 +77,7 @@ public interface IEnergyInterfaceTile {
|
|||
*
|
||||
* @return the amount of energy used
|
||||
*/
|
||||
public int useEnergy(int energy, boolean simulate);
|
||||
public double useEnergy(double energy, boolean simulate);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -99,12 +99,13 @@ public interface IEnergyInterfaceTile {
|
|||
*
|
||||
* @return the max amount of energy outputted per tick.
|
||||
*/
|
||||
public int getMaxOutput();
|
||||
public double getMaxOutput();
|
||||
|
||||
/**
|
||||
* Return -1 if you don't want to accept power ever.
|
||||
*
|
||||
* @return The max amount of energy that can be added to the tile in one tick.
|
||||
*/
|
||||
public int getMaxInput();
|
||||
public double getMaxInput();
|
||||
|
||||
}
|
||||
|
|
|
@ -5,4 +5,6 @@ public class PowerSystem {
|
|||
public static boolean RFPOWENET = true;
|
||||
|
||||
public static boolean EUPOWENET = true;
|
||||
|
||||
public static double euPerRF = 0.2; // 5eu = 1rf? //TODO
|
||||
}
|
||||
|
|
|
@ -30,8 +30,9 @@ public abstract class TilePowerAcceptor extends TileMachineBase implements
|
|||
IEnergyTile, IEnergySink, IEnergySource //Ic2
|
||||
{
|
||||
public int tier;
|
||||
private int energy;
|
||||
private double energy;
|
||||
public final TileEntity parent;
|
||||
public int maxEnergy;
|
||||
|
||||
public TilePowerAcceptor(int tier, TileEntity parent) {
|
||||
this.tier = tier;
|
||||
|
@ -160,21 +161,21 @@ public abstract class TilePowerAcceptor extends TileMachineBase implements
|
|||
if (!canAcceptEnergy(from)) {
|
||||
return 0;
|
||||
}
|
||||
return addEnergy(maxReceive, simulate);
|
||||
return (int) ((int) addEnergy(maxReceive, simulate) * PowerSystem.euPerRF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
if (!PowerSystem.RFPOWENET)
|
||||
return 0;
|
||||
return getEnergy();
|
||||
return (int) ((int) getEnergy() * PowerSystem.euPerRF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
if (!PowerSystem.RFPOWENET)
|
||||
return 0;
|
||||
return getMaxPower();
|
||||
return (int) ((int) getMaxPower() * PowerSystem.euPerRF);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,22 +185,88 @@ public abstract class TilePowerAcceptor extends TileMachineBase implements
|
|||
if (!canAcceptEnergy(from)) {
|
||||
return 0;
|
||||
}
|
||||
return useEnergy(maxExtract, simulate);
|
||||
return (int) ((int) useEnergy(maxExtract, simulate) * PowerSystem.euPerRF);
|
||||
}
|
||||
//END COFH
|
||||
|
||||
|
||||
|
||||
//TechReborn
|
||||
|
||||
@Override
|
||||
public double getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(double energy) {
|
||||
this.energy = energy;
|
||||
|
||||
if (this.energy > getMaxPower()) {
|
||||
this.energy = getMaxPower();
|
||||
} else if (this.energy < 0) {
|
||||
this.energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double addEnergy(double energy) {
|
||||
return addEnergy(energy, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double addEnergy(double energy, boolean simulate) {
|
||||
double energyReceived = Math.min(getMaxPower() - energy, Math.min(this.getMaxPower(), energy));
|
||||
|
||||
if (!simulate) {
|
||||
this.energy += energyReceived;
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseEnergy(double energy) {
|
||||
return this.energy >= energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double useEnergy(double energy) {
|
||||
return useEnergy(energy, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double useEnergy(double energy, boolean simulate) {
|
||||
double energyExtracted = Math.min(energy, Math.min(this.getMaxOutput(), energy));
|
||||
|
||||
if (!simulate) {
|
||||
this.energy -= energyExtracted;
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddEnergy(double energy) {
|
||||
return this.energy + energy <= getMaxPower();
|
||||
}
|
||||
|
||||
//TechReborn END
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
NBTTagCompound data = tag.getCompoundTag("TilePowerAcceptor");
|
||||
energy = data.getInteger("energy");
|
||||
energy = data.getDouble("energy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setInteger("energy", energy);
|
||||
data.setDouble("energy", energy);
|
||||
tag.setTag("TilePowerAcceptor", data);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue